Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: refactor the e2e test workflow #1436

Merged
merged 7 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ See also:

**CI Switch**

- [ ] E2E Tests
- [ ] Web3 Compatible Tests
- [ ] OCT 1-5 And 12-15
- [ ] OCT 6-10
Expand All @@ -48,18 +47,15 @@ See also:

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

<!--
#### Deprecated CIs
- [ ] Chaos CI
| *Chaos CI* | Test the liveness and robustness of Axon under terrible network condition |
- [ ] Coverage Test
| *Coverage Test* | Get the unit test coverage report |
-->
</details>
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }}
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build

- name: Build Axon in the development profile
if: steps.axon-bin-cache.outputs.cache-hit != 'true'
Expand Down
167 changes: 52 additions & 115 deletions .github/workflows/e2e_test.yml
Original file line number Diff line number Diff line change
@@ -1,136 +1,73 @@
name: E2E Tests

on:
push:
branches:
- main
pull_request:
types: [ opened, synchronize, reopened ]
merge_group:
workflow_dispatch:
inputs:
dispatch:
type: string
description: "Dispatch contains pr context that want to trigger e2e test"
required: true

# 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-jobs/using-concurrency#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# only needs to test the group's latest commit
cancel-in-progress: true

jobs:
dispatch-build:
if: contains(github.event_name, 'workflow_dispatch')
runs-on: ubuntu-latest
outputs:
output-sha: ${{ steps.escape_multiple_lines_test_inputs.outputs.result }}
e2e-test:
strategy:
matrix:
# Supported GitHub-hosted runners and hardware resources
# see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
os: [ubuntu-22.04]
fail-fast: false
runs-on: ${{ matrix.os }}

steps:
- name: Generate axon-bot token
if: contains(github.event_name, 'workflow_dispatch') &&
github.repository_owner == 'axonweb3' && github.event.inputs.dispatch != 'regression'
id: generate_axon_bot_token
uses: wow-actions/use-app-token@v2
with:
app_id: ${{ secrets.AXON_BOT_APP_ID }}
private_key: ${{ secrets.AXON_BOT_PRIVATE_KEY }}
- name: Event is dispatch
if: contains(github.event_name, 'workflow_dispatch') &&
github.repository_owner == 'axonweb3' && github.event.inputs.dispatch != 'regression'
uses: actions/github-script@v6
id: get_sha
with:
github-token: ${{ steps.generate_axon_bot_token.outputs.BOT_TOKEN }}
script: |
const dispatch = JSON.parse(`${{ github.event.inputs.dispatch }}`);
const pr = (
await github.rest.pulls.get({
owner: dispatch.repo.owner,
repo: dispatch.repo.repo,
pull_number: dispatch.issue.number,
})
).data.head;
github.rest.repos.createCommitStatus({
state: 'pending',
owner: dispatch.repo.owner,
repo: dispatch.repo.repo,
context: '${{ github.workflow }}',
sha: pr.sha,
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
})
return pr.sha
- name: Escape multiple lines test inputs
if: contains(github.event_name, 'workflow_dispatch') &&
github.repository_owner == 'axonweb3' && github.event.inputs.dispatch != 'regression'
id: escape_multiple_lines_test_inputs
run: |
inputs=${{ steps.get_sha.outputs.result}}
inputs="${inputs//'%'/'%25'}"
inputs="${inputs//'\n'/'%0A'}"
inputs="${inputs//'\r'/'%0D'}"
echo "result=$inputs" >> $GITHUB_OUTPUT
- name: Git checkout
uses: actions/checkout@v4
with:
ref: ${{ steps.escape_multiple_lines_test_inputs.outputs.result || 'main' }}
- uses: lyricwulf/abc@v1
with:
linux: m4
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- name: Cache of Cargo
uses: actions/cache@v3
with:
node-version: "16"
cache: "yarn"
cache-dependency-path: "tests/e2e/yarn.lock"

- name: E2E Tests Linting
run: make e2e-test-lint
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build
${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo

- name: E2E Tests
run: make e2e-test-ci
finally:
name: Finally
needs: [ dispatch-build ]
if: always() && contains(github.event_name, 'workflow_dispatch') &&
github.event.inputs.dispatch != 'regression' && github.repository_owner == 'axonweb3'
runs-on: ubuntu-latest
steps:
- name: Generate axon-bot token
id: generate_axon_bot_token
uses: wow-actions/use-app-token@v2
with:
app_id: ${{ secrets.AXON_BOT_APP_ID }}
private_key: ${{ secrets.AXON_BOT_PRIVATE_KEY }}
- if: contains(join(needs.*.result, ';'), 'failure') || contains(join(needs.*.result, ';'), 'cancelled')
run: exit 1
- uses: actions/github-script@v6
if: ${{ always() }}
with:
github-token: ${{ steps.generate_axon_bot_token.outputs.BOT_TOKEN }}
script: |
github.rest.repos.createCommitStatus({
state: '${{ job.status }}',
owner: context.repo.owner,
repo: context.repo.repo,
context: '${{ github.workflow }}',
sha: '${{ needs.dispatch-build.outputs.output-sha }}',
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
})
build:
if: |
(contains(fromJson('["dependabot[bot]" ]'), github.actor) && github.event_name == 'pull_request') ||
(contains(github.event_name, 'push') && github.ref == 'refs/heads/main' )
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: lyricwulf/abc@v1
with:
# https://www.gnu.org/software/m4/
linux: m4

- name: Use Node.js ${{ matrix.node-version }}
# TODO: use Node.js 18
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: "16"
cache: "yarn"
cache-dependency-path: "tests/e2e/yarn.lock"
- name: Get yarn cache directory
id: yarn-cache-dir
run: echo "dir=$(yarn cache dir)" >> ${GITHUB_OUTPUT}
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- name: Node Cache
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.yarn-cache-dir.outputs.dir }}
${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node_modules-

- name: E2E Tests Linting
- name: E2E Tests Linting in tests/e2e
run: make e2e-test-lint

- name: E2E Tests
- name: E2E Tests in tests/e2e
run: make e2e-test-ci
15 changes: 0 additions & 15 deletions .github/workflows/entry_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,6 @@ jobs:
check_list=`${check_list}\n - Coverage Test`;
}

// check E2E Tests exist or not
const e2e_match = pr.data.body.includes("[x] E2E Tests");
if (e2e_match) {
const resp = await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "e2e_test.yml",
ref: `main`,
inputs: {
dispatch: jsonDispatch,
}
});
core.info(`${JSON.stringify(resp, null, 2)}`);
check_list=`${check_list}\n - E2E Tests`;
}
// check OCT 1-5 And 12-15 exist or not
const OCT_match = pr.data.body.includes("[x] OCT 1-5 And 12-15");
if (OCT_match) {
Expand Down
14 changes: 1 addition & 13 deletions .github/workflows/regression_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@ jobs:
workflow: Code Format
token: ${{ secrets.GITHUB_TOKEN }}

invoke-E2E-test:
if: github.repository_owner == 'axonweb3'
runs-on: ubuntu-latest
steps:
- name: Invoke fmt test
id: invoke-E2E-test
uses: aurelien-baudet/workflow-dispatch@v2
with:
workflow: E2E Tests
token: ${{ secrets.GITHUB_TOKEN }}
inputs: '{ "dispatch": "regression" }'

invoke-v3-core-test:
if: github.repository_owner == 'axonweb3'
runs-on: ubuntu-latest
Expand Down Expand Up @@ -109,7 +97,7 @@ jobs:

output-result:
runs-on: ubuntu-latest
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]
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]
if: github.repository_owner == 'axonweb3' && always()
steps:
- name: send message
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/web3_compatible.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ on:
merge_group:
workflow_dispatch:
inputs:
# used by regression_testing.yml and entry_workflow.yml
dispatch:
type: string
description: "Dispatch contains pr context that want to trigger web3-compatible test"
description: "'regression' or the JSON of a PR's context"
required: false

jobs:
Expand Down Expand Up @@ -60,12 +61,13 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }}
key: ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build
- name: Build Axon in the development profile
run: cargo build
- name: Deploy Local Network of Axon
run: |
rm -rf ./devtools/chain/data
./target/debug/axon init \
--config devtools/chain/config.toml \
--chain-spec devtools/chain/specs/single_node/chain-spec.toml \
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
},
"dependencies": {
"@chainsafe/dappeteer": "^5",
"@ethereumjs/tx": "^4.1.1",
"@ethereumjs/common": "^3.1.1",
"puppeteer": "^20.7.4",
"@ethereumjs/tx": "^4.2.0",
"puppeteer": "^21.2.1",
"web3": "^1.8.2",
"xhr2": "^0.2.1"
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.21.5",
"eslint": "^8.38.0",
"eslint": "^8.49.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-sonarjs": "^0.19.0",
Expand Down
Loading