|
| 1 | +name: gas measurement |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + name: gas measurement |
| 12 | + runs-on: ubuntu-latest |
| 13 | + env: |
| 14 | + GAS_OUT_DIR: gas_reports |
| 15 | + steps: |
| 16 | + - name: Checkout sources |
| 17 | + uses: actions/checkout@v3 |
| 18 | + |
| 19 | + - name: Install latest nightly toolchain |
| 20 | + uses: actions-rs/toolchain@v1 |
| 21 | + with: |
| 22 | + profile: minimal |
| 23 | + toolchain: nightly |
| 24 | + target: wasm32-unknown-unknown |
| 25 | + override: true |
| 26 | + |
| 27 | + - name: Rust Dependencies Cache |
| 28 | + uses: actions/cache@v3 |
| 29 | + with: |
| 30 | + path: | |
| 31 | + ~/.cargo/registry/index/ |
| 32 | + ~/.cargo/registry/cache/ |
| 33 | + ~/.cargo/git/db/ |
| 34 | + target/ |
| 35 | + artifacts/ |
| 36 | + key: ${{ runner.os }}-cargo-with-artifacts-${{ hashFiles('**/Cargo.lock') }} |
| 37 | + |
| 38 | + - name: Set latest just version |
| 39 | + run: echo "JUST_VERSION=$(cargo search just -q | sed -n -e '/^just[[:space:]]/p' | cut -d '"' -f 2)" >> $GITHUB_ENV |
| 40 | + |
| 41 | + - name: Get cached just |
| 42 | + uses: actions/cache@v3 |
| 43 | + with: |
| 44 | + path: ~/.cargo/bin/just |
| 45 | + key: ${{ runner.os }}-just-${{ env.JUST_VERSION }} |
| 46 | + |
| 47 | + - name: Install just |
| 48 | + run: cargo install just || true |
| 49 | + |
| 50 | + - name: Run Integration Tests |
| 51 | + run: just integration-test |
| 52 | + |
| 53 | + - name: List gas reports |
| 54 | + run: ls ci/integration-tests/gas_reports |
| 55 | + |
| 56 | + - name: Combine Test Gas Reports |
| 57 | + run: cd ci/integration-tests/ && jq -rs 'reduce .[] as $item ({}; . * $item)' gas_reports/*.json > gas_report.json |
| 58 | + |
| 59 | + - name: Raw Gas Report |
| 60 | + run: cat ci/integration-tests/gas_report.json |
| 61 | + |
| 62 | + - name: Set GIT_BRANCH |
| 63 | + run: echo "GIT_BRANCH=$(echo ${{ github.ref }} | sed 's|/|-|g')" >> $GITHUB_ENV |
| 64 | + |
| 65 | + - name: Upload Gas Report |
| 66 | + if: ${{ github.ref == 'refs/heads/main' }} |
| 67 | + uses: actions/upload-artifact@v3 |
| 68 | + with: |
| 69 | + name: cw-nfts-gas-report-${{ env.GIT_BRANCH }} |
| 70 | + path: ci/integration-tests/gas_report.json |
| 71 | + retention-days: 90 |
| 72 | + |
| 73 | + - name: Download main gas report |
| 74 | + id: download_gas |
| 75 | + # Because the max retention period of github artifacts is 90 days |
| 76 | + # there's a possibility the main's report no longer exists |
| 77 | + continue-on-error: true |
| 78 | + if: ${{ github.ref != 'refs/heads/main' }} |
| 79 | + # NOTE: We can't use github's `actions/download-artifact` because it doesnt support |
| 80 | + # downloading an artifact cross workflows yet |
| 81 | + # https://github.com/actions/download-artifact/issues/3 |
| 82 | + uses: dawidd6/action-download-artifact@v2 |
| 83 | + with: |
| 84 | + branch: main |
| 85 | + workflow: cosm-orc.yml |
| 86 | + name: cw-nfts-gas-report-refs-heads-main |
| 87 | + |
| 88 | + - name: Post gas diff to PR |
| 89 | + if: ${{ github.ref != 'refs/heads/main' && steps.download_gas.outputs.error_message == ''}} |
| 90 | + uses: de-husk/cosm-orc-gas-diff-action@v0.6.2 |
| 91 | + with: |
| 92 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 93 | + current_json: ci/integration-tests/gas_report.json |
| 94 | + old_json: gas_report.json |
0 commit comments