Merge branch 'main' of github.com:jbilcke-hf/clapper #65
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: E2E & Unit Tests | |
on: | |
push: | |
branches: [ main, master ] | |
pull_request: | |
branches: [ main, master ] | |
jobs: | |
test: | |
timeout-minutes: 60 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'npm' | |
# the day we use a monorepo we should do this: | |
# cache-dependency-path: subdir/package-lock.json | |
# see https://github.com/actions/setup-node#caching-global-packages-data | |
- name: Get installed Playwright version | |
id: playwright-version | |
run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package-lock.json').dependencies['@playwright/test'].version)")" >> $GITHUB_ENV | |
- name: Cache playwright binaries | |
uses: actions/cache@v4 | |
id: playwright-cache | |
with: | |
path: /home/runner/.cache/ms-playwright | |
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}-${{ inputs.browser }} | |
- name: Cache NextJS dependencies | |
uses: actions/cache@v4 | |
with: | |
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node | |
path: | | |
~/.npm | |
${{ github.workspace }}/.next/cache | |
# Generate a new cache whenever packages or source files change. | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | |
# If source files changed but packages didn't, rebuild from a prior cache. | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- | |
- name: Install dependencies (with optional dependencies) | |
run: npm ci --include=optional | |
- name: Install Playwright | |
run: npm install @playwright/test@${{ env.PLAYWRIGHT_VERSION }} | |
- name: Install Playwright Browsers | |
run: npx playwright install --with-deps ${{ inputs.browser }} | |
# disabled for now as we have caching issues: | |
#_if: steps.playwright-cache.outputs.cache-hit != 'true' | |
- name: Install system dependencies for WebKit | |
# Some WebKit dependencies seem to lay outside the cache and will need to be installed separately | |
# disabled for now as we have caching issues: | |
#_if: ${{ inputs.browser == 'webkit' && steps.playwright-cache.outputs.cache-hit == 'true' }} | |
run: npx playwright install-deps webkit | |
- name: Run build | |
run: npm run build:ci | |
- name: Run unit tests | |
run: npm run test:unit:ci | |
- name: Run E2E tests | |
run: npm run test:e2e | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: playwright-report | |
path: playwright-report/ | |
retention-days: 30 |