This repository was archived by the owner on Apr 7, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (142 loc) · 4.66 KB
/
test.yml
File metadata and controls
169 lines (142 loc) · 4.66 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: Template Tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
schedule:
# Run tests weekly to catch issues with dependencies
- cron: '0 6 * * 1'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Lint with Ruff
run: |
ruff check hooks/ tests/ --ignore PLR0133,PLR0912,PLR0915,PLC0415,UP035,UP006,B007,F841,PLR1714
ruff format --check hooks/ tests/
- name: Type check with MyPy
run: mypy tests/
- name: Security check with Bandit
run: bandit -r hooks/ -ll
- name: Validate cookiecutter.json
run: python -c "import json; json.load(open('cookiecutter.json'))"
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
exclude:
# Reduce matrix size - test all Python versions on Ubuntu, fewer on others
- os: windows-latest
python-version: '3.9'
- os: windows-latest
python-version: '3.10'
- os: macos-latest
python-version: '3.9'
- os: macos-latest
python-version: '3.10'
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run fast tests
run: pytest tests/ -m "not slow" -v
- name: Run slow tests
run: pytest tests/ -m "slow" -v
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
test-generated-projects:
runs-on: ubuntu-latest
strategy:
matrix:
config:
- name: "minimal"
use_ruff: "n"
use_mypy: "n"
use_github_actions: "n"
command_line_interface: "none"
- name: "basic-cli"
use_ruff: "y"
use_mypy: "n"
use_github_actions: "n"
command_line_interface: "typer"
- name: "full-quality"
use_ruff: "y"
use_mypy: "y"
use_github_actions: "y"
command_line_interface: "typer"
use_coverage: "y"
use_bandit: "y"
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install cookiecutter
run: |
python -m pip install --upgrade pip
pip install cookiecutter
- name: Generate project with ${{ matrix.config.name }} config
run: |
cookiecutter . --no-input \
project_name="Test Package ${{ matrix.config.name }}" \
project_slug="test_package_${{ matrix.config.name }}" \
use_ruff="${{ matrix.config.use_ruff }}" \
use_mypy="${{ matrix.config.use_mypy }}" \
use_github_actions="${{ matrix.config.use_github_actions }}" \
command_line_interface="${{ matrix.config.command_line_interface }}" \
use_coverage="${{ matrix.config.use_coverage || 'n' }}" \
use_bandit="${{ matrix.config.use_bandit || 'n' }}"
- name: Test generated project
run: |
cd "test_package_${{ matrix.config.name }}"
python -m pip install -e ".[dev]"
python -m pytest -v
- name: Test generated project quality tools
if: matrix.config.use_ruff == 'y'
run: |
cd "test_package_${{ matrix.config.name }}"
python -m ruff check src/ tests/
python -m ruff format --check src/ tests/
- name: Test generated project type checking
if: matrix.config.use_mypy == 'y'
run: |
cd "test_package_${{ matrix.config.name }}"
python -m mypy src/
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run tests with coverage
run: pytest tests/ --cov=. --cov-report=xml --cov-report=html
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: ./coverage.xml
flags: template-tests
name: template-coverage