Debian Codegraph @

.github/workflows/modified_scripts_build.yml

raw
1 name: modified_scripts
2 on: [pull_request]
3 jobs:
4 discover_modified_scripts:
5 runs-on: ubuntu-latest
6 outputs:
7 versions: ${{steps.modified-versions.outputs.versions}}
8 versions_cpython_only: ${{steps.modified-versions.outputs.versions_cpython_only}}
9 versions_macos_build_exclude: ${{steps.modified-versions.outputs.versions_macos_build_exclude}}
10 steps:
11 - uses: actions/checkout@v6
12 - run: git fetch origin "$GITHUB_BASE_REF"
13 - shell: bash
14 run: >
15 versions=$(git diff "origin/$GITHUB_BASE_REF" --name-only -z
16 | perl -ne 'BEGIN {$\="\n";$/="\0";} chomp;
17 if (/^(plugins\/python-build\/share\/python-build\/)(?:([^\/]+)|patches\/([^\/]+)\/.*)$/ and -e $& )
18 {
19 print $2.$3;
20 if ( -e $1.$2.$3.t ) { print $2.$3.t; }
21 }' \
22 | sort -u);
23 EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64);
24 echo "versions<<$EOF" >> $GITHUB_ENV;
25 echo "$versions" >> $GITHUB_ENV;
26 echo "$EOF" >> $GITHUB_ENV;
27
28 versions_cpython_only=$(grep -Ee '^[[:digit:]]' <<<"$versions")
29 EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64);
30 echo "versions_cpython_only<<$EOF" >> $GITHUB_ENV;
31 echo "$versions_cpython_only" >> $GITHUB_ENV;
32 echo "$EOF" >> $GITHUB_ENV;
33 - run: pip install packaging
34 - name: Build exclusions JSON
35 shell: python
36 run: |
37 import os
38 import json
39 import random
40 import re
41 import subprocess
42
43 import packaging.version
44
45 result=[]
46
47 for line in os.environ['versions'].splitlines():
48 if m:=re.match(r'([^-]+)-(\d+\.\d+)-(\d+\.\d+.\d+)', line):
49 name, version = m.group(1), packaging.version.Version(m.group(3))
50
51 # Miniconda dropped MacOS x64 support
52 if (name == 'miniconda3' and version >= packaging.version.Version('25.9.1')):
53 result.append({'os':'macos-15-intel','python-version':line})
54
55 if m:=re.match(r'([^-]+)-(\d+\.\d+)', line):
56 name, version = m.group(1), packaging.version.Version(m.group(2))
57
58 # Anaconda dropped MacOS x64 support
59 if name == 'anaconda3' and version >= packaging.version.Version('2025.12'):
60 result.append({'os':'macos-15-intel','python-version':line})
61
62 if m:=re.match(r'graalpy-(community-)?(\d+\.\d+.\d+)', line):
63 version = packaging.version.Version(m.group(2))
64
65 # GraalPy dropped MacOS x64 support
66 if version >= packaging.version.Version('25.0.2'):
67 result.append({'os':'macos-15-intel','python-version':line})
68
69
70 EOF = str(random.getrandbits(15*8))
71
72 with open(os.environ['GITHUB_ENV'],'w') as f:
73 f.write(f"versions_macos_build_exclude_json<<{EOF}\n")
74 json.dump(result, f)
75 f.write(f'\n{EOF}\n')
76
77 - id: modified-versions
78 run: |
79 echo "versions=`echo "${{ env.versions }}" | jq -R . | jq -sc .`" >> $GITHUB_OUTPUT
80 echo "versions_cpython_only=`echo "${{ env.versions_cpython_only }}" | jq -R . | jq -sc .`" >> $GITHUB_OUTPUT
81 echo 'versions_macos_build_exclude=${{ env.versions_macos_build_exclude_json }}' >> $GITHUB_OUTPUT
82 macos_build:
83 needs: discover_modified_scripts
84 if: needs.discover_modified_scripts.outputs.versions != '[""]'
85 strategy:
86 fail-fast: false
87 matrix:
88 python-version: ${{fromJson(needs.discover_modified_scripts.outputs.versions)}}
89 os:
90 - macos-14
91 - macos-15
92 - macos-15-intel
93 - macos-26
94 exclude: ${{fromJson(needs.discover_modified_scripts.outputs.versions_macos_build_exclude)}}
95 runs-on: ${{ matrix.os }}
96 steps:
97 - uses: actions/checkout@v6
98 - run: |
99 #envvars
100 export PYENV_ROOT="$GITHUB_WORKSPACE"
101 echo "PYENV_ROOT=$PYENV_ROOT" >> $GITHUB_ENV
102 echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH
103 - run: |
104 #prerequisites
105 brew install openssl readline sqlite3 xz tcl-tk@8 libb2 zstd
106 if [[ "${{ matrix.python-version }}" =~ pypy.*-(src|dev) ]]; then
107 export PYENV_BOOTSTRAP_VERSION=pypy2.7-7
108 echo "PYENV_BOOTSTRAP_VERSION=$PYENV_BOOTSTRAP_VERSION" >> $GITHUB_ENV
109 pyenv install $PYENV_BOOTSTRAP_VERSION
110 fi
111 - run: |
112 #build
113 pyenv --debug install ${{ matrix.python-version }} && rc=$? || rc=$?
114 if [[ $rc -ne 0 ]]; then echo config.log:; cat $TMPDIR/python-build*/*/config.log; false; fi
115 pyenv global ${{ matrix.python-version }}
116 # Micropython doesn't support --version
117 - run: |
118 #print version
119 if [[ "${{ matrix.python-version }}" == "micropython-"* ]]; then
120 python -c 'import sys; print(sys.version)'
121 else
122 python --version
123 python -m pip --version
124 fi
125 # Micropython doesn't support sys.executable, os.path, older versions even os
126 - env:
127 EXPECTED_PYTHON: ${{ matrix.python-version }}
128 run: |
129 #check
130 if [[ "${{ matrix.python-version }}" == "micropython-"* ]]; then
131 [[ $(pyenv which python) == "${{ env.PYENV_ROOT }}/versions/${{ matrix.python-version }}/bin/python" ]] || exit 1
132 python -c 'import sys; assert sys.implementation.name == "micropython"'
133 else
134 python -c 'if True:
135 import os, sys, os.path
136 correct_dir = os.path.join(
137 os.environ["PYENV_ROOT"],
138 "versions",
139 os.environ["EXPECTED_PYTHON"],
140 "bin")
141 assert os.path.dirname(sys.executable) == correct_dir'
142 fi
143 # bundled executables in some Anaconda releases cause the post-run step to hang in MacOS
144 - run: |
145 pyenv global system
146 rm -f "$(pyenv root)"/shims/*
147
148
149 macos_build_bundled_dependencies:
150 needs: discover_modified_scripts
151 if: needs.discover_modified_scripts.outputs.versions_cpython_only != '[""]'
152 strategy:
153 fail-fast: false
154 matrix:
155 python-version: ${{fromJson(needs.discover_modified_scripts.outputs.versions_cpython_only)}}
156 os: ["macos-14", "macos-15", "macos-15-intel"]
157 runs-on: ${{ matrix.os }}
158 steps:
159 - uses: actions/checkout@v6
160 - run: |
161 #envvars
162 export PYENV_ROOT="$GITHUB_WORKSPACE"
163 echo "PYENV_ROOT=$PYENV_ROOT" >> $GITHUB_ENV
164 echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH
165 - run: |
166 #prerequisites
167 brew install sqlite3 xz tcl-tk@8 libb2 zstd
168 "$GITHUB_WORKSPACE/.github/workflows/scripts/brew-uninstall-cascade.sh" openssl@3 [email protected] readline
169 if [[ "${{ matrix.python-version }}" =~ pypy.*-(src|dev) ]]; then
170 export PYENV_BOOTSTRAP_VERSION=pypy2.7-7
171 echo "PYENV_BOOTSTRAP_VERSION=$PYENV_BOOTSTRAP_VERSION" >> $GITHUB_ENV
172 pyenv install $PYENV_BOOTSTRAP_VERSION
173 fi
174 - run: |
175 #build
176 pyenv --debug install ${{ matrix.python-version }} && rc=$? || rc=$?
177 if [[ $rc -ne 0 ]]; then echo config.log:; cat $TMPDIR/python-build*/*/config.log; false; fi
178 pyenv global ${{ matrix.python-version }}
179 - run: |
180 #print version
181 python --version
182 python -m pip --version
183 - env:
184 EXPECTED_PYTHON: ${{ matrix.python-version }}
185 run: |
186 #check
187 python -c '
188 import os, sys, os.path
189 correct_dir = os.path.join(
190 os.environ["PYENV_ROOT"],
191 "versions",
192 os.environ["EXPECTED_PYTHON"],
193 "bin")
194 assert os.path.dirname(sys.executable) == correct_dir'
195
196 ubuntu_build:
197 needs: discover_modified_scripts
198 if: needs.discover_modified_scripts.outputs.versions != '[""]'
199 strategy:
200 fail-fast: false
201 matrix:
202 python-version: ${{fromJson(needs.discover_modified_scripts.outputs.versions)}}
203 os:
204 - ubuntu-22.04
205 - ubuntu-24.04
206 runs-on: ${{ matrix.os }}
207 steps:
208 - uses: actions/checkout@v6
209 - run: |
210 #envvars
211 export PYENV_ROOT="$GITHUB_WORKSPACE"
212 echo "PYENV_ROOT=$PYENV_ROOT" >> $GITHUB_ENV
213 echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH
214 - run: |
215 #prerequisites
216 sudo apt-get update -q; sudo apt-get install -yq make build-essential \
217 libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \
218 curl llvm libncurses5-dev libncursesw5-dev \
219 xz-utils tk-dev libffi-dev liblzma-dev
220 if [[ "${{ matrix.python-version }}" =~ pypy.*-(src|dev) ]]; then
221 export PYENV_BOOTSTRAP_VERSION=pypy2.7-7
222 echo "PYENV_BOOTSTRAP_VERSION=$PYENV_BOOTSTRAP_VERSION" >> $GITHUB_ENV
223 pyenv install $PYENV_BOOTSTRAP_VERSION
224 fi
225 - run: |
226 #build
227 pyenv --debug install ${{ matrix.python-version }} && rc=$? || rc=$?
228 if [[ $rc -ne 0 ]]; then echo config.log:; cat $TMPDIR/python-build*/*/config.log; false; fi
229 pyenv global ${{ matrix.python-version }}
230 # Micropython doesn't support --version
231 - run: |
232 #print version
233 if [[ "${{ matrix.python-version }}" == "micropython-"* ]]; then
234 python -c 'import sys; print(sys.version)'
235 else
236 python --version
237 python -m pip --version
238 fi
239 # Micropython doesn't support sys.executable, os.path, older versions even os
240 - env:
241 EXPECTED_PYTHON: ${{ matrix.python-version }}
242 run: |
243 #check
244 if [[ "${{ matrix.python-version }}" == "micropython-"* ]]; then
245 [[ $(pyenv which python) == "${{ env.PYENV_ROOT }}/versions/${{ matrix.python-version }}/bin/python" ]] || exit 1
246 python -c 'import sys; assert sys.implementation.name == "micropython"'
247 else
248 python -c 'if True:
249 import os, sys, os.path
250 correct_dir = os.path.join(
251 os.environ["PYENV_ROOT"],
252 "versions",
253 os.environ["EXPECTED_PYTHON"],
254 "bin")
255 assert os.path.dirname(sys.executable) == correct_dir'
256 fi
257 # bundled executables in some Anaconda releases cause the post-run step to break
258 - run: |
259 pyenv global system
260 rm -f "$(pyenv root)"/shims/*
261 ubuntu_build_tar_gz:
262 needs: discover_modified_scripts
263 if: needs.discover_modified_scripts.outputs.versions_cpython_only != '[""]'
264 strategy:
265 fail-fast: false
266 matrix:
267 python-version: ${{fromJson(needs.discover_modified_scripts.outputs.versions_cpython_only)}}
268 os: ["ubuntu-latest"]
269 runs-on: ${{ matrix.os }}
270 steps:
271 - uses: actions/checkout@v6
272 - run: |
273 #envvars
274 export PYENV_ROOT="$GITHUB_WORKSPACE"
275 echo "PYENV_ROOT=$PYENV_ROOT" >> $GITHUB_ENV
276 echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH
277 echo "_PYTHON_BUILD_FORCE_SKIP_XZ=1" >> $GITHUB_PATH
278 - run: |
279 #prerequisites
280 sudo apt-get update -q; sudo apt-get install -yq make build-essential \
281 libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \
282 curl llvm libncurses5-dev libncursesw5-dev \
283 xz-utils tk-dev libffi-dev liblzma-dev
284 if [[ "${{ matrix.python-version }}" =~ pypy.*-(src|dev) ]]; then
285 export PYENV_BOOTSTRAP_VERSION=pypy2.7-7
286 echo "PYENV_BOOTSTRAP_VERSION=$PYENV_BOOTSTRAP_VERSION" >> $GITHUB_ENV
287 pyenv install $PYENV_BOOTSTRAP_VERSION
288 fi
289 - run: |
290 #build
291 pyenv --debug install ${{ matrix.python-version }} && rc=$? || rc=$?
292 if [[ $rc -ne 0 ]]; then echo config.log:; cat $TMPDIR/python-build*/*/config.log; false; fi
293 pyenv global ${{ matrix.python-version }}
294 - run: |
295 #print version
296 python --version
297 python -m pip --version
298 - env:
299 EXPECTED_PYTHON: ${{ matrix.python-version }}
300 run: |
301 #check
302 python -c '
303 import os, sys, os.path
304 correct_dir = os.path.join(
305 os.environ["PYENV_ROOT"],
306 "versions",
307 os.environ["EXPECTED_PYTHON"],
308 "bin")
309 assert os.path.dirname(sys.executable) == correct_dir'