diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 297edfeb95..bd5ec3b442 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -1,6 +1,12 @@ name: Build, Test - +run-name: CI check on: + pull_request_review: + types: + - submitted + issue_comment: + types: + - created pull_request: branches: ["master"] types: @@ -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 @@ -142,11 +146,47 @@ jobs: - name: Check formatting with ESLint run: yarn lint + dismiss-previous-e2e-check: + 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: 'Build, Test' + }); + + 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: @@ -154,13 +194,16 @@ jobs: 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: @@ -256,15 +299,40 @@ jobs: name: "Test E2E Success" runs-on: ubuntu-latest needs: [test-e2e] - if: always() + if: (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: 'Build, Test', + 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 diff --git a/.github/workflows/formatSpecfiles.js b/.github/workflows/formatSpecfiles.js index 70bd38a3f6..f6944ac1d5 100644 --- a/.github/workflows/formatSpecfiles.js +++ b/.github/workflows/formatSpecfiles.js @@ -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)) \ No newline at end of file +console.log(JSON.stringify(tests)); diff --git a/packages/arb-token-bridge-ui/synpress.cctp.config.ts b/packages/arb-token-bridge-ui/synpress.cctp.config.ts index 6b35dfbdd1..a54d6f1512 100644 --- a/packages/arb-token-bridge-ui/synpress.cctp.config.ts +++ b/packages/arb-token-bridge-ui/synpress.cctp.config.ts @@ -113,10 +113,10 @@ async function fundWallets() { } /** - * We need 0.0002 USDC per test (0.0001 for same address and 0.0001 for custom address) + * We need 0.00021 USDC per test (0.0001 for same address and 0.00011 for custom address) * And in the worst case, we run each tests 3 time */ - const usdcAmount = utils.parseUnits('0.0006', 6) + const usdcAmount = utils.parseUnits('0.00063', 6) const ethAmountSepolia = utils.parseEther('0.025') const ethAmountArbSepolia = utils.parseEther('0.006') const ethPromises: (() => Promise)[] = [] diff --git a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts index 661a66e6a0..5404ac83a8 100644 --- a/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts +++ b/packages/arb-token-bridge-ui/tests/e2e/specs/withdrawCctp.cy.ts @@ -88,17 +88,18 @@ describe('Withdraw USDC through CCTP', () => { }) it('should initiate withdrawing USDC to custom destination address through CCTP successfully', () => { + const customUSDCAmountToSend = 0.00011 cy.fillCustomDestinationAddress() cy.findMoveFundsButton().click() confirmAndApproveCctpWithdrawal() - cy.confirmSpending(USDCAmountToSend.toString()) + cy.confirmSpending(customUSDCAmountToSend.toString()) // eslint-disable-next-line cy.wait(10_000) cy.confirmMetamaskTransaction(undefined) const txData = { - amount: USDCAmountToSend, + amount: customUSDCAmountToSend, symbol: 'USDC' } cy.findTransactionInTransactionHistory({