-
Notifications
You must be signed in to change notification settings - Fork 1
143 lines (118 loc) · 3.73 KB
/
ci.yml
File metadata and controls
143 lines (118 loc) · 3.73 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
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
env:
_PAPERSCOUT_TESTING: "1"
SLACK_BOT_TOKEN: xoxb-ci-placeholder
SLACK_SIGNING_SECRET: ci-placeholder-secret
jobs:
lockfile:
name: Lockfile (uv)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.8.3"
- name: Verify uv.lock matches pyproject.toml
run: uv lock --check
lint:
name: Lint (pre-commit)
runs-on: ubuntu-latest
needs: lockfile
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.8.3"
- name: Install dependencies
run: uv sync --frozen --extra dev
- name: Cache pre-commit environments
uses: actions/cache@v5
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit
run: uv run pre-commit run --all-files
test:
name: Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
needs: lockfile
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.8.3"
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --frozen --extra dev
- name: Run tests with coverage
run: |
uv run python -m pytest tests/ \
--cov=paperscout \
--cov-report=term-missing \
--cov-report=xml \
--cov-fail-under=90 \
-v
- name: Write coverage summary
if: always()
run: uv run python -m coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
- name: Upload coverage artifact
if: matrix.python-version == '3.12'
uses: actions/upload-artifact@v7
with:
name: coverage-xml
path: coverage.xml
retention-days: 7
benchmark:
name: Probe cycle benchmark (regression)
runs-on: ubuntu-latest
needs: lockfile
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.8.3"
python-version: "3.12"
- name: Install dependencies
run: uv sync --frozen --extra dev
- name: Run probe benchmark (mock HTTP)
run: uv run pytest benchmarks/ -m benchmark -v --tb=short
docker:
name: Docker image (build + tests in container)
runs-on: ubuntu-latest
needs: lockfile
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Build test image
run: docker build --target test -t paperscout:ci .
- name: Run tests in container
run: |
docker run --rm --entrypoint python \
-e _PAPERSCOUT_TESTING=1 \
-e SLACK_BOT_TOKEN=xoxb-ci-placeholder \
-e SLACK_SIGNING_SECRET=ci-placeholder-secret \
-e COVERAGE_FILE=/tmp/.coverage \
paperscout:ci \
-m pytest tests/ -q --cov=paperscout --cov-fail-under=90