Skip to content

Commit

Permalink
Boilerplate for e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tasiov committed Mar 20, 2023
1 parent bfc9ba3 commit b3fd4d8
Show file tree
Hide file tree
Showing 17 changed files with 2,725 additions and 27 deletions.
1 change: 1 addition & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ wasm = "build --release --target wasm32-unknown-unknown"
wasm-debug = "build --target wasm32-unknown-unknown"
unit-test = "test --lib"
schema = "run --example schema"
integration-test = "test --package e2e -- --ignored --test-threads 1 -Z unstable-options --report-time"
94 changes: 94 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: E2E Integration Tests

on:
pull_request:
push:
branches:
- main

jobs:
test:
name: E2E tests
runs-on: ubuntu-latest
env:
GAS_OUT_DIR: gas_reports
ENABLE_MAX_COLLECTION: true
GAS_LIMIT: 75000000
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install latest nightly toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
targets: wasm32-unknown-unknown

- 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: Get mainnet GAS_LIMIT
run: echo "MAINNET_GAS_LIMIT=$(curl -s https://rpc.stargaze-apis.com/consensus_params | jq -r '.result.consensus_params.block.max_gas')" >> $GITHUB_ENV

- name: Mainnet block GAS_LIMIT changed
if: ${{ env.MAINNET_GAS_LIMIT != env.GAS_LIMIT }}
uses: actions/github-script@v6
with:
script: core.setFailed(`Integration tests must update GAS_LIMIT from ${process.env.GAS_LIMIT} to ${process.env.MAINNET_GAS_LIMIT}`)

- name: Deploy local Stargaze node
run: make deploy-local

- name: Optimize Contracts
run: make optimize

- name: Run Integration Tests
run: make e2etest

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

- name: Raw Gas Report
run: cat e2e/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: infinity-pool-gas-report-${{ env.GIT_BRANCH }}
path: e2e/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: e2e.yml
name: infinity-pool-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/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
current_json: e2e/gas_report.json
old_json: gas_report.json
Loading

0 comments on commit b3fd4d8

Please sign in to comment.