v2.3.0 migration script and upgrade test #3777
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Contracts CI | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
types: [opened, reopened, synchronize, ready_for_review] | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
if: ${{ !github.event.pull_request.draft }} | |
name: setup | |
outputs: | |
test-chunks: ${{ steps['set-test-chunks'].outputs['test-chunks'] }} | |
test-chunk-ids: ${{ steps['set-test-chunk-ids'].outputs['test-chunk-ids'] }} | |
steps: | |
- name: Checkout repository | |
uses: actions/[email protected] | |
- name: Setup node | |
uses: actions/[email protected] | |
with: | |
node-version: 16.14.x | |
cache: "npm" | |
- run: npm install | |
- name: Prepare Environment | |
shell: bash | |
run: | | |
cp .env.example .env | |
- run: npm run build | |
- name: Lint | |
run: | | |
npm run check:contracts | |
npm run check:scripts | |
- name: Verify interface ids | |
run: npm run natspec-interface-id | |
- id: set-test-chunks | |
name: Set Chunks | |
run: echo "test-chunks=$(jq -c '.' test/util/test-chunks.txt)" >> $GITHUB_OUTPUT | |
- id: set-test-chunk-ids | |
name: Set Chunk IDs | |
run: | | |
echo "test-chunk-ids=$( echo $CHUNKS | jq -cM 'to_entries | map(.key)')" >> $GITHUB_OUTPUT | |
env: | |
CHUNKS: ${{ steps['set-test-chunks'].outputs['test-chunks'] }} | |
test: | |
needs: setup | |
runs-on: ubuntu-latest | |
if: ${{ !github.event.pull_request.draft }} | |
env: | |
GAS_REPORTER_COINMARKETCAP_API_KEY: ${{ secrets.COINMARKETCAP_API_KEY }} | |
name: test (chunk ${{ matrix.chunk }}) | |
strategy: | |
matrix: | |
chunk: ${{ fromJson(needs.setup.outputs['test-chunk-ids']) }} | |
steps: | |
- name: Checkout repository | |
uses: actions/[email protected] | |
- name: Setup node | |
uses: actions/[email protected] | |
with: | |
node-version: 16.14.x | |
cache: "npm" | |
- name: Install Dependencies | |
run: npm install | |
- name: Prepare Environment | |
shell: bash | |
run: | | |
cp .env.example .env | |
- name: Compile Contracts | |
run: npm run build | |
- name: Contract Sizing | |
run: npm run size | |
- name: Unit Tests | |
run: echo $CHUNKS | jq '.[${{ matrix.chunk }}] | .[] | @text' | xargs npx hardhat test | |
env: | |
CHUNKS: ${{ needs.setup.outputs['test-chunks'] }} | |
integration-test: | |
needs: setup | |
runs-on: ubuntu-latest | |
if: ${{ !github.event.pull_request.draft }} | |
env: | |
GAS_REPORTER_COINMARKETCAP_API_KEY: ${{ secrets.COINMARKETCAP_API_KEY }} | |
name: "test:integration" | |
steps: | |
- name: Checkout repository | |
uses: actions/[email protected] | |
- name: Setup node | |
uses: actions/[email protected] | |
with: | |
node-version: 16.14.x | |
cache: "npm" | |
- name: Install Dependencies | |
run: npm install | |
- name: Prepare Environment | |
shell: bash | |
run: | | |
cp .env.example .env | |
- name: Integration tests | |
run: npx hardhat test test/integration/*.js | |
coverage: | |
needs: setup | |
if: ${{ !github.event.pull_request.draft }} | |
env: | |
GAS_REPORTER_COINMARKETCAP_API_KEY: ${{ secrets.COINMARKETCAP_API_KEY }} | |
name: code coverage | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/[email protected] | |
- name: Setup node | |
uses: actions/[email protected] | |
with: | |
node-version: 16.14.x | |
cache: "npm" | |
- name: Install Dependencies | |
run: npm install | |
- name: Prepare Environment | |
shell: bash | |
run: | | |
cp .env.example .env | |
- name: Code coverage | |
run: npm run coverage | |
- name: Upload code coverage results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: code-coverage-report | |
path: coverage/ | |
- name: Check Code Coverage | |
shell: bash | |
run: | | |
MAX_SKIPPED=1 # at this moment msgData() in BosonVoucher is not covered | |
{ read TOTAL; read COVERED; read COVERAGE; } <<< $(jq '.total.lines.total, .total.lines.covered, .total.lines.pct' coverage/coverage-summary.json) | |
SKIPPED=$(($TOTAL - $COVERED)) | |
echo "solidity code coverage is '$COVERAGE'" | |
if (( $(echo "$SKIPPED > $MAX_SKIPPED" | bc -l) )); then echo "Fail: number of skipped statements '$SKIPPED' is higher than configured '$MAX_SKIPPED'" >&2; exit 1; fi | |
echo "Number of skipped statements '$SKIPPED' is within configured '$MAX_SKIPPED'" | |
report-coverage: | |
needs: coverage | |
runs-on: ubuntu-latest | |
env: | |
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} | |
name: "report: coverage" | |
steps: | |
- name: Checkout repository | |
uses: actions/[email protected] | |
- name: Setup node | |
uses: actions/[email protected] | |
with: | |
node-version: 16.14.x | |
cache: "npm" | |
- name: npm install | |
run: npm install | |
- name: Download code coverage results | |
uses: actions/download-artifact@v3 | |
with: | |
name: code-coverage-report | |
path: coverage/ | |
- name: Coveralls | |
uses: coverallsapp/github-action@v2 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
path-to-lcov: ./coverage/lcov.info | |
deploy-dry-run: | |
needs: setup | |
runs-on: ubuntu-latest | |
if: ${{ !github.event.pull_request.draft }} | |
name: "deploy: dry run" | |
steps: | |
- name: Checkout repository | |
uses: actions/[email protected] | |
- name: Setup node | |
uses: actions/[email protected] | |
with: | |
node-version: 16.14.x | |
cache: "npm" | |
- name: Install Dependencies | |
run: npm install | |
- name: Prepare Environment | |
shell: bash | |
run: | | |
cp .env.example .env | |
- name: Deploy suite locally | |
run: npm run deploy-suite:hardhat | |
- name: Cancelling tests in case of failure | |
if: failure() | |
uses: andymckay/[email protected] | |
# analyze: | |
# needs: setup | |
# runs-on: ubuntu-latest | |
# permissions: | |
# contents: read | |
# security-events: write | |
# steps: | |
# - name: Checkout repository | |
# uses: actions/[email protected] | |
# - name: Setup node | |
# uses: actions/[email protected] | |
# with: | |
# node-version: 16.14.x | |
# cache: "npm" | |
# - name: Install Dependencies | |
# run: npm install | |
# - name: Prepare Environment | |
# shell: bash | |
# run: | | |
# cp .env.example .env | |
# - name: Slither analyzer | |
# uses: crytic/[email protected] | |
# id: slither | |
# with: | |
# node-version: 16 | |
# sarif: results.sarif | |
# fail-on: none | |
# - name: Upload SARIF file | |
# uses: github/codeql-action/upload-sarif@v2 | |
# with: | |
# sarif_file: ${{ steps.slither.outputs.sarif }} |