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

test: Run cctp tests on approval #1890

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 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
86 changes: 78 additions & 8 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Build, Test

run-name: CI check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this added? now "Build, Test" is changed to "CI check"

https://github.com/OffchainLabs/arbitrum-token-bridge/actions/workflows/build-test.yml

on:
pull_request_review:
types:
- submitted
Comment on lines +4 to +6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

This is creating a lot of duplicate runs

My suggestion is to split the CCTP e2e to a separate file and only run that flow on pull_request_review

issue_comment:
types:
- created
pull_request:
branches: ["master"]
types:
Expand All @@ -14,8 +20,6 @@ on:

# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
concurrency:
# github.workflow: name of the workflow
# github.event.pull_request.number || github.ref: pull request number or branch name if not a pull request
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

Expand Down Expand Up @@ -142,25 +146,64 @@ jobs:
- name: Check formatting with ESLint
run: yarn lint

dismiss-previous-e2e-check:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have cancel-in-progress: true on L24, what is this specifically for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This serve something different. We don't want to remove it from the checks display when a PR is approved so we don't have duplicate

name: "Dismiss Previous E2E Check"
runs-on: ubuntu-latest
if: github.event.review.state == 'approved'
steps:
- name: Dismiss previous E2E check run
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { owner, repo } = context.repo;
const sha = context.payload.pull_request.head.sha;

const checkRuns = await github.rest.checks.listForRef({
owner,
repo,
ref: sha,
check_name: 'Test E2E'
});

for (const checkRun of checkRuns.data.check_runs) {
await github.rest.checks.update({
owner,
repo,
check_run_id: checkRun.id,
status: 'completed',
conclusion: 'cancelled',
output: {
title: 'Previous E2E Check Dismissed',
summary: 'This E2E check was dismissed due to PR approval. A new E2E check will be initiated.'
}
});
}

load-e2e-files:
name: "Load e2e files"
runs-on: ubuntu-latest
needs: [check-is-hotfix]
if: needs.check-is-hotfix.outputs.is_hotfix == 'false'
if: |
needs.check-is-hotfix.outputs.is_hotfix == 'false' &&
(github.event_name != 'pull_request_review' || github.event.review.state == 'approved')
outputs:
matrix: ${{ steps.set-matrix.outputs.e2eFiles }}
steps:
- name: Checkout
uses: actions/checkout@v4

- id: set-matrix
run: echo "e2eFiles=$(node .github/workflows/formatSpecfiles.js | jq . --compact-output)" >> $GITHUB_OUTPUT
run: echo "e2eFiles=$(node .github/workflows/formatSpecfiles.js ${{ (github.event.review.state == 'approved' || github.event.comment.body == '/cctp') && 'includeCctp' || '' }} | jq . --compact-output)" >> $GITHUB_OUTPUT

test-e2e:
name: "Test E2E ${{ (matrix.test.type == 'cctp' && 'CCTP') || (matrix.test.orbitTest == '1' && 'with L3') || '' }} - ${{ matrix.test.name }}"
runs-on: ubuntu-latest
needs: [build, check-files, check-is-hotfix, load-e2e-files]
if: needs.check-files.outputs.run_tests == 'true' && needs.check-is-hotfix.outputs.is_hotfix == 'false'
if: |
needs.check-files.outputs.run_tests == 'true' &&
needs.check-is-hotfix.outputs.is_hotfix == 'false' &&
(github.event_name != 'pull_request_review' || github.event.review.state == 'approved')
strategy:
fail-fast: false # If one test fails, let the other tests run
matrix:
Expand Down Expand Up @@ -256,15 +299,42 @@ jobs:
name: "Test E2E Success"
runs-on: ubuntu-latest
needs: [test-e2e]
if: always()
if: |
always() &&
(github.event_name != 'pull_request_review' || github.event.review.state == 'approved')
steps:
- name: Update E2E check run
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { owner, repo } = context.repo;
const sha = context.payload.pull_request ? context.payload.pull_request.head.sha : context.sha;

const conclusion = '${{ needs.test-e2e.result }}' === 'success' ? 'success' : 'failure';

await github.rest.checks.create({
owner,
repo,
head_sha: sha,
name: 'Test E2E',
status: 'completed',
conclusion: conclusion,
output: {
title: 'E2E Test Results',
summary: `The E2E tests have ${conclusion === 'success' ? 'passed' : 'failed'}.`
}
});

- name: E2E Succeeded
if: needs.test-e2e.result == 'success' || needs.test-e2e.result == 'skipped'
run: echo "nice"
run: echo "E2E tests passed"

- name: E2E Failed
if: needs.test-e2e.result != 'success' && needs.test-e2e.result != 'skipped'
run: exit 1


clean-up:
name: "Clean Up"
runs-on: ubuntu-latest
Expand Down
47 changes: 25 additions & 22 deletions .github/workflows/formatSpecfiles.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
#!/usr/bin/env node
const specFiles = require('../../packages/arb-token-bridge-ui/tests/e2e/specfiles.json')
const cctpFiles = require('../../packages/arb-token-bridge-ui/tests/e2e/cctp.json')
const specFiles = require("../../packages/arb-token-bridge-ui/tests/e2e/specfiles.json");
const cctpFiles = require("../../packages/arb-token-bridge-ui/tests/e2e/cctp.json");

// For each test in specFiles, add an orbit test
const tests = []
specFiles.forEach(spec => {
tests.push({
...spec,
type: 'regular',
orbitTest: '0',
})
tests.push({
...spec,
type: 'regular',
orbitTest: '1',
})
})
const tests = [];
specFiles.forEach((spec) => {
tests.push({
...spec,
type: "regular",
orbitTest: "0",
});
tests.push({
...spec,
type: "regular",
orbitTest: "1",
});
});

cctpFiles.forEach(spec => {
const includeCctp = Boolean(process.argv[2] === "includeCctp" || false);
if (includeCctp) {
cctpFiles.forEach((spec) => {
tests.push({
...spec,
type: 'cctp',
orbitTest: null,
})
})
...spec,
type: "cctp",
orbitTest: null,
});
});
}

console.log(JSON.stringify(tests))
console.log(JSON.stringify(tests));
Loading