From 7ee54706bb2f5a80d427a755a707280cf514c5f1 Mon Sep 17 00:00:00 2001 From: Andrew Hosgood Date: Thu, 21 Sep 2023 14:37:40 +0100 Subject: [PATCH] Fix workflow actions --- .github/actions/lint/action.yml | 24 ++- .github/actions/prototype-kit-test/action.yml | 160 +++++++++--------- .github/actions/tests/action.yml | 32 ++-- .github/workflows/npm-publish.yml | 11 +- 4 files changed, 110 insertions(+), 117 deletions(-) diff --git a/.github/actions/lint/action.yml b/.github/actions/lint/action.yml index 8e2b1544..f820ea83 100644 --- a/.github/actions/lint/action.yml +++ b/.github/actions/lint/action.yml @@ -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 diff --git a/.github/actions/prototype-kit-test/action.yml b/.github/actions/prototype-kit-test/action.yml index 309b0a7d..15dd14c7 100644 --- a/.github/actions/prototype-kit-test/action.yml +++ b/.github/actions/prototype-kit-test/action.yml @@ -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 diff --git a/.github/actions/tests/action.yml b/.github/actions/tests/action.yml index a27c4f0d..7a2ed895 100644 --- a/.github/actions/tests/action.yml +++ b/.github/actions/tests/action.yml @@ -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 diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 353425f8..3c9ff080 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -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 @@ -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 }}