Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
owenatgov committed Nov 19, 2024
1 parent 6025bc0 commit 88178a8
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 49 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Install

runs:
using: composite

steps:
- name: Cache build
uses: actions/[email protected]
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
33 changes: 33 additions & 0 deletions .github/workflows/actions/install-node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Install dependencies

runs:
using: composite

steps:
- name: Cache dependencies
uses: actions/[email protected]
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
19 changes: 19 additions & 0 deletions .github/workflows/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
id: setup-node

with:
cache: ${{ inputs.use-cache == 'true' && 'npm' || '' }}
node-version-file: .nvmrc
26 changes: 12 additions & 14 deletions .github/workflows/check-external-links.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -11,21 +19,11 @@ jobs:
- name: Checkout
uses: actions/[email protected]

- name: Setup Node.js
uses: actions/[email protected]
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/[email protected]
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
Expand Down
39 changes: 5 additions & 34 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,11 @@ jobs:
- name: Checkout code
uses: actions/[email protected]

- name: Restore build
uses: actions/[email protected]
id: build-cache

with:
key: build-cache-${{ runner.os }}-${{ github.sha }}
path: build

- name: Setup Node.js
uses: actions/[email protected]
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 }}
Expand Down Expand Up @@ -91,21 +72,11 @@ jobs:
- name: Checkout
uses: actions/[email protected]

- name: Setup Node.js
uses: actions/[email protected]
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/[email protected]
with:
key: build-cache-${{ runner.os }}-${{ github.sha }}
path: build
- name: Build
uses: ./.github/workflows/actions/build

- name: Run task
id: task
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build/
/build/
node_modules/
*.log
.DS_Store
Expand Down

0 comments on commit 88178a8

Please sign in to comment.