From 51a44a44ab2e6f087962654284e4d343d3e793d1 Mon Sep 17 00:00:00 2001 From: Owen Jones Date: Tue, 19 Nov 2024 17:09:45 +0000 Subject: [PATCH] WIP --- .github/workflows/actions/build/action.yml | 26 +++++++++++++++ .../workflows/actions/install-node/action.yml | 33 +++++++++++++++++++ .../workflows/actions/setup-node/action.yml | 19 +++++++++++ .github/workflows/check-external-links.yaml | 26 +++++++-------- .github/workflows/test.yaml | 29 +++------------- .gitignore | 2 +- 6 files changed, 96 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/actions/build/action.yml create mode 100644 .github/workflows/actions/install-node/action.yml create mode 100644 .github/workflows/actions/setup-node/action.yml diff --git a/.github/workflows/actions/build/action.yml b/.github/workflows/actions/build/action.yml new file mode 100644 index 0000000000..89f368dc57 --- /dev/null +++ b/.github/workflows/actions/build/action.yml @@ -0,0 +1,26 @@ +name: Install + +runs: + using: composite + + steps: + - name: Cache build + uses: actions/cache@v4.1.2 + id: build-cache + + with: + # Use faster GNU tar for all runners + enableCrossOsArchive: true + + # Restore build cache (unless commit SHA changes) + key: build-${{ runner.os }}-${{ github.sha }} + path: build + + - name: Build + id: build + + # Skip build when we’ve built this SHA before + if: steps.build-cache.outputs.cache-hit != 'true' + shell: bash + + run: npm run build diff --git a/.github/workflows/actions/install-node/action.yml b/.github/workflows/actions/install-node/action.yml new file mode 100644 index 0000000000..ab1602eea1 --- /dev/null +++ b/.github/workflows/actions/install-node/action.yml @@ -0,0 +1,33 @@ +name: Install dependencies + +runs: + using: composite + + steps: + - name: Cache dependencies + uses: actions/cache@v4.1.2 + id: npm-install-cache + + with: + # Use faster GNU tar for all runners + enableCrossOsArchive: true + + # Restore `node_modules` cache (unless packages change) + key: npm-install-${{ runner.os }}-${{ hashFiles('package-lock.json', '**/package.json') }} + path: node_modules + + - name: Setup Node.js + uses: ./.github/workflows/actions/setup-node + id: setup-node + + with: + # Restore global `~/.npm` cache (unless packages change) + use-cache: ${{ steps.npm-install-cache.outputs.cache-hit != 'true' }} + + - name: Install dependencies + id: install-node + + # Skip install when dependencies are cached + if: steps.npm-install-cache.outputs.cache-hit != 'true' + shell: bash + run: npm ci diff --git a/.github/workflows/actions/setup-node/action.yml b/.github/workflows/actions/setup-node/action.yml new file mode 100644 index 0000000000..8959fcbd8e --- /dev/null +++ b/.github/workflows/actions/setup-node/action.yml @@ -0,0 +1,19 @@ +name: Setup + +inputs: + use-cache: + description: Restore global `~/.npm` cache + default: 'true' + required: true + +runs: + using: composite + + steps: + - name: Setup Node.js + uses: actions/setup-node@v4.1.0 + id: setup-node + + with: + cache: ${{ inputs.use-cache == 'true' && 'npm' || '' }} + node-version-file: .nvmrc diff --git a/.github/workflows/check-external-links.yaml b/.github/workflows/check-external-links.yaml index a741e09f44..62f129afed 100644 --- a/.github/workflows/check-external-links.yaml +++ b/.github/workflows/check-external-links.yaml @@ -1,6 +1,14 @@ name: Check external links -on: workflow_dispatch +on: + pull_request: + + push: + branches: + - 'feature/**' + - 'v[0-9]' + + workflow_dispatch: jobs: check-links: @@ -11,21 +19,11 @@ jobs: - name: Checkout uses: actions/checkout@v4.2.1 - - name: Setup Node.js - uses: actions/setup-node@v4.0.4 - with: - cache: npm - check-latest: true - node-version-file: .nvmrc - - name: Install dependencies - run: npm ci + uses: ./.github/workflows/actions/install-node - - name: Restore build - uses: actions/cache/restore@v4.1.1 - with: - key: build-cache-${{ runner.os }}-${{ github.sha }} - path: build + - name: Build + uses: ./.github/workflows/actions/build - name: Check external broken links id: check-links diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f12901850a..b72863072e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -20,43 +20,24 @@ on: - windows-latest jobs: - build: - name: Build + install: + name: Install runs-on: ${{ github.event.inputs.runner || 'ubuntu-latest' }} steps: - name: Checkout code uses: actions/checkout@v4.2.2 - - name: Restore build - uses: actions/cache@v4.1.2 - id: build-cache - - with: - key: build-cache-${{ runner.os }}-${{ github.sha }} - path: build - - - name: Setup Node.js - uses: actions/setup-node@v4.1.0 - if: steps.build-cache.outputs.cache-hit != 'true' - - with: - cache: npm - check-latest: true - node-version-file: .nvmrc - - name: Install dependencies - if: steps.build-cache.outputs.cache-hit != 'true' - run: npm ci + uses: ./.github/workflows/actions/install-node - name: Build - if: steps.build-cache.outputs.cache-hit != 'true' - run: npm run build + uses: ./.github/workflows/actions/build test: name: ${{ matrix.task.description }} runs-on: ${{ github.event.inputs.runner || 'ubuntu-latest' }} - needs: [build] + needs: [install] strategy: fail-fast: false diff --git a/.gitignore b/.gitignore index d89b0598ad..1524596de6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -build/ +/build/ node_modules/ *.log .DS_Store