-
-
Notifications
You must be signed in to change notification settings - Fork 188
176 lines (164 loc) · 5.43 KB
/
reusable-codspeed.yml
File metadata and controls
176 lines (164 loc) · 5.43 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
170
171
172
173
174
175
176
---
name: >-
❌
[DO NOT CLICK]
Reusable codspeed
on: # yamllint disable-line rule:truthy
workflow_call:
inputs:
check-name:
description: A custom name for the Checks API-reported status
required: false
type: string
dists-artifact-name:
description: >-
Workflow artifact name containing dists.
Defaults to "python-package-distributions".
default: python-package-distributions
required: false
type: string
pypi-project-name:
description: >-
Project name in the metadata that goes into site-packages. It
also governs whether to install the project from pre-built
wheels (when set) or build from source (when unset).
default: ''
required: false
type: string
runner-vm-os:
description: VM OS to use
default: ubuntu-latest
required: false
type: string
source-tarball-name:
default: >-
*.tar.gz
description: Sdist filename wildcard. Defaults to "*.tar.gz".
required: false
type: string
timeout-minutes:
description: Deadline for the job to complete
required: true
type: number
secrets:
codspeed-token:
description: Mandatory token for uploading to Codspeed
required: true
env:
COLOR: >- # Supposedly, pytest or coveragepy use this
yes
FORCE_COLOR: 1 # Request colored output from CLI tools supporting it
PIP_DISABLE_PIP_VERSION_CHECK: 1
PIP_NO_PYTHON_VERSION_WARNING: 1
PIP_NO_WARN_SCRIPT_LOCATION: 1
PY_COLORS: 1 # Recognized by the `py` package, dependency of `pytest`
PYTHONIOENCODING: utf-8
PYTHONUTF8: 1
jobs:
codspeed:
name: >-
${{
inputs.check-name
&& inputs.check-name
|| format(
'🐇 Codspeed: {0}', inputs.pypi-project-name != ''
&& 'pre-built'
|| 'src'
)
}}
runs-on: ${{ inputs.runner-vm-os }}
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- name: Retrieve the project source from Git to please Codspeed runner
# NOTE: Codspeed is incapable of getting repo details from CI environment
# Ref: https://github.com/CodSpeedHQ/runner/issues/144
uses: actions/checkout@v6
with:
depth: 1 # Codspeed only checks the HEAD
- name: Retrieve the project source from an sdist inside the GHA artifact
uses: re-actors/checkout-python-sdist@release/v2
with:
source-tarball-name: >-
${{ inputs.source-tarball-name }}
workflow-artifact-name: >-
${{ inputs.dists-artifact-name }}
- name: Download distributions
if: inputs.pypi-project-name != ''
uses: actions/download-artifact@v8
with:
path: dist
pattern: ${{ inputs.dists-artifact-name }}*
merge-multiple: true
- name: Setup Python 3.13
id: python-install
uses: actions/setup-python@v6
with:
python-version: 3.13
- name: >-
Calculate dependency files' combined hash value
for use in the cache key
id: calc-cache-key-files
uses: ./.github/actions/cache-keys
- name: Set up pip cache
uses: re-actors/cache-python-deps@release/v1
with:
cache-key-for-dependency-files: >-
${{ steps.calc-cache-key-files.outputs.cache-key-for-dep-files }}
- name: Determine pre-compiled compatible wheel
if: inputs.pypi-project-name != ''
env:
# NOTE: When `pip` is forced to colorize output piped into `jq`,
# NOTE: the latter can't parse it. So we're overriding the color
# NOTE: preference here via https://no-color.org.
# NOTE: Setting `FORCE_COLOR` to any value (including 0, an empty
# NOTE: string, or a "YAML null" `~`) doesn't have any effect and
# NOTE: `pip` (through its verndored copy of `rich`) treats the
# NOTE: presence of the variable as "force-color" regardless.
#
# NOTE: This doesn't actually work either, so we'll resort to unsetting
# NOTE: in the Bash script.
# NOTE: Ref: https://github.com/Textualize/rich/issues/2622
NO_COLOR: 1
PROJECT_NAME: ${{ inputs.pypi-project-name }}
id: wheel-file
run: >
echo -n path= | tee -a "${GITHUB_OUTPUT}"
unset FORCE_COLOR
python
-X utf8
-u -I
-m pip install
--find-links=./dist
--no-index
"${PROJECT_NAME}"
--force-reinstall
--no-color
--no-deps
--only-binary=:all:
--dry-run
--report=-
--quiet
| jq --raw-output .install[].download_info.url
| tee -a "${GITHUB_OUTPUT}"
shell: bash
- name: Install benchmark deps and the project from a pre-built wheel
if: inputs.pypi-project-name != ''
run: >-
python -Im pip install
-r requirements/codspeed.txt
'${{ steps.wheel-file.outputs.path }}'
- name: Install benchmark deps and the project from source
if: inputs.pypi-project-name == ''
run: >-
python -Im pip install
-r requirements/codspeed.txt
.
--config-setting=pure-python=false
--config-setting=with-cython-tracing=false
- name: Run benchmarks
uses: CodSpeedHQ/action@v4
with:
token: ${{ secrets.codspeed-token }}
run: python -Im pytest --no-cov -vvvvv --codspeed
mode: instrumentation
...