-
Notifications
You must be signed in to change notification settings - Fork 1
119 lines (100 loc) · 3.39 KB
/
Copy pathci.yml
File metadata and controls
119 lines (100 loc) · 3.39 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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
workflow_call:
jobs:
lint:
name: Lint and Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Install dependencies
run: uv sync --all-extras
- name: Run ty type checking
run: uv run ty check
- name: Run ruff
run: |
uv run ruff check src/ tests/
uv run ruff format --check src/ tests/
test:
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.11", "3.12", "3.13"]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Install dependencies
run: uv sync --all-extras
- name: Download spaCy models
run: |
uv run python -m spacy download en_core_web_sm
uv run python -m spacy download ja_core_news_sm
uv run python -m spacy download xx_ent_wiki_sm
- name: Download NLTK data
run: |
uv run python -m nltk.downloader punkt
uv run python -m nltk.downloader averaged_perceptron_tagger
uv run python -m nltk.downloader maxent_ne_chunker
uv run python -m nltk.downloader words
- name: Run tests
# On 3.12 also collect coverage in the same invocation to avoid running
# the suite twice. --cov-fail-under enforces the overall regression floor
# (configured in pyproject.toml [tool.coverage.report] fail_under = 33).
# Patch coverage (new/changed lines ≥ 80%) is enforced by Codecov below.
run: |
EXTRA_ARGS=""
if [ "${{ matrix.python-version }}" = "3.11" ]; then
EXTRA_ARGS="--cov=src/risk_assessment --cov-report=xml --cov-report=html --cov-report=term-missing"
fi
uv run pytest tests/ -v --tb=short --maxfail=5 \
--junitxml=test-results/junit-${{ matrix.os }}-${{ matrix.python-version }}.xml \
$EXTRA_ARGS
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}-${{ matrix.python-version }}
path: test-results/
retention-days: 7
- name: Upload coverage to Codecov
if: matrix.python-version == '3.11'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
fail_ci_if_error: true
verbose: true
- name: Upload HTML coverage report as artifact
if: always() && matrix.python-version == '3.11'
uses: actions/upload-artifact@v4
with:
name: coverage-html-report
path: htmlcov/
retention-days: 14