-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (113 loc) · 3.66 KB
/
python-test.yml
File metadata and controls
132 lines (113 loc) · 3.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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Test Python package
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.14
uses: actions/setup-python@v3
with:
python-version: 3.14
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: "0.8.14"
- name: Install dependencies
# TODO: Is this necessary? Maybe we just install pre-commit directly?
run: |
uv sync --locked --dev
uv pip freeze
- name: Lint with pre-commit
# TODO: Consider caching pre-commit installation
run: |
uv run pre-commit run --all-files --show-diff-on-failure
test:
runs-on: ${{ matrix.os }}
needs: lint
strategy:
fail-fast: true
matrix:
os: ["ubuntu-latest", "windows-latest"]
python-version: ["3.10", "3.14"]
django-version: ["4.2.*", "5.2.*", "6.0.*"]
exclude:
# Django 6.0 only supports Python 3.12 and above
- python-version: "3.10"
django-version: "6.0.*"
- python-version: "3.11"
django-version: "6.0.*"
# No need to test all combinations on Ubuntu
- os: "ubuntu-latest"
python-version: "3.10"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: "0.8.14"
- name: Install dependencies
# TODO: set up caching for uv
run: |
uv sync --locked --dev --no-install-package django
uv pip install "django==${{ matrix.django-version }}"
uv pip freeze
- name: Test with pytest
run: |
uv run pytest --cov-report xml:coverage.xml --junitxml=pytest.xml --cov-fail-under=80
continue-on-error: true # Always continue to upload reports
- name: Upload coverage and test reports
# Upload coverage report only once to avoid redundancy
if: ${{ matrix.os == 'windows-latest' && matrix.python-version == '3.14' && matrix.django-version == '5.2.*' }}
uses: actions/upload-artifact@v4.6.2
with:
name: test-report
path: |
coverage.xml
pytest.xml
sonarqube:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# No shallow clone for a better analysis
fetch-depth: 0
- name: Set up Python 3.14
uses: actions/setup-python@v3
with:
python-version: 3.14
- name: Install Mypy
run: |
python -m pip install mypy django-stubs types-pywin32
- name: Run MyPy
run: |
mypy --strict --junit-xml mypy.xml src
continue-on-error: true
- name: Download coverage report
uses: actions/download-artifact@v4
with:
name: test-report
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v5.3.1
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- name: SonarQube Quality Gate check
uses: sonarsource/sonarqube-quality-gate-action@v1.2.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}