Contract Tests #1543
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: Contract Tests | |
on: | |
pull_request: | |
push: | |
branches: | |
- 'v1*' | |
- 'develop' | |
- '*alphanet*' | |
- '*testnet*' | |
schedule: | |
- cron: '50 0 * * *' # every 24 hour | |
workflow_dispatch: | |
# Use concurrency to ensure that only a single job or workflow | |
# using the same concurrency group will run at a time. | |
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions?query=workflow_dispatch#concurrency | |
concurrency: | |
group: staging_environments | |
cancel-in-progress: false | |
jobs: | |
contract-tests: | |
if: github.repository == 'godwokenrises/godwoken-tests' | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
# network: [gw_testnet_v1, gw_alphanet_v1] | |
network: [gw_testnet_v1] | |
outputs: | |
available: ${{ steps.check.outputs.available }} | |
steps: | |
- name: Check Environments | |
id: check | |
env: | |
KEY1: '${{ secrets.GODWOKEN_TEST_PRIVATE_KEY }}' | |
KEY2: '${{ secrets.GODWOKEN_TEST_PRIVATE_KEY2 }}' | |
KEY3: '${{ secrets.GW_TESTNET_V1_TEST_PK }}' | |
if: ${{ env.KEY1 != '' && env.KEY2 != '' && env.KEY3 != '' }} | |
run: echo "available=true" >> $GITHUB_OUTPUT | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '18' | |
- name: Get npm cache directory | |
id: npm-cache-dir | |
shell: bash | |
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir | |
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT | |
- name: Hardhat cache | |
uses: actions/cache@v3 | |
id: hardhat-cache | |
with: | |
path: ~/.cache/hardhat-nodejs | |
key: ${{ runner.os }}-hardhat-nodejs-${{ hashFiles('contracts/package-lock.json', 'testcases/account-abstraction/yarn.lock') }} | |
- name: Node Cache for contracts directory | |
uses: actions/cache@v3 | |
id: npm-and-yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | |
with: | |
path: | | |
${{ steps.npm-cache-dir.outputs.dir }} | |
${{ steps.yarn-cache-dir.outputs.dir }} | |
contracts/artifacts | |
contracts/cache | |
key: ${{ runner.os }}-node_modules-${{ hashFiles('contracts/package-lock.json', 'testcases/account-abstraction/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node_modules- | |
- name: Test | Run internal contract tests | |
working-directory: contracts | |
run: | | |
ls test | |
npm install | |
npm run compile | |
npm run test:${{ matrix.network }} | |
- name: Test | Run gasless tests | |
working-directory: testcases/account-abstraction | |
run: | | |
ls test | |
yarn | |
yarn run ci | |
yarn run hardhat test --network ${{ matrix.network }} | |
notice: | |
runs-on: ubuntu-latest | |
needs: contract-tests | |
if: success() || failure() | |
steps: | |
- name: send contract-tests status | |
run: | | |
curl -H "Content-Type: application/json" \ | |
-X POST https://discord.com/api/webhooks/${{secrets.DISCORD_CHANNEL_ID}}/${{secrets.DISCORD_CHANNEL_TOKEN}} \ | |
--data ' | |
{ | |
"content": "Contract test", | |
"embeds": [ | |
{ | |
"title":"Contract Test Status", | |
"color": 5814789, | |
"fields": [ | |
{ | |
"name": "Job name", | |
"value": "contract-tests\n" | |
}, | |
{ "name": "Job statues", | |
"value": "${{needs.contract-tests.result}}\n" | |
}, | |
{ | |
"name": "URL", | |
"value": "[Click and jump to Github workflow](https://github.com/godwokenrises/godwoken-tests/actions/workflows/contract-test.yml)\n" | |
} | |
] | |
} | |
] | |
}' |