-
Notifications
You must be signed in to change notification settings - Fork 1
124 lines (117 loc) · 3.26 KB
/
python-app.yml
File metadata and controls
124 lines (117 loc) · 3.26 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
# Run testing, linting and type-checking for Python code
# * uv as dependency manager
# * pytest for testing
# * ruff for linting
# * mypy for type-checking
#
# Testing is run across many platforms and Python versions
# All others are just run on Ubuntu with latest compatible Python
name: Test and Lint
on:
pull_request:
branches:
- main
push:
branches:
- main
# Yoinked from https://github.com/MTES-MCT/apilos/pull/854/files
# Explicitely set permissions to allow Dependabot workflow runs to write in the PR
# for coverage's reporting.
# By default, these are read-only when the actions are ran by Dependabot
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#changing-github_token-permissions
permissions:
contents: read
pull-requests: write
jobs:
# Run test suite with coverage
Test:
strategy:
matrix:
python-version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
os:
- "ubuntu-latest"
- "windows-latest"
- "macos-latest"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Test with pytest
run: |
uv run pytest
# Only run coverage once
Coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
# Pinned Python version
python-version-file: ".python-version"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Pytest with coverage
run: |
uv run coverage run -m pytest
- name: Print coverage output
run: |
uv run coverage report
- name: Generate code coverage report
if: ${{ github.event_name == 'pull_request' }}
run: |
uv run coverage xml
- name: Create code coverage comment
if: ${{ github.event_name == 'pull_request' }}
uses: orgoro/coverage@v3
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
# Run linting
Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
# Pinned Python version
python-version-file: ".python-version"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Lint with ruff
run: |
uv run ruff check
# Run type-checking with mypy
Type-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
# Pinned Python version
python-version-file: ".python-version"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Type-check with mypy
run: |
uv run mypy