Skip to content

Commit 49cdb7c

Browse files
authored
ci: refactor the e2e test workflow (#1436)
* chore(CI): refactor the E2E test workflow * chore(CI): install GNU M4 for the E2E test job * chore(deps): update puppeteer in tests/e2e * chore(CI): rewine the cargo-build-cache key * node-version: "16" * chore(deps): update eslint in tests/e2e * chore(CI): run E2E test for every commit With cache, `make e2e-test-ci` only takes only 7 minutes.
1 parent 271613a commit 49cdb7c

File tree

8 files changed

+245
-389
lines changed

8 files changed

+245
-389
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ See also:
3636

3737
**CI Switch**
3838

39-
- [ ] E2E Tests
4039
- [ ] Web3 Compatible Tests
4140
- [ ] OCT 1-5 And 12-15
4241
- [ ] OCT 6-10
@@ -48,18 +47,15 @@ See also:
4847

4948
| CI Name | Description |
5049
| ----------------------------------------- | ------------------------------------------------------------------------- |
51-
| *Chaos CI* | Test the liveness and robustness of Axon under terrible network condition |
52-
| *Cargo Clippy* | Run `cargo clippy --all --all-targets --all-features` |
53-
| *Coverage Test* | Get the unit test coverage report |
54-
| *E2E Test* | Run end-to-end test to check interfaces |
55-
| *Code Format* | Run `cargo +nightly fmt --all -- --check` and `cargo sort -gwc` |
5650
| *Web3 Compatible Test* | Test the Web3 compatibility of Axon |
5751
| *v3 Core Test* | Run the compatibility tests provided by Uniswap V3 |
5852
| *OCT 1-5 \| 6-10 \| 11 \| 12-15 \| 16-19* | Run the compatibility tests provided by OpenZeppelin |
5953

6054
<!--
6155
#### Deprecated CIs
6256
- [ ] Chaos CI
57+
| *Chaos CI* | Test the liveness and robustness of Axon under terrible network condition |
6358
- [ ] Coverage Test
59+
| *Coverage Test* | Get the unit test coverage report |
6460
-->
6561
</details>

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ jobs:
3838
~/.cargo/registry/cache/
3939
~/.cargo/git/db/
4040
target/
41-
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }}
41+
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
42+
restore-keys: |
43+
${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build
4244
4345
- name: Build Axon in the development profile
4446
if: steps.axon-bin-cache.outputs.cache-hit != 'true'

.github/workflows/e2e_test.yml

Lines changed: 52 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,73 @@
11
name: E2E Tests
2+
23
on:
34
push:
4-
branches:
5-
- main
65
pull_request:
7-
types: [ opened, synchronize, reopened ]
86
merge_group:
9-
workflow_dispatch:
10-
inputs:
11-
dispatch:
12-
type: string
13-
description: "Dispatch contains pr context that want to trigger e2e test"
14-
required: true
7+
8+
# Ensure that only a single job or workflow using the same concurrency group will run at a time.
9+
# see https://docs.github.com/en/actions/using-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
# only needs to test the group's latest commit
13+
cancel-in-progress: true
1514

1615
jobs:
17-
dispatch-build:
18-
if: contains(github.event_name, 'workflow_dispatch')
19-
runs-on: ubuntu-latest
20-
outputs:
21-
output-sha: ${{ steps.escape_multiple_lines_test_inputs.outputs.result }}
16+
e2e-test:
17+
strategy:
18+
matrix:
19+
# Supported GitHub-hosted runners and hardware resources
20+
# see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
21+
os: [ubuntu-22.04]
22+
fail-fast: false
23+
runs-on: ${{ matrix.os }}
24+
2225
steps:
23-
- name: Generate axon-bot token
24-
if: contains(github.event_name, 'workflow_dispatch') &&
25-
github.repository_owner == 'axonweb3' && github.event.inputs.dispatch != 'regression'
26-
id: generate_axon_bot_token
27-
uses: wow-actions/use-app-token@v2
28-
with:
29-
app_id: ${{ secrets.AXON_BOT_APP_ID }}
30-
private_key: ${{ secrets.AXON_BOT_PRIVATE_KEY }}
31-
- name: Event is dispatch
32-
if: contains(github.event_name, 'workflow_dispatch') &&
33-
github.repository_owner == 'axonweb3' && github.event.inputs.dispatch != 'regression'
34-
uses: actions/github-script@v6
35-
id: get_sha
36-
with:
37-
github-token: ${{ steps.generate_axon_bot_token.outputs.BOT_TOKEN }}
38-
script: |
39-
const dispatch = JSON.parse(`${{ github.event.inputs.dispatch }}`);
40-
const pr = (
41-
await github.rest.pulls.get({
42-
owner: dispatch.repo.owner,
43-
repo: dispatch.repo.repo,
44-
pull_number: dispatch.issue.number,
45-
})
46-
).data.head;
47-
github.rest.repos.createCommitStatus({
48-
state: 'pending',
49-
owner: dispatch.repo.owner,
50-
repo: dispatch.repo.repo,
51-
context: '${{ github.workflow }}',
52-
sha: pr.sha,
53-
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
54-
})
55-
return pr.sha
56-
- name: Escape multiple lines test inputs
57-
if: contains(github.event_name, 'workflow_dispatch') &&
58-
github.repository_owner == 'axonweb3' && github.event.inputs.dispatch != 'regression'
59-
id: escape_multiple_lines_test_inputs
60-
run: |
61-
inputs=${{ steps.get_sha.outputs.result}}
62-
inputs="${inputs//'%'/'%25'}"
63-
inputs="${inputs//'\n'/'%0A'}"
64-
inputs="${inputs//'\r'/'%0D'}"
65-
echo "result=$inputs" >> $GITHUB_OUTPUT
66-
- name: Git checkout
67-
uses: actions/checkout@v4
68-
with:
69-
ref: ${{ steps.escape_multiple_lines_test_inputs.outputs.result || 'main' }}
70-
- uses: lyricwulf/abc@v1
71-
with:
72-
linux: m4
26+
- uses: actions/checkout@v4
7327

74-
- name: Use Node.js ${{ matrix.node-version }}
75-
uses: actions/setup-node@v3
28+
- name: Cache of Cargo
29+
uses: actions/cache@v3
7630
with:
77-
node-version: "16"
78-
cache: "yarn"
79-
cache-dependency-path: "tests/e2e/yarn.lock"
80-
81-
- name: E2E Tests Linting
82-
run: make e2e-test-lint
31+
path: |
32+
~/.cargo/bin/
33+
~/.cargo/registry/index/
34+
~/.cargo/registry/cache/
35+
~/.cargo/git/db/
36+
target/
37+
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
38+
restore-keys: |
39+
${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build
40+
${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo
8341
84-
- name: E2E Tests
85-
run: make e2e-test-ci
86-
finally:
87-
name: Finally
88-
needs: [ dispatch-build ]
89-
if: always() && contains(github.event_name, 'workflow_dispatch') &&
90-
github.event.inputs.dispatch != 'regression' && github.repository_owner == 'axonweb3'
91-
runs-on: ubuntu-latest
92-
steps:
93-
- name: Generate axon-bot token
94-
id: generate_axon_bot_token
95-
uses: wow-actions/use-app-token@v2
96-
with:
97-
app_id: ${{ secrets.AXON_BOT_APP_ID }}
98-
private_key: ${{ secrets.AXON_BOT_PRIVATE_KEY }}
99-
- if: contains(join(needs.*.result, ';'), 'failure') || contains(join(needs.*.result, ';'), 'cancelled')
100-
run: exit 1
101-
- uses: actions/github-script@v6
102-
if: ${{ always() }}
103-
with:
104-
github-token: ${{ steps.generate_axon_bot_token.outputs.BOT_TOKEN }}
105-
script: |
106-
github.rest.repos.createCommitStatus({
107-
state: '${{ job.status }}',
108-
owner: context.repo.owner,
109-
repo: context.repo.repo,
110-
context: '${{ github.workflow }}',
111-
sha: '${{ needs.dispatch-build.outputs.output-sha }}',
112-
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
113-
})
114-
build:
115-
if: |
116-
(contains(fromJson('["dependabot[bot]" ]'), github.actor) && github.event_name == 'pull_request') ||
117-
(contains(github.event_name, 'push') && github.ref == 'refs/heads/main' )
118-
runs-on: ubuntu-latest
119-
steps:
120-
- uses: actions/checkout@v4
12142
- uses: lyricwulf/abc@v1
12243
with:
44+
# https://www.gnu.org/software/m4/
12345
linux: m4
12446

125-
- name: Use Node.js ${{ matrix.node-version }}
47+
# TODO: use Node.js 18
48+
- name: Use Node.js 16
12649
uses: actions/setup-node@v3
12750
with:
12851
node-version: "16"
129-
cache: "yarn"
130-
cache-dependency-path: "tests/e2e/yarn.lock"
52+
- name: Get yarn cache directory
53+
id: yarn-cache-dir
54+
run: echo "dir=$(yarn cache dir)" >> ${GITHUB_OUTPUT}
55+
- name: Get npm cache directory
56+
id: npm-cache-dir
57+
shell: bash
58+
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
59+
- name: Node Cache
60+
uses: actions/cache@v3
61+
id: npm-and-yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
62+
with:
63+
path: |
64+
${{ steps.yarn-cache-dir.outputs.dir }}
65+
${{ steps.npm-cache-dir.outputs.dir }}
66+
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}
67+
restore-keys: |
68+
${{ runner.os }}-node_modules-
13169
132-
- name: E2E Tests Linting
70+
- name: E2E Tests Linting in tests/e2e
13371
run: make e2e-test-lint
134-
135-
- name: E2E Tests
72+
- name: E2E Tests in tests/e2e
13673
run: make e2e-test-ci

.github/workflows/entry_workflow.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,6 @@ jobs:
7575
check_list=`${check_list}\n - Coverage Test`;
7676
}
7777
78-
// check E2E Tests exist or not
79-
const e2e_match = pr.data.body.includes("[x] E2E Tests");
80-
if (e2e_match) {
81-
const resp = await github.rest.actions.createWorkflowDispatch({
82-
owner: context.repo.owner,
83-
repo: context.repo.repo,
84-
workflow_id: "e2e_test.yml",
85-
ref: `main`,
86-
inputs: {
87-
dispatch: jsonDispatch,
88-
}
89-
});
90-
core.info(`${JSON.stringify(resp, null, 2)}`);
91-
check_list=`${check_list}\n - E2E Tests`;
92-
}
9378
// check OCT 1-5 And 12-15 exist or not
9479
const OCT_match = pr.data.body.includes("[x] OCT 1-5 And 12-15");
9580
if (OCT_match) {

.github/workflows/regression_testing.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,6 @@ jobs:
1717
workflow: Code Format
1818
token: ${{ secrets.GITHUB_TOKEN }}
1919

20-
invoke-E2E-test:
21-
if: github.repository_owner == 'axonweb3'
22-
runs-on: ubuntu-latest
23-
steps:
24-
- name: Invoke fmt test
25-
id: invoke-E2E-test
26-
uses: aurelien-baudet/workflow-dispatch@v2
27-
with:
28-
workflow: E2E Tests
29-
token: ${{ secrets.GITHUB_TOKEN }}
30-
inputs: '{ "dispatch": "regression" }'
31-
3220
invoke-v3-core-test:
3321
if: github.repository_owner == 'axonweb3'
3422
runs-on: ubuntu-latest
@@ -109,7 +97,7 @@ jobs:
10997

11098
output-result:
11199
runs-on: ubuntu-latest
112-
needs: [invoke-fmt-test,invoke-E2E-test,invoke-v3-core-test,invoke-web3-compatible-test,invoke-openzeppelin-test-1-5-and-12-15-test,invoke-OCT-6-10-test,invoke-OCT-11-test,invoke-OCT-16-19-test]
100+
needs: [invoke-fmt-test,invoke-v3-core-test,invoke-web3-compatible-test,invoke-openzeppelin-test-1-5-and-12-15-test,invoke-OCT-6-10-test,invoke-OCT-11-test,invoke-OCT-16-19-test]
113101
if: github.repository_owner == 'axonweb3' && always()
114102
steps:
115103
- name: send message

.github/workflows/web3_compatible.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ on:
44
merge_group:
55
workflow_dispatch:
66
inputs:
7+
# used by regression_testing.yml and entry_workflow.yml
78
dispatch:
89
type: string
9-
description: "Dispatch contains pr context that want to trigger web3-compatible test"
10+
description: "'regression' or the JSON of a PR's context"
1011
required: false
1112

1213
jobs:
@@ -60,12 +61,13 @@ jobs:
6061
~/.cargo/registry/cache/
6162
~/.cargo/git/db/
6263
target/
63-
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }}
64+
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
65+
restore-keys: |
66+
${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build
6467
- name: Build Axon in the development profile
6568
run: cargo build
6669
- name: Deploy Local Network of Axon
6770
run: |
68-
rm -rf ./devtools/chain/data
6971
./target/debug/axon init \
7072
--config devtools/chain/config.toml \
7173
--chain-spec devtools/chain/specs/single_node/chain-spec.toml \

tests/e2e/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
},
88
"dependencies": {
99
"@chainsafe/dappeteer": "^5",
10-
"@ethereumjs/tx": "^4.1.1",
1110
"@ethereumjs/common": "^3.1.1",
12-
"puppeteer": "^20.7.4",
11+
"@ethereumjs/tx": "^4.2.0",
12+
"puppeteer": "^21.2.1",
1313
"web3": "^1.8.2",
1414
"xhr2": "^0.2.1"
1515
},
1616
"devDependencies": {
1717
"@babel/plugin-transform-modules-commonjs": "^7.21.5",
18-
"eslint": "^8.38.0",
18+
"eslint": "^8.49.0",
1919
"eslint-config-airbnb": "^19.0.4",
2020
"eslint-plugin-import": "^2.27.5",
2121
"eslint-plugin-sonarjs": "^0.19.0",

0 commit comments

Comments
 (0)