forked from chamilad/process-metrics-collector
-
Notifications
You must be signed in to change notification settings - Fork 1
261 lines (250 loc) · 9.61 KB
/
pre-commit_wsl.yml
File metadata and controls
261 lines (250 loc) · 9.61 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
name: pre-commit_wsl
on:
workflow_dispatch:
pull_request:
#push:
# branches: [exec]
# paths-ignore:
# - 'constraints-*_*-wsl.txt'
jobs:
pre-commit:
runs-on: windows-2022
strategy:
matrix:
# python-version: [ "3.12" ]
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" ]
distribution: [ "Ubuntu-22.04", "Ubuntu-24.04" ]
max-parallel: 1
name: Pre-commit WSL python ${{ matrix.python-version }} dist ${{ matrix.distribution }}
steps:
- name: Bootstrapping dist ${{ matrix.distribution }}
uses: Vampire/setup-wsl@v6
with:
distribution: ${{ matrix.distribution }}
use-cache: 'true'
update: 'true'
additional-packages: |
python3
python3-pip
build-essential
libssl-dev
zlib1g-dev
libbz2-dev
libreadline-dev
libsqlite3-dev
wget
curl
llvm
libncurses5-dev
libncursesw5-dev
xz-utils
tk-dev
libffi-dev
liblzma-dev
python3-openssl
- name: Cache pyenv and pip in WSL
id: cache-pyenv
uses: actions/cache@v5
with:
path: |
.pyenv
.bash_profile
.bashrc
.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.distribution }}
- name: Install pyenv in WSL
if: steps.cache-pyenv.outputs.cache-hit != 'true'
shell: wsl-bash {0}
run: |
pwd
ls -la
git clone -b v2.6.11 https://github.com/pyenv/pyenv.git ~/.pyenv
cd ~/.pyenv && src/configure && make -C src
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init - bash)"' >> ~/.bashrc
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init - bash)"' >> ~/.bash_profile
- name: Install python ${{matrix.python-version}} using pyenv in WSL
if: steps.cache-pyenv.outputs.cache-hit != 'true'
shell: wsl-bash {0}
run: |
source ~/.bash_profile
pyenv install ${{matrix.python-version}}
pyenv global ${{matrix.python-version}}
- name: Clone repo
shell: wsl-bash {0}
run: |
git clone --filter=blob:none --no-checkout "${{github.server_url}}/${{github.repository}}" the_repo
cd the_repo
git checkout "${{github.sha}}"
- name: 'Install requirements (standard or constraints ${{ matrix.python-version }})'
shell: wsl-bash {0}
run: |
source ~/.bash_profile
cd the_repo
python -mvenv .env
source .env/bin/activate
pip install --upgrade pip wheel
constraints_file="constraints-${{ matrix.python-version }}_${{ matrix.distribution }}-wsl.txt"
regen_constraints=
if [ -f "$constraints_file" ] ; then
at="$(git --no-pager log -p -1 "--format=tformat:%at" --no-patch -- "$constraints_file")"
dat="$(git --no-pager log -p -1 "--format=tformat:%at" --no-patch -- "requirements.txt")"
if [ "$at" -lt "$dat" ] ; then
regen_constraints=true
fi
else
regen_constraints=true
fi
if [ -n "$regen_constraints" ] ; then
pip install -r requirements.txt
pip freeze > "$constraints_file"
grep -vF git+ "$constraints_file" > "$constraints_file"-relaxed
else
grep -vF git+ "$constraints_file" > "$constraints_file"-relaxed
pip install -r requirements.txt -c "$constraints_file"-relaxed
fi
- name: 'Install development requirements'
shell: wsl-bash {0}
run: |
source ~/.bash_profile
cd the_repo
source .env/bin/activate
pip install -r dev-requirements.txt -r mypy-requirements.txt -c constraints-${{ matrix.python-version }}_${{ matrix.distribution }}-wsl.txt-relaxed
# - name: MyPy cache
# uses: actions/cache@v5
# with:
# path: '.mypy_cache/[0-9]*'
# key: mypy-${{ matrix.python-version }}
- name: 'pre-commit'
shell: wsl-bash {0}
run: |
source ~/.bash_profile
cd the_repo
source .env/bin/activate
pre-commit run -a
- name: CPU database cache restore
id: cache-cpu-databases-restore
uses: actions/cache/restore@v5
with:
path: |
the_repo/cpumark_table.csv
the_repo/cpu-spec-dataset
key: cpu_databases_wsl
- name: CPU database population
if: steps.cache-cpu-databases-restore.outputs.cache-hit != 'true'
shell: wsl-bash {0}
run: |
source ~/.bash_profile
cd the_repo
source .env/bin/activate
python -m treecript.tdp_sources cpumark_table.tsv
git clone https://github.com/JosuaCarl/cpu-spec-dataset
- name: CPU database cache save
if: steps.cache-cpu-databases-restore.outputs.cache-hit != 'true'
id: cache-cpu-databases-save
uses: actions/cache/save@v5
with:
path: |
the_repo/cpumark_table.csv
the_repo/cpu-spec-dataset
key: ${{ steps.cache-cpu-databases-restore.outputs.cache-primary-key }}
- name: 'pytest + coverage (${{ matrix.python-version }})'
shell: wsl-bash {0}
run: |
source ~/.bash_profile
cd the_repo
source .env/bin/activate
CACHED_CPU_SPEC_DATASET=${PWD}/cpu-spec-dataset CACHED_CPUMARK_DATASET=${PWD}/cpumark_table.tsv pytest --cov=treecript
- uses: actions/upload-artifact@v6
with:
name: wsl_pre-commit-${{ matrix.python-version }}_${{ matrix.distribution }}
retention-days: 2
path: the_repo/constraints-${{ matrix.python-version }}_${{ matrix.distribution }}-wsl.txt
check_licences:
runs-on: ubuntu-latest
strategy:
matrix:
# python-version: [ "3.12" ]
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" ]
distribution: [ "Ubuntu-22.04", "Ubuntu-24.04" ]
name: Validate licences of gathered dependencies (WSL python ${{ matrix.python-version }} dist ${{ matrix.distribution }})
needs:
- pre-commit
steps:
- name: Get analysis timestamp
id: timestamp
run: echo "timestamp=$(date -Is)" >> "$GITHUB_OUTPUT"
- uses: actions/download-artifact@v7
id: download
with:
name: wsl_pre-commit-${{matrix.python-version}}_${{ matrix.distribution }}
- name: Get transitive dependencies licences
id: license_check_print_report
# continue-on-error: true
uses: pilosus/action-pip-license-checker@v3.1.0
with:
requirements: constraints-${{ matrix.python-version }}_${{ matrix.distribution }}-wsl.txt
# - name: Check transitive dependencies licences
# id: license_check_report
# uses: pilosus/action-pip-license-checker@v3.1.0
# with:
# requirements: constraints-${{ matrix.python-version }}.txt
# fail: 'StrongCopyleft'
# exclude: '(?i)^(pylint|dulwich|docutils).*'
- name: Print licences report
if: ${{ always() }}
run: echo "${{ steps.license_check_print_report.outputs.report }}"
pull_request_changes:
# Do this only when it is not a pull request validation
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
name: Pull request with the newly generated contents
needs:
- check_licences
steps:
- name: Get analysis timestamp
id: timestamp
run: echo "timestamp=$(date -Is)" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v6
- uses: actions/download-artifact@v7
id: download
with:
pattern: wsl_pre-commit-*_*
merge-multiple: true
path: changes-dir
- name: Move artifacts to their right place
id: move
run: |
skip=true
if [ -d "${{steps.download.outputs.download-path}}" ] ; then
for con in "${{steps.download.outputs.download-path}}"/constraints-*_*-wsl.txt ; do
case "$con" in
*/constraints-\*_\*-wsl.txt)
break
;;
*)
cp -p "$con" .
skip=false
;;
esac
done
fi
echo "skip=$skip" >> "$GITHUB_OUTPUT"
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v8
if: steps.move.outputs.skip == 'false'
with:
title: Updated WSL constraints (triggered on ${{ steps.timestamp.outputs.timestamp }} by ${{ github.sha }})
branch: create-pull-request/patch-wsl_constraints
add-paths: constraints-*_*-wsl.txt
delete-branch: true
commit-message: "[create-pull-request] Automatically commit updated contents (constraints WSL)"
- name: Check outputs
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" >> "$GITHUB_STEP_SUMMARY"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" >> "$GITHUB_STEP_SUMMARY"