Skip to content

Commit

Permalink
Fix workflow actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Sep 21, 2023
1 parent 3445e75 commit 7ee5470
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 117 deletions.
24 changes: 11 additions & 13 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ name: Lint
on:
workflow_call:

jobs:
tests:
name: Lint code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
runs:
using: "composite"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
160 changes: 79 additions & 81 deletions .github/actions/prototype-kit-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,84 +3,82 @@ name: GOV.UK prototype kit
on:
workflow_call:

jobs:
prototype-kit:
name: Test GOV.UK prototype kit integration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- name: Install dependencies
run: npm ci
- name: Build package
run: >
./tasks/build-package.sh &&
cd package &&
npm pack --pack-destination .
- name: Test package
run: node tasks/test-package.js || exit 1
- name: Create prototype
run: >
mkdir prototype &&
cd prototype &&
npx govuk-prototype-kit create
- name: Create usage data config
run: echo "{\"collectUsageData\":false}" > prototype/usage-data-config.json
- name: Install package
run: >
cd prototype &&
npm install ../package/nationalarchives-frontend-$(node -p "require('../package.json').version").tgz
- name: Add imports to template
run: >
echo -e "{% from \"nationalarchives/components/breadcrumbs/macro.njk\" import tnaBreadcrumbs %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/button/macro.njk\" import tnaButton %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/card/macro.njk\" import tnaCard %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/cookie-banner/macro.njk\" import tnaCookieBanner %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/filters/macro.njk\" import tnaFilters %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/footer/macro.njk\" import tnaFooter %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/gallery/macro.njk\" import tnaGallery %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/grid/macro.njk\" import tnaGrid %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/header/macro.njk\" import tnaHeader %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/hero/macro.njk\" import tnaHero %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/index-grid/macro.njk\" import tnaIndexGrid %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/message/macro.njk\" import tnaMessage %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/phase-banner/macro.njk\" import tnaPhaseBanner %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/picture/macro.njk\" import tnaPicture %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/profile/macro.njk\" import tnaProfile %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/sensitive-image/macro.njk\" import tnaSensitiveImage %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/skip-link/macro.njk\" import tnaSkipLink %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/tabs/macro.njk\" import tnaTabs %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html
- name: Add components to template
run: >
echo "\n{% block bodyEnd %}" >> prototype/app/views/index.html &&
echo "{{ tnaBreadcrumbs({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaButton({text:\"I am a button\",url:\"#\"}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaCard({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaCookieBanner({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaFilters({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaFooter({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaGallery({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaGrid({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaHeader({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaHero({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaIndexGrid({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaMessage({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaPhaseBanner({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaPicture({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaProfile({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaSensitiveImage({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaSkipLink({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaTabs({}) }}" >> prototype/app/views/index.html &&
echo "{% endblock %}" >> prototype/app/views/index.html
- name: Run prototype
run: >
cd prototype &&
npm run dev &
- uses: nev7n/wait_for_response@v1
with:
url: "http://localhost:3000"
responseCode: 200
timeout: 30000
interval: 500
runs:
using: "composite"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- name: Install dependencies
run: npm ci
- name: Build package
run: >
./tasks/build-package.sh &&
cd package &&
npm pack --pack-destination .
- name: Test package
run: node tasks/test-package.js || exit 1
- name: Create prototype
run: >
mkdir prototype &&
cd prototype &&
npx govuk-prototype-kit create
- name: Create usage data config
run: echo "{\"collectUsageData\":false}" > prototype/usage-data-config.json
- name: Install package
run: >
cd prototype &&
npm install ../package/nationalarchives-frontend-$(node -p "require('../package.json').version").tgz
- name: Add imports to template
run: >
echo -e "{% from \"nationalarchives/components/breadcrumbs/macro.njk\" import tnaBreadcrumbs %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/button/macro.njk\" import tnaButton %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/card/macro.njk\" import tnaCard %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/cookie-banner/macro.njk\" import tnaCookieBanner %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/filters/macro.njk\" import tnaFilters %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/footer/macro.njk\" import tnaFooter %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/gallery/macro.njk\" import tnaGallery %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/grid/macro.njk\" import tnaGrid %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/header/macro.njk\" import tnaHeader %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/hero/macro.njk\" import tnaHero %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/index-grid/macro.njk\" import tnaIndexGrid %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/message/macro.njk\" import tnaMessage %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/phase-banner/macro.njk\" import tnaPhaseBanner %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/picture/macro.njk\" import tnaPicture %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/profile/macro.njk\" import tnaProfile %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/sensitive-image/macro.njk\" import tnaSensitiveImage %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/skip-link/macro.njk\" import tnaSkipLink %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html &&
echo -e "{% from \"nationalarchives/components/tabs/macro.njk\" import tnaTabs %}\n$(cat prototype/app/views/index.html)" > prototype/app/views/index.html
- name: Add components to template
run: >
echo "\n{% block bodyEnd %}" >> prototype/app/views/index.html &&
echo "{{ tnaBreadcrumbs({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaButton({text:\"I am a button\",url:\"#\"}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaCard({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaCookieBanner({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaFilters({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaFooter({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaGallery({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaGrid({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaHeader({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaHero({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaIndexGrid({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaMessage({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaPhaseBanner({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaPicture({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaProfile({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaSensitiveImage({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaSkipLink({}) }}" >> prototype/app/views/index.html &&
echo "{{ tnaTabs({}) }}" >> prototype/app/views/index.html &&
echo "{% endblock %}" >> prototype/app/views/index.html
- name: Run prototype
run: >
cd prototype &&
npm run dev &
- uses: nev7n/wait_for_response@v1
with:
url: "http://localhost:3000"
responseCode: 200
timeout: 30000
interval: 500
32 changes: 15 additions & 17 deletions .github/actions/tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@ name: Tests
on:
workflow_call:

jobs:
tests:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- name: Install dependencies
run: npm ci
- name: Build Storybook
run: npm run build
- name: Start Storybook
run: npm start &
- name: Run tests
run: npm run test
runs:
using: "composite"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- name: Install dependencies
run: npm ci
- name: Build Storybook
run: npm run build
- name: Start Storybook
run: npm start &
- name: Run tests
run: npm run test
11 changes: 5 additions & 6 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/lint

tests:
runs-on: ubuntu-latest
needs:
- lint
- check
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/tests
Expand All @@ -38,17 +38,16 @@ jobs:
runs-on: ubuntu-latest
needs:
- check
- lint
- tests
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/prototype-kit-test

publish-npm:
name: Build package and publish to npm
runs-on: ubuntu-latest
needs:
- check
- lint
- tests
- prototype-kit
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down

0 comments on commit 7ee5470

Please sign in to comment.