-
Notifications
You must be signed in to change notification settings - Fork 19
123 lines (114 loc) · 4.02 KB
/
contract-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
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]
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"
}
]
}
]
}'