-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpip-build-lint-test-coverage.yml
More file actions
150 lines (144 loc) · 4.32 KB
/
pip-build-lint-test-coverage.yml
File metadata and controls
150 lines (144 loc) · 4.32 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
name: CI
on:
push:
branches: [ main, "v*" ]
pull_request:
branches: [ main, "v*" ]
workflow_dispatch:
permissions:
contents: read
pull-requests: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get git tags
run: git fetch --prune --unshallow --tags
- name: Set up PDM (cached)
if: ${{ hashFiles('**/pdm.lock') != '' }}
uses: pdm-project/setup-pdm@v4
with:
python-version: '3.12'
cache: true
cache-dependency-path: '**/pdm.lock'
- name: Set up PDM (no cache)
if: ${{ hashFiles('**/pdm.lock') == '' }}
uses: pdm-project/setup-pdm@v4
with:
python-version: '3.12'
- name: Install dev dependencies
run: pdm install -G dev
- name: Lint
run: pdm run lint
- name: Typecheck
run: pdm run typecheck
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.11', '3.12' ]
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get git tags
run: git fetch --prune --unshallow --tags
- name: Set up PDM (cached)
if: ${{ hashFiles('**/pdm.lock') != '' }}
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}
cache: true
cache-dependency-path: '**/pdm.lock'
- name: Set up PDM (no cache)
if: ${{ hashFiles('**/pdm.lock') == '' }}
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dev dependencies
run: pdm install -G dev
- name: Run tests (no coverage)
if: matrix.python-version != '3.12'
run: pdm run test
- name: Run tests with coverage
if: matrix.python-version == '3.12'
run: pdm run coverage
- name: Upload coverage artifact
if: matrix.python-version == '3.12' && github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: coverage-xml
path: coverage.xml
- name: Coverage report to coveralls
if: matrix.python-version == '3.12'
uses: coverallsapp/github-action@v2.0.0
with:
path-to-lcov: coverage.xml
benchmark:
runs-on: ubuntu-latest
needs: [ test ]
permissions:
contents: write
pull-requests: write
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get git tags
run: git fetch --prune --unshallow --tags
- name: Set up PDM (cached)
if: ${{ hashFiles('**/pdm.lock') != '' }}
uses: pdm-project/setup-pdm@v4
with:
python-version: '3.12'
cache: true
cache-dependency-path: '**/pdm.lock'
- name: Set up PDM (no cache)
if: ${{ hashFiles('**/pdm.lock') == '' }}
uses: pdm-project/setup-pdm@v4
with:
python-version: '3.12'
- name: Install dev dependencies
run: pdm install -G dev
- name: Run benchmarks
run: pdm run benchmark --benchmark-json bench.json
- name: Upload benchmark artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: bench-json
path: bench.json
- name: Store main benchmark result
if: github.ref == 'refs/heads/main'
uses: benchmark-action/github-action-benchmark@v1
with:
name: Python Benchmark
tool: 'pytest'
output-file-path: bench.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
gh-pages-branch: gh-pages
- name: Compare benchmarks
if: github.event_name == 'pull_request'
uses: benchmark-action/github-action-benchmark@v1
with:
name: Python Benchmark
tool: 'pytest'
output-file-path: bench.json
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-always: true
fail-threshold: '200%'
alert-threshold: '150%'
auto-push: false