mirror of
https://github.com/fastapi/full-stack-fastapi-template.git
synced 2026-09-21 05:12:48 +00:00
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
140 lines
4.8 KiB
YAML
140 lines
4.8 KiB
YAML
name: Playwright Tests
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
workflow_dispatch:
|
|
inputs:
|
|
debug_enabled:
|
|
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
|
|
required: false
|
|
default: 'false'
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
changes:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
# Set job outputs to values from filter step
|
|
outputs:
|
|
changed: ${{ steps.filter.outputs.changed }}
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
fetch-depth: 2
|
|
persist-credentials: false
|
|
# For pull requests it's not necessary to checkout the code but for the main branch it is
|
|
- uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2
|
|
id: filter
|
|
with:
|
|
filters: |
|
|
changed:
|
|
- backend/**
|
|
- frontend/**
|
|
- .env
|
|
- compose*.yml
|
|
- .github/workflows/playwright.yml
|
|
|
|
test-playwright:
|
|
needs:
|
|
- changes
|
|
if: ${{ needs.changes.outputs.changed == 'true' }}
|
|
timeout-minutes: 15
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
shardIndex: [1, 2, 3, 4]
|
|
shardTotal: [4]
|
|
fail-fast: false
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
|
with:
|
|
bun-version: 1.3.12
|
|
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
with:
|
|
python-version-file: .python-version
|
|
- name: Setup tmate session
|
|
uses: mxschmitt/action-tmate@35b54afac29c97fb54faba5b513f8fbd1882f113 # v3.24
|
|
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
|
|
with:
|
|
limit-access-to-actor: true
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
|
|
with:
|
|
# Before upgrading uv version, make sure astral-sh/setup-uv knows its checksum.
|
|
# See: https://github.com/astral-sh/setup-uv/issues/851#issuecomment-4282017837
|
|
version: "0.11.18"
|
|
- run: uv sync
|
|
working-directory: backend
|
|
- run: bun ci
|
|
working-directory: frontend
|
|
- run: bash scripts/generate-client.sh
|
|
- run: docker compose build
|
|
- run: docker compose down -v --remove-orphans
|
|
- name: Run Playwright tests
|
|
run: docker compose run --rm playwright bunx playwright test --fail-on-flaky-tests --trace=retain-on-failure --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
|
|
- run: docker compose down -v --remove-orphans
|
|
- name: Upload blob report to GitHub Actions Artifacts
|
|
if: ${{ !cancelled() }}
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: blob-report-${{ matrix.shardIndex }}
|
|
path: frontend/blob-report
|
|
include-hidden-files: true
|
|
retention-days: 1
|
|
|
|
merge-playwright-reports:
|
|
needs:
|
|
- test-playwright
|
|
- changes
|
|
# Merge reports after playwright-tests, even if some shards have failed
|
|
if: ${{ !cancelled() && needs.changes.outputs.changed == 'true' }}
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
|
with:
|
|
bun-version: 1.3.12
|
|
- name: Install dependencies
|
|
run: bun ci
|
|
- name: Download blob reports from GitHub Actions Artifacts
|
|
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
with:
|
|
path: frontend/all-blob-reports
|
|
pattern: blob-report-*
|
|
merge-multiple: true
|
|
- name: Merge into HTML Report
|
|
run: bunx playwright merge-reports --reporter html ./all-blob-reports
|
|
working-directory: frontend
|
|
- name: Upload HTML report
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: html-report--attempt-${{ github.run_attempt }}
|
|
path: frontend/playwright-report
|
|
retention-days: 30
|
|
include-hidden-files: true
|
|
|
|
# https://github.com/marketplace/actions/alls-green#why
|
|
alls-green-playwright: # This job does nothing and is only used for the branch protection
|
|
if: always()
|
|
needs:
|
|
- test-playwright
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
steps:
|
|
- name: Decide whether the needed jobs succeeded or failed
|
|
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
|
|
with:
|
|
jobs: ${{ toJSON(needs) }}
|
|
allowed-skips: test-playwright
|