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 OpenZeppelin tests and entry_workflow.yml #1610

Merged
merged 4 commits into from
Dec 1, 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
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
Loading