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: move out build run #1926

Merged
merged 23 commits into from
Oct 22, 2024
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
12 changes: 0 additions & 12 deletions .github/actions/build-artifacts/cache/action.yml

This file was deleted.

13 changes: 0 additions & 13 deletions .github/actions/build-artifacts/restore/action.yml

This file was deleted.

13 changes: 13 additions & 0 deletions .github/actions/restore-build-artifacts/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Restore build artifacts
description: Restore build artifacts

runs:
using: composite
steps:
- name: Restore build artifacts
uses: actions/cache/restore@v4
with:
path: |
./packages/arb-token-bridge-ui/build
key: build-artifacts-${{ github.run_id }}
fail-on-cache-miss: true
48 changes: 48 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Cache build artifacts

on:
workflow_call:
Copy link
Member Author

Choose a reason for hiding this comment

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

this is a reusable workflow, not a composite workflow

https://docs.github.com/en/actions/sharing-automations/reusing-workflows


env:
NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }}
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID }}
THE_GRAPH_NETWORK_API_KEY: ${{ secrets.THE_GRAPH_NETWORK_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
check-build-cache:
name: Check cache for build artifacts
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check cache for build artifacts
id: cache
uses: actions/cache/restore@v4
with:
path: |
./packages/arb-token-bridge-ui/build
key: build-artifacts-${{ github.run_id }}
Comment on lines +20 to +26
Copy link
Member Author

Choose a reason for hiding this comment

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

we try to find it from cache first, and if it's not there, then we run build, otherwise just use the cache

this is similar to the approach we use for node modules in our actions repo


- name: Install node_modules
if: steps.cache.outputs.cache-hit != 'true'
uses: OffchainLabs/actions/node-modules/install@main

- name: Build
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
run: yarn build
env:
NEXT_PUBLIC_IS_E2E_TEST: true
NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }}
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID }}
THE_GRAPH_NETWORK_API_KEY: ${{ secrets.THE_GRAPH_NETWORK_API_KEY }}

- name: Cache build artifacts
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
./packages/arb-token-bridge-ui/build
key: build-artifacts-${{ github.run_id }}
9 changes: 7 additions & 2 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ jobs:
- id: set-matrix
run: echo "e2eFiles=$(node .github/workflows/formatSpecfiles.js ${{ inputs.test_type }} | jq . --compact-output)" >> $GITHUB_OUTPUT

build:
name: 'Build'
uses: ./.github/workflows/build.yml
secrets: inherit
Comment on lines +30 to +33
Copy link
Member Author

Choose a reason for hiding this comment

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

moved into here

and now the build won't be run twice ever on the same run


test-e2e:
name: "${{ matrix.test.name }}${{ matrix.test.type == 'orbit-eth' && ' with L3' || matrix.test.type == 'orbit-custom' && ' with custom fee token' || ''}}"
needs: [load-e2e-files]
needs: [build, load-e2e-files]
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down Expand Up @@ -69,7 +74,7 @@ jobs:
uses: OffchainLabs/actions/node-modules/install@main

- name: Restore build artifacts
uses: ./.github/actions/build-artifacts/restore
uses: ./.github/actions/restore-build-artifacts

- name: Install cypress
run: yarn cypress install
Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/run-cctp-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,8 @@ env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:
name: "Build"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main

- name: Build
run: yarn build
env:
NEXT_PUBLIC_IS_E2E_TEST: true
NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }}
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID }}
THE_GRAPH_NETWORK_API_KEY: ${{ secrets.THE_GRAPH_NETWORK_API_KEY }}

- name: Cache build artifacts
uses: ./.github/actions/build-artifacts/cache

cctp-e2e-tests:
name: "CCTP E2E Tests"
needs: [build]
uses: ./.github/workflows/e2e-tests.yml
with:
test_type: 'cctp'
Expand Down
30 changes: 6 additions & 24 deletions .github/workflows/build-test.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build, Test
name: Test

on:
pull_request:
Expand Down Expand Up @@ -35,26 +35,10 @@ jobs:
id: check-files

build:
name: "Build"
runs-on: ubuntu-latest
if: needs.check-files.outputs.run_tests == 'true' && ${{ !contains(github.event.pull_request.title, 'hotfix') }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install node_modules
uses: OffchainLabs/actions/node-modules/install@main

- name: Build
run: yarn build
env:
NEXT_PUBLIC_IS_E2E_TEST: true
NEXT_PUBLIC_INFURA_KEY: ${{ secrets.NEXT_PUBLIC_INFURA_KEY }}
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID }}
THE_GRAPH_NETWORK_API_KEY: ${{ secrets.THE_GRAPH_NETWORK_API_KEY }}

- name: Cache build artifacts
uses: ./.github/actions/build-artifacts/cache
name: 'Build'
needs: [check-files]
uses: ./.github/workflows/build.yml
secrets: inherit

test-ui:
name: "Test UI"
Expand All @@ -69,15 +53,14 @@ jobs:
uses: OffchainLabs/actions/node-modules/install@main

- name: Restore build artifacts
uses: ./.github/actions/build-artifacts/restore
uses: ./.github/actions/restore-build-artifacts

- name: Start UI and Test
run: yarn start-server-and-test 'start' http://127.0.0.1:3000 'yarn test:ci'

audit:
name: "Audit"
runs-on: ubuntu-latest
needs: build
Copy link
Member Author

Choose a reason for hiding this comment

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

it never needed the build files

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -91,7 +74,6 @@ jobs:
check-formatting:
name: "Check Formatting"
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down