-
Notifications
You must be signed in to change notification settings - Fork 7
126 lines (120 loc) · 3.57 KB
/
Copy pathtest.yaml
File metadata and controls
126 lines (120 loc) · 3.57 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
name: Test package and web app
on:
push:
branches:
- master
pull_request:
jobs:
lint:
name: Pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.14"
- name: Set up uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
version: "0.12.5"
- name: Run pre-commit hooks
run: uvx pre-commit run --all-files
test:
strategy:
matrix:
python: ["3.10", "3.13"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python }}
- name: Set up uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
version: "0.12.5"
- name: Install dependencies
run: uv pip install --system nox[uv]
- name: Test with pytest
run: nox -db uv
- name: Upload Python coverage to Codecov
uses: codecov/codecov-action@v7
with:
use_oidc: true
flags: python
name: python-${{ matrix.python }}
web:
name: Web tests
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-python@v7
with:
python-version: "3.14"
- name: Set up uv
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
version: "0.12.5"
- uses: actions/setup-node@v6
with:
node-version: 22
- name: Install web test dependencies
run: npm install
- name: Run web unit tests with coverage
run: npm run test:web
- name: Upload web coverage to Codecov
uses: codecov/codecov-action@v7
with:
use_oidc: true
files: ./coverage/lcov.info
flags: web
name: web
fail_ci_if_error: true
- name: Build test web bundle from locked dependencies
run: |
uv build --wheel
wheel=$(echo dist/wenxian-*.whl)
python scripts/build_web_bundle.py "$wheel" test-web-bundle.tar.gz
bundle_bytes=$(stat -c%s test-web-bundle.tar.gz)
echo "Web bundle: $bundle_bytes bytes"
test "$bundle_bytes" -lt 1000000
- name: Install Chromium
run: npx playwright install --with-deps chromium
- name: Run browser end-to-end smoke test
env:
WENXIAN_WEB_BUNDLE_PATH: ${{ github.workspace }}/test-web-bundle.tar.gz
run: |
python3 -m http.server 8000 --directory docs >/tmp/wenxian-web.log 2>&1 &
server_pid=$!
trap 'kill "$server_pid"' EXIT
for _ in {1..20}; do
if curl --fail --silent http://127.0.0.1:8000/ >/dev/null; then
break
fi
sleep 0.25
done
npm run test:web:e2e
- name: Upload browser failure screenshot
if: failure()
uses: actions/upload-artifact@v7
with:
name: web-e2e-failure
path: web-e2e-failure.png
if-no-files-found: ignore
pass:
name: Pass testing
needs: [lint, test, web]
runs-on: ubuntu-latest
if: always()
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
permissions:
contents: read
id-token: write