Fix cache? #13
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: Run tests | |
concurrency: | |
group: ${{github.ref}}/${{github.workflow}} | |
cancel-in-progress: true | |
on: | |
push: | |
branches: | |
- "*" | |
pull_request: | |
branches: | |
- "*" | |
workflow_call: | |
inputs: | |
update-snapshots: | |
description: "Update snapshots?" | |
type: boolean | |
workflow_dispatch: | |
inputs: | |
update-snapshots: | |
description: "Update snapshots?" | |
type: boolean | |
permissions: | |
actions: read | |
contents: write | |
env: | |
BROWSERCAT_API_KEY: ${{secrets.BROWSERCAT_API_KEY}} | |
jobs: | |
run-tests: | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up PNPM | |
uses: pnpm/action-setup@v2 | |
with: | |
version: latest | |
- name: Set up Node | |
uses: actions/setup-node@v3 | |
with: | |
cache: pnpm | |
node-version-file: .nvmrc | |
check-latest: true | |
- name: Install deps | |
run: | | |
pnpm install --frozen-lockfile | |
- name: Set up cache | |
id: cache | |
uses: actions/cache@v4 | |
with: | |
key: cache-${{github.repository}}-${{github.ref}} | |
path: | | |
.test/**/* | |
- name: Initialize snapshots | |
if: ${{steps.cache.outputs.cache-hit != 'true' || inputs.update-snapshots == 'true'}} | |
run: | | |
pnpm run test:bcat --update-snapshots | |
- name: Test | |
id: test | |
continue-on-error: true | |
run: | | |
pnpm run test:bcat | |
- name: Upload test report | |
id: report | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: playwright-report | |
path: .test/spec/results/ | |
retention-days: 30 | |
overwrite: true | |
- name: Update snapshots? | |
if: ${{steps.test.outcome == 'failure'}} | |
uses: trstringer/manual-approval@v1 | |
with: | |
secret: ${{github.TOKEN}} | |
minimum-approvals: 1 | |
exclude-workflow-initiator-as-approver: false | |
approvers: ${{github.actor}}},${{github.triggering_actor}} | |
issue-title: "Tests failed. Update snapshots?" | |
issue-body: | | |
The tests failed. | |
Check out the [test report](${{steps.report.outputs.artifact-url}}). | |
Should we update the snapshots and try again? | |
- name: Update snapshots! | |
if: ${{steps.test.outcome == 'failure'}} | |
uses: ./.github/workflows/run-tests.yml | |
with: | |
update-snapshots: true |