Skip to content

Commit

Permalink
ci: refactor OpenZeppelin tests and entry_workflow.yml (#1610)
Browse files Browse the repository at this point in the history
* chore(CI): fix the step of updating commit status

* chore: rm useless file - tests/e2e/docker-compose.yaml

* refactor(CI): only provide 1 checkbox for all OpenZeppelin tests

in the PR template

* chore(CI): remove pull_request event in v3_core_test
  • Loading branch information
Flouse authored Dec 1, 2023
1 parent 1092ca0 commit 6667c5d
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 189 deletions.
23 changes: 6 additions & 17 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,14 @@ See also:
**CI Switch**

- [ ] Web3 Compatible Tests
- [ ] OCT 1-5 And 12-15
- [ ] OCT 6-10
- [ ] OCT 11
- [ ] OCT 16-19
- [ ] OpenZeppelin tests
- [ ] v3 Core Tests

### **CI Description**

| CI Name | Description |
| ----------------------------------------- | ------------------------------------------------------------------------- |
| *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 |
-->
| CI Name | Description |
| ---------------------- | ------------------------------------------------------------------------------------------------------- |
| *Web3 Compatible Test* | Test the Web3 compatibility of Axon |
| *v3 Core Test* | Run the compatibility tests provided by Uniswap V3 |
| *OpenZeppelin tests* | Run the compatibility tests provided by OpenZeppelin, including OCT 1-5 \| 6-10 \| 11 \| 12-15 \| 16-19 |
</details>
138 changes: 35 additions & 103 deletions .github/workflows/entry_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,124 +48,56 @@ jobs:
.replace(/\\t/g, "\\\\t");
// get pr comments body,not issue comments body
const pr =
await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
let check_list=`
let check_list = `
\### CI test list:
`;
// check Coverage Test exist or not
const coverage_match = pr.data.body.includes("[x] Coverage Test");
if (coverage_match) {
const resp = await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "coverage.yml",
ref: `main`,
inputs: {
dispatch: jsonDispatch,
}
const dispatchWorkflow = async (workflowId) => {
const resp = await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: workflowId,
ref: `main`,
inputs: {
dispatch: jsonDispatch,
}
});
core.info(`${JSON.stringify(resp, null, 2)}`);
check_list=`${check_list}\n - Coverage Test`;
}
check_list = `${check_list}\n - ${workflowId}`;
};
// check OCT 1-5 And 12-15 exist or not
const OCT_match = pr.data.body.includes("[x] OCT 1-5 And 12-15");
// check if OpenZeppelin tests is required
const OCT_match = pr.data.body.includes("[x] OpenZeppelin tests");
if (OCT_match) {
const resp = await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "openzeppelin_test_1_5_and_12_15.yml",
ref: `main`,
inputs: {
dispatch: jsonDispatch,
}
});
core.info(`${JSON.stringify(resp, null, 2)}`);
check_list=`${check_list}\n - OCT 1-5 And 12-15`;
}
// check OCT 6-10 exist or not
const OCT_6_match = pr.data.body.includes("[x] OCT 6-10");
if (OCT_6_match) {
const resp = await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "openzeppelin_test_6_10.yml",
ref: `main`,
inputs: {
dispatch: jsonDispatch,
}
});
core.info(`${JSON.stringify(resp, null, 2)}`);
check_list=`${check_list}\n - OCT 6-10`;
}
// check OCT 11 exist or not
const OCT_11_match = pr.data.body.includes("[x] OCT 11");
if (OCT_11_match) {
const resp = await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "openzeppelin_test_11.yml",
ref: `main`,
inputs: {
dispatch: jsonDispatch,
}
});
core.info(`${JSON.stringify(resp, null, 2)}`);
check_list=`${check_list}\n - OCT 11`;
}
// check OCT 16-19 exist or not
const OCT_16_match = pr.data.body.includes("[x] OCT 16-19");
if (OCT_16_match) {
const resp = await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "openzeppelin_test_16_19.yml",
ref: `main`,
inputs: {
dispatch: jsonDispatch,
}
});
core.info(`${JSON.stringify(resp, null, 2)}`);
check_list=`${check_list}\n - OCT 16-19`;
}
const workflowIds = [
"openzeppelin_test_1_5_and_12_15.yml",
"openzeppelin_test_6_10.yml",
"openzeppelin_test_11.yml",
"openzeppelin_test_16_19.yml",
];
await Promise.all(workflowIds.map(dispatchWorkflow));
}
// check v3 Core Tests exist or not
const v3_match = pr.data.body.includes("[x] v3 Core Tests");
if (v3_match) {
const resp = await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "v3_core_test.yml",
ref: `main`,
inputs: {
dispatch: jsonDispatch,
}
});
core.info(`${JSON.stringify(resp, null, 2)}`);
check_list=`${check_list}\n - v3 Core Tests`;
}
await dispatchWorkflow("v3_core_test.yml");
}
// check Unit Tests exist or not
const web3_match = pr.data.body.includes("[x] Web3 Compatible Tests");
if (web3_match) {
const resp = await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "web3_compatible.yml",
ref: `main`,
inputs: {
dispatch: jsonDispatch,
}
});
core.info(`${JSON.stringify(resp, null, 2)}`);
check_list=`${check_list}\n - Web3 Compatible Tests`;
};
return check_list
await dispatchWorkflow("web3_compatible.yml");
};
return check_list
- name: Escape check list
id: escape_multiple_lines_test_inputs
Expand Down
37 changes: 28 additions & 9 deletions .github/workflows/openzeppelin_test_11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ jobs:
return `${{ github.sha }}`;
result-encoding: string

# The `statuses: write` permission is required in this step.
- name: Update the commit Status
if: always()
uses: actions/github-script@v7
with:
script: |
if (`${{ env.IS_DISPATCH }}` == 'true' && `${{ env.IS_REGRESSION }}` == 'false') {
github.rest.repos.createCommitStatus({
state: 'pending',
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 }}'
});
}
- name: Checkout Axon commit ${{ steps.axon_git_ref.outputs.result}}
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -164,15 +181,17 @@ jobs:

# The `statuses: write` permission is required in this step.
- name: Update the commit Status
if: always() && env.IS_DISPATCH == 'true' && env.IS_REGRESSION == 'false'
if: always()
uses: actions/github-script@v7
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 }}'
})
if (`${{ env.IS_DISPATCH }}` == 'true' && `${{ env.IS_REGRESSION }}` == 'false') {
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 }}'
});
}
37 changes: 28 additions & 9 deletions .github/workflows/openzeppelin_test_16_19.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ jobs:
return `${{ github.sha }}`;
result-encoding: string

# The `statuses: write` permission is required in this step.
- name: Update the commit Status
if: always()
uses: actions/github-script@v7
with:
script: |
if (`${{ env.IS_DISPATCH }}` == 'true' && `${{ env.IS_REGRESSION }}` == 'false') {
github.rest.repos.createCommitStatus({
state: 'pending',
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 }}'
});
}
- name: Checkout Axon commit ${{ steps.axon_git_ref.outputs.result}}
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -175,15 +192,17 @@ jobs:

# The `statuses: write` permission is required in this step.
- name: Update the commit Status
if: always() && env.IS_DISPATCH == 'true' && env.IS_REGRESSION == 'false'
if: always()
uses: actions/github-script@v7
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 }}'
})
if (`${{ env.IS_DISPATCH }}` == 'true' && `${{ env.IS_REGRESSION }}` == 'false') {
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 }}'
});
}
37 changes: 28 additions & 9 deletions .github/workflows/openzeppelin_test_1_5_and_12_15.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ jobs:
return `${{ github.sha }}`;
result-encoding: string

# The `statuses: write` permission is required in this step.
- name: Update the commit Status
if: always()
uses: actions/github-script@v7
with:
script: |
if (`${{ env.IS_DISPATCH }}` == 'true' && `${{ env.IS_REGRESSION }}` == 'false') {
github.rest.repos.createCommitStatus({
state: 'pending',
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 }}'
});
}
- name: Checkout Axon commit ${{ steps.axon_git_ref.outputs.result}}
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -205,15 +222,17 @@ jobs:

# The `statuses: write` permission is required in this step.
- name: Update the commit Status
if: always() && env.IS_DISPATCH == 'true' && env.IS_REGRESSION == 'false'
if: always()
uses: actions/github-script@v7
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 }}'
})
if (`${{ env.IS_DISPATCH }}` == 'true' && `${{ env.IS_REGRESSION }}` == 'false') {
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 }}'
});
}
37 changes: 28 additions & 9 deletions .github/workflows/openzeppelin_test_6_10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ jobs:
return `${{ github.sha }}`;
result-encoding: string

# The `statuses: write` permission is required in this step.
- name: Update the commit Status
if: always()
uses: actions/github-script@v7
with:
script: |
if (`${{ env.IS_DISPATCH }}` == 'true' && `${{ env.IS_REGRESSION }}` == 'false') {
github.rest.repos.createCommitStatus({
state: 'pending',
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 }}'
});
}
- name: Checkout Axon commit ${{ steps.axon_git_ref.outputs.result}}
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -181,15 +198,17 @@ jobs:

# The `statuses: write` permission is required in this step.
- name: Update the commit Status
if: always() && env.IS_DISPATCH == 'true' && env.IS_REGRESSION == 'false'
if: always()
uses: actions/github-script@v7
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 }}'
})
if (`${{ env.IS_DISPATCH }}` == 'true' && `${{ env.IS_REGRESSION }}` == 'false') {
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 }}'
});
}
Loading

0 comments on commit 6667c5d

Please sign in to comment.