Skip to content

Commit

Permalink
chore(CI): run E2E test for every commit
Browse files Browse the repository at this point in the history
With cache, `make e2e-test-ci` only takes only 7 minutes.
  • Loading branch information
Flouse committed Sep 18, 2023
1 parent d6377f2 commit 34c64fb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 96 deletions.
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>
70 changes: 9 additions & 61 deletions .github/workflows/e2e_test.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: E2E Tests

on:
# TODO: With cache, `make e2e-test-ci` only takes only 7 minutes.
push:
pull_request:
merge_group:
workflow_dispatch:
inputs:
# used by regression_testing.yml and entry_workflow.yml
dispatch:
type: string
description: "'regression' or the JSON of a PR's context"
required: false

# 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:
e2e-test:
Expand All @@ -21,39 +21,9 @@ jobs:
os: [ubuntu-22.04]
fail-fast: false
runs-on: ${{ matrix.os }}
env:
IS_DISPATCH: ${{ github.event_name == 'workflow_dispatch' }}
IS_REGRESSION: ${{ github.event.inputs.dispatch == 'regression' }}

# When the permissions key is used, all unspecified permissions are set to no access, with the
# exception of the metadata scope, which always gets read access.
# See https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
statuses: write

steps:
- name: Get the git ref of Axon
uses: actions/github-script@v6
id: axon_git_ref
with:
script: |
if (`${{ env.IS_DISPATCH }}` == 'true' && `${{ env.IS_REGRESSION }}` == 'false' && `${{ github.event.inputs.dispatch }}`) {
const dispatch = JSON.parse(`${{ github.event.inputs.dispatch }}`);
const prNum = dispatch.issue.number;
const { data: pullRequest } = await github.rest.pulls.get({
owner: dispatch.repo.owner,
repo: dispatch.repo.repo,
pull_number: dispatch.issue.number,
});
return pullRequest.head.sha;
}
return `${{ github.sha }}`;
result-encoding: string

- name: Checkout Axon ${{ steps.axon_git_ref.outputs.result}}
uses: actions/checkout@v4
with:
ref: ${{ steps.axon_git_ref.outputs.result}}
- uses: actions/checkout@v4

- name: Cache of Cargo
uses: actions/cache@v3
Expand All @@ -68,7 +38,6 @@ jobs:
restore-keys: |
${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo-build
${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo
# TODO: remove ${{ matrix.os }}-${{ runner.os }}-${{ runner.arch }}-cargo key
- uses: lyricwulf/abc@v1
with:
Expand Down Expand Up @@ -98,28 +67,7 @@ jobs:
restore-keys: |
${{ runner.os }}-node_modules-
# Only enable tmate while debugging
# - name: Setup tmate session
# # if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
# timeout-minutes: 30

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

# The `statuses: write` permission is required in this step.
- name: Update the commit Status
if: always() && env.IS_DISPATCH == 'true' && env.IS_REGRESSION == 'false'
uses: actions/github-script@v6
with:
script: |
github.rest.repos.createCommitStatus({
state: '${{ job.status }}',
owner: context.repo.owner,
repo: context.repo.repo,
context: '${{ github.workflow }}',
sha: '${{ steps.axon_git_ref.outputs.result}}',
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
})
16 changes: 0 additions & 16 deletions .github/workflows/entry_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +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

0 comments on commit 34c64fb

Please sign in to comment.