-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (86 loc) · 2.76 KB
/
ci-e2e-playwright.yml
File metadata and controls
93 lines (86 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Reusable workflow for running Playwright E2E tests in a containerized
# environment with browsers pre-installed. Eliminates the ~60s browser
# install step by using Microsoft's official Playwright Docker images.
#
# Usage:
#
# jobs:
# e2e:
# uses: codeflash-ai/github-workflows/.github/workflows/ci-e2e-playwright.yml@main
# with:
# test-command: "uv run pytest tests/e2e/ --browser $BROWSER -v"
#
# The $BROWSER placeholder in test-command is replaced with the matrix
# browser value (chromium, firefox, or webkit) at runtime.
name: E2E (Playwright)
on:
workflow_call:
inputs:
playwright-version:
description: "Playwright version tag, e.g. v1.59.0 (defaults to latest)"
type: string
default: "v1.59.0"
base-image:
description: "Ubuntu base for the container image"
type: string
default: "noble"
browsers:
description: "JSON array of browsers to test"
type: string
default: '["chromium", "firefox", "webkit"]'
sync-command:
description: "Dependency install command"
type: string
default: "uv sync"
test-command:
description: "Pytest command template — use $BROWSER placeholder for browser name"
type: string
required: true
test-directory:
description: "Working directory for all commands"
type: string
default: "."
artifact-retention-days:
description: "How long to keep trace artifacts"
type: number
default: 7
fail-fast:
description: "Stop on first browser failure"
type: boolean
default: false
jobs:
e2e:
strategy:
fail-fast: ${{ inputs.fail-fast }}
matrix:
browser: ${{ fromJSON(inputs.browsers) }}
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright/python:${{ inputs.playwright-version }}-${{ inputs.base-image }}
options: --user 1001
permissions:
contents: read
env:
UV_LINK_MODE: copy
defaults:
run:
working-directory: ${{ inputs.test-directory }}
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v8.1.0
with:
enable-cache: true
- run: ${{ inputs.sync-command }}
- name: Run Playwright tests (${{ matrix.browser }})
shell: bash
run: |
BROWSER="${{ matrix.browser }}" && ${TEST_CMD/\$BROWSER/$BROWSER}
env:
TEST_CMD: ${{ inputs.test-command }}
- name: Upload traces
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-traces-${{ matrix.browser }}
path: ${{ inputs.test-directory }}/test-results/
retention-days: ${{ inputs.artifact-retention-days }}