Skip to content

Commit

Permalink
test, playwright - adapt smoke test workflow for better playwright tests
Browse files Browse the repository at this point in the history
- Externalize a custom action to simplify workflow
- Upload the whole output folder as artefact
- Add a new input to update snapshot in cache before running tests
  • Loading branch information
cderv committed Sep 30, 2024
1 parent d983298 commit cedf9c5
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 13 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/actions/setup-playwright-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: "Setup playwright tests"
description: "Install Playwright, and restore snapshot cache or update snapshots"
inputs:
playwright-tests-path:
description: "Path to playwright tests"
required: true
default: "./tests/integration/playwright"
playwright-snapshots-path:
description: "Path to playwright snapshot path"
required: true
default: "./tests/integration/playwright/.test/spec/snaps"
update-snapshots:
description: "Update Playwright Snapshots?"
type: boolean
required: false
default: false

runs:
using: "composite"
steps:
- name: Install node if necessary
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install tests dependencies
run: yarn
working-directory: ${{ inputs.playwright-tests-path }}
shell: bash

- name: Install Playwright Browsers
run: npx playwright install --with-deps
working-directory: ${{ inputs.playwright-tests-path }}
shell: bash

- name: Set up cache for snapshot playwright tests
id: cache-playwright
uses: actions/cache@v4
with:
key: cache/${{github.repository}}/${{github.ref}}
restore-keys: cache/${{github.repository}}/refs/heads/main
path: ${{ inputs.playwright-snapshots-path }}

- name: Initialize snapshots
if: ${{steps.cache-playwright.outputs.cache-hit != 'true' || inputs.update-snapshots == 'true'}}
run: npx playwright test --update-snapshots
working-directory: ${{ inputs.playwright-tests-path }}
45 changes: 32 additions & 13 deletions .github/workflows/test-smokes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ on:
required: false
type: string
default: ""
update-playwright-snapshots:
description: "Update Playwright Snapshots?"
type: boolean
required: false
default: false
workflow_dispatch:
inputs:
buckets:
Expand All @@ -35,6 +40,11 @@ on:
required: false
type: string
default: ""
update-playwright-snapshots:
description: "Update Playwright Snapshots?"
type: boolean
required: false
default: false
schedule:
- cron: "0 6 * * *"

Expand All @@ -57,6 +67,17 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Is this is a run with Playwright Tests ?
id: is-playwright
# Either when running all tests (no buckets) or if we are running the playwright tests in the current bucket
# and skip on windows for now
if: >-
runner.os !='Windows' &&
(format('{0}', inputs.buckets) == '' || contains(format('{0}', inputs.buckets), 'integration/playwright-tests.test.ts'))
run: |
echo "::notice title=Playwright tests::This workflow run is running the playwright tests."
echo "PLAYWRIGHTRUN=true" >> $GITHUB_OUTPUT
- name: Fix temp dir to use runner one (windows)
if: runner.os == 'Windows'
run: |
Expand All @@ -78,16 +99,13 @@ jobs:
with:
node-version: 20

- name: Install node dependencies
if: ${{ runner.os != 'Windows' || github.event_name == 'schedule' }}
run: yarn
working-directory: ./tests/integration/playwright
shell: bash

- name: Install Playwright Browsers
if: ${{ runner.os != 'Windows' || github.event_name == 'schedule' }}
run: npx playwright install --with-deps
working-directory: ./tests/integration/playwright
- name: Setup playwright tests
if: ${{ steps.is-playwright.outputs.PLAYWRIGHTRUN == 'true' }}
uses: ./.github/workflows/actions/setup-playwright-tests
with:
playwright-tests-path: "./tests/integration/playwright"
playwright-snapshots-path: "./tests/integration/playwright/.test/spec/snaps"
update-snapshots: ${{ inputs.update-playwright-snapshots }}

- name: Install MECA validator
if: ${{ runner.os != 'Windows' }}
Expand Down Expand Up @@ -292,8 +310,9 @@ jobs:

- uses: actions/upload-artifact@v4
# PLaywright test only runs on Linux for now
if: ${{ !cancelled() && runner.os != 'Windows' }}
if: steps.is-playwright.outputs.PLAYWRIGHTRUN && !cancelled()
with:
name: playwright-report
path: ./tests/integration/playwright/playwright-report/
retention-days: 30
path: ./tests/integration/playwright/.test/
retention-days: 15
overwrite: true

0 comments on commit cedf9c5

Please sign in to comment.