Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CosmOrc test for NFT mint, transfer, and instantiate gas usage. #84

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
wasm = "build --release --target wasm32-unknown-unknown"
wasm-debug = "build --target wasm32-unknown-unknown"
unit-test = "test --lib"
integration-test = "test --package integration-tests -- --ignored --test-threads 1"
94 changes: 94 additions & 0 deletions .github/workflows/cosm-orc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: gas measurement

on:
pull_request:
push:
branches:
- main

jobs:
test:
name: gas measurement
runs-on: ubuntu-latest
env:
GAS_OUT_DIR: gas_reports
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install latest nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
target: wasm32-unknown-unknown
override: true

- name: Rust Dependencies Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
artifacts/
key: ${{ runner.os }}-cargo-with-artifacts-${{ hashFiles('**/Cargo.lock') }}

- name: Set latest just version
run: echo "JUST_VERSION=$(cargo search just -q | sed -n -e '/^just[[:space:]]/p' | cut -d '"' -f 2)" >> $GITHUB_ENV

- name: Get cached just
uses: actions/cache@v3
with:
path: ~/.cargo/bin/just
key: ${{ runner.os }}-just-${{ env.JUST_VERSION }}

- name: Install just
run: cargo install just || true

- name: Run Integration Tests
run: just integration-test

- name: List gas reports
run: ls ci/integration-tests/gas_reports

- name: Combine Test Gas Reports
run: cd ci/integration-tests/ && jq -rs 'reduce .[] as $item ({}; . * $item)' gas_reports/*.json > gas_report.json

- name: Raw Gas Report
run: cat ci/integration-tests/gas_report.json

- name: Set GIT_BRANCH
run: echo "GIT_BRANCH=$(echo ${{ github.ref }} | sed 's|/|-|g')" >> $GITHUB_ENV

- name: Upload Gas Report
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/upload-artifact@v3
with:
name: cw-nfts-gas-report-${{ env.GIT_BRANCH }}
path: ci/integration-tests/gas_report.json
retention-days: 90

- name: Download main gas report
id: download_gas
# Because the max retention period of github artifacts is 90 days
# there's a possibility the main's report no longer exists
continue-on-error: true
if: ${{ github.ref != 'refs/heads/main' }}
# NOTE: We can't use github's `actions/download-artifact` because it doesnt support
# downloading an artifact cross workflows yet
# https://github.com/actions/download-artifact/issues/3
uses: dawidd6/action-download-artifact@v2
with:
branch: main
workflow: cosm-orc.yml
name: cw-nfts-gas-report-refs-heads-main

- name: Post gas diff to PR
if: ${{ github.ref != 'refs/heads/main' && steps.download_gas.outputs.found_artifact == 'true' }}
uses: de-husk/cosm-orc-gas-diff-action@v0.6.2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
current_json: ci/integration-tests/gas_report.json
old_json: gas_report.json