Skip to content

Commit

Permalink
Add GitHub Actions tests to verify package exports
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Jun 19, 2023
1 parent 5cd7aa2 commit e36bc25
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,58 @@ jobs:
- name: Run verify task
run: ${{ matrix.task.run }}

package:
name: Export ${{ matrix.conditions }}, Node.js ${{ matrix.node-version }}
runs-on: ${{ github.event.inputs.runner || 'ubuntu-latest' }}
needs: [install, build]

# Skip when scheduled or run manually
if: ${{ !inputs.runner }}

strategy:
fail-fast: false

matrix:
node-version:
- 12.18 # Node.js 12.18 uses package exports with trailing slashes
- 12 # But Node.js 12.20+ uses package exports with subpath patterns
- 18

conditions:
- require
- import

exclude:
- conditions: import
node-version: 12.18

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Restore dependencies
uses: ./.github/workflows/actions/install-node

- name: Restore build
uses: ./.github/workflows/actions/build

- name: Change Node.js version
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Export ${{ matrix.conditions }}, Node.js ${{ matrix.node-version }}
env:
# Node.js conditions override from "require" to "import" etc
# https://nodejs.org/api/cli.html#-c-condition---conditionscondition
FLAGS: ${{ matrix.conditions != 'require' && format(' --conditions {0}', matrix.conditions) || '' }}

run: |
node --eval "console.log(require.resolve('govuk-frontend'))"${{ env.FLAGS }}
node --eval "console.log(require.resolve('govuk-frontend/package.json'))"${{ env.FLAGS }}
node --eval "console.log(require.resolve('govuk-frontend/dist/govuk/i18n.js'))"${{ env.FLAGS }}
node --eval "console.log(require.resolve('govuk-frontend/dist/govuk-esm/i18n.mjs'))"${{ env.FLAGS }}
regression:
name: Percy
needs: [install, build]
Expand Down

0 comments on commit e36bc25

Please sign in to comment.