This repository was archived by the owner on Sep 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 680
154 lines (144 loc) · 5.25 KB
/
Copy pathplaywright.yml
File metadata and controls
154 lines (144 loc) · 5.25 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Playwright E2E Tests
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
push:
branches:
- main
env:
LOG_LEVEL: ERROR
STATIC_DIR: ""
DATABASE_HOSTNAME: localhost
DATABASE_CREDENTIALS: dispatch:dispatch
DISPATCH_ENCRYPTION_KEY: NJHDWDJ3PbHT8h
DISPATCH_JWT_SECRET: foo
jobs:
# Job to determine if e2e tests should run
should-run-e2e:
runs-on: ubuntu-latest
outputs:
run-tests: ${{ steps.check.outputs.run-tests }}
steps:
- name: Check out Git repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if e2e tests should run
id: check
run: |
# Skip if draft PR
if [[ "${{ github.event.pull_request.draft }}" == "true" ]]; then
echo "Skipping e2e tests: Draft PR"
echo "run-tests=false" >> $GITHUB_OUTPUT
exit 0
fi
# Skip if only docs changed
if git diff --name-only origin/${{ github.base_ref }}..HEAD | grep -v -E '^(docs/|.*\.md$|.*\.mdx$|LICENSE|.*\.txt$)' | wc -l | grep -q '^0$'; then
echo "Skipping e2e tests: Documentation-only changes"
echo "run-tests=false" >> $GITHUB_OUTPUT
exit 0
fi
# Skip if only backend tests changed
if git diff --name-only origin/${{ github.base_ref }}..HEAD | grep -v -E '^(tests/(?!static/e2e)|.*test.*\.py$)' | wc -l | grep -q '^0$'; then
echo "Skipping e2e tests: Test-only changes"
echo "run-tests=false" >> $GITHUB_OUTPUT
exit 0
fi
# Skip if only backend-only changes (no frontend impact)
if git diff --name-only origin/${{ github.base_ref }}..HEAD | grep -v -E '^(src/dispatch/(?!static)|tests/(?!static)|\.github/workflows/(?!playwright)|requirements.*\.txt|setup\.py|pyproject\.toml|\.python-version|Dockerfile|docker/)' | wc -l | grep -q '^0$'; then
echo "Skipping e2e tests: Backend-only changes"
echo "run-tests=false" >> $GITHUB_OUTPUT
exit 0
fi
# Skip if labeled with skip-e2e
if echo '${{ toJson(github.event.pull_request.labels.*.name) }}' | grep -q 'skip-e2e'; then
echo "Skipping e2e tests: skip-e2e label found"
echo "run-tests=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "Running e2e tests: Frontend or critical changes detected"
echo "run-tests=true" >> $GITHUB_OUTPUT
end-to-end:
needs: should-run-e2e
if: needs.should-run-e2e.outputs.run-tests == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
services:
postgres:
image: postgres
env:
POSTGRES_USER: dispatch
POSTGRES_PASSWORD: dispatch
POSTGRES_DB: dispatch
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11.11
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
export DISPATCH_LIGHT_BUILD=1
uv venv
source .venv/bin/activate
uv pip install psycopg[binary]
uv pip install -e ".[dev]"
- name: Install npm dependencies
run: |
npm ci -D --prefix src/dispatch/static/dispatch
npm ci
- name: Install playwright browsers
run: npx playwright install --with-deps chromium
- name: Setup sample database
run: |
source .venv/bin/activate
dispatch database restore --dump-file data/dispatch-sample-data.dump --skip-check && dispatch database upgrade
- name: Run tests
run: |
source .venv/bin/activate
npx playwright test --project=chromium --shard=${{ matrix.shard }}/4
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report-shard-${{ matrix.shard }}
path: playwright-report/
retention-days: 30
# Summary job for required checks
e2e-tests-complete:
runs-on: ubuntu-latest
needs: [should-run-e2e, end-to-end]
if: always()
steps:
- name: Check e2e test results
run: |
if [[ "${{ needs.should-run-e2e.outputs.run-tests }}" == "false" ]]; then
echo "✅ E2E tests skipped (not needed for this change)"
exit 0
elif [[ "${{ needs.end-to-end.result }}" == "success" ]]; then
echo "✅ E2E tests passed"
exit 0
else
echo "❌ E2E tests failed"
exit 1
fi