-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (110 loc) · 3.11 KB
/
ci.yaml
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
name: CI
on:
workflow_call:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
PYTHON_VERSION: "3.10"
CI: "1"
jobs:
changes:
name: Check for file changes
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
permissions:
pull-requests: read
contents: read
outputs:
deps: ${{steps.filter.outputs.deps}}
ci: ${{steps.filter.outputs.ci}}
python: ${{steps.filter.outputs.python}}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
deps: &deps-files
- 'pyproject.toml'
- 'uv.lock'
ci: &ci-files
- '.github/workflows/ci.yaml'
python:
- *deps-files
- *ci-files
- '**/*.py'
check_pre_commit:
name: Check pre-commit
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
permissions:
contents: read
checks: write
issues: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ env.PYTHON_VERSION }}
- name: Load cached pre-commit environment
uses: actions/cache/restore@v4
id: pre-commit-cache
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }}
restore-keys: |
${{ runner.os }}-pre-commit-
- name: Install deps
run: uv sync --all-groups
- name: Run pre-commit hook
id: run-pre-commit-hooks
run: |
git add .pre-commit-config.yaml
uv run pre-commit run --color=always --all-files
- name: Annotate any changes using reviewdog
if: ${{ failure() }}
id: reviewdog-suggester
uses: reviewdog/action-suggester@v1
with:
tool_name: pre-commit
- name: Save pre-commit cache
if: ${{ always() }}
uses: actions/cache/save@v4
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }}
test:
strategy:
fail-fast: true
matrix:
python-version: ["3.10", "3.11", "3.12"]
runs-on: ubuntu-latest
needs: [changes]
if: ${{needs.changes.outputs.python == 'true' && !github.event.pull_request.draft }}
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Install deps
run: uv sync --group test
- name: Run tests
uses: quantco/pytest-action@v2
with:
verbose: true
job-summary: true
emoji: true
custom-pytest: uv run pytest -n 2
click-to-expand: true
report-title: "Test Report"