Skip to content

Commit 998bc16

Browse files
NCLIcorona10
authored andcommitted
pythongh-111062: Reusable ubuntu build that supports free-threaded mode as the conditional CI (python#111452)
Co-authored-by: Donghee Na <donghee.na92@gmail.com>
1 parent 0f86605 commit 998bc16

File tree

2 files changed

+91
-58
lines changed

2 files changed

+91
-58
lines changed

.github/workflows/build.yml

+21-58
Original file line numberDiff line numberDiff line change
@@ -248,70 +248,30 @@ jobs:
248248

249249
build_ubuntu:
250250
name: 'Ubuntu'
251-
runs-on: ubuntu-20.04
252-
timeout-minutes: 60
253251
needs: check_source
254252
if: needs.check_source.outputs.run_tests == 'true'
255-
env:
256-
OPENSSL_VER: 3.0.11
257-
PYTHONSTRICTEXTENSIONBUILD: 1
258-
steps:
259-
- uses: actions/checkout@v4
260-
- name: Register gcc problem matcher
261-
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
262-
- name: Install dependencies
263-
run: sudo ./.github/workflows/posix-deps-apt.sh
264-
- name: Configure OpenSSL env vars
265-
run: |
266-
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> $GITHUB_ENV
267-
echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}" >> $GITHUB_ENV
268-
echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV
269-
- name: 'Restore OpenSSL build'
270-
id: cache-openssl
271-
uses: actions/cache@v3
272-
with:
273-
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
274-
key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
275-
- name: Install OpenSSL
276-
if: steps.cache-openssl.outputs.cache-hit != 'true'
277-
run: python3 Tools/ssl/multissltests.py --steps=library --base-directory $MULTISSL_DIR --openssl $OPENSSL_VER --system Linux
278-
- name: Add ccache to PATH
279-
run: |
280-
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
281-
- name: Configure ccache action
282-
uses: hendrikmuhs/ccache-action@v1.2
283-
- name: Setup directory envs for out-of-tree builds
284-
run: |
285-
echo "CPYTHON_RO_SRCDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-ro-srcdir)" >> $GITHUB_ENV
286-
echo "CPYTHON_BUILDDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-builddir)" >> $GITHUB_ENV
287-
- name: Create directories for read-only out-of-tree builds
288-
run: mkdir -p $CPYTHON_RO_SRCDIR $CPYTHON_BUILDDIR
289-
- name: Bind mount sources read-only
290-
run: sudo mount --bind -o ro $GITHUB_WORKSPACE $CPYTHON_RO_SRCDIR
291-
- name: Restore config.cache
292-
uses: actions/cache@v3
293-
with:
294-
path: ${{ env.CPYTHON_BUILDDIR }}/config.cache
295-
key: ${{ github.job }}-${{ runner.os }}-${{ needs.check_source.outputs.config_hash }}
296-
- name: Configure CPython out-of-tree
297-
working-directory: ${{ env.CPYTHON_BUILDDIR }}
298-
run: |
253+
uses: ./.github/workflows/reusable-build-ubuntu.yml
254+
with:
255+
config_hash: ${{ needs.check_source.outputs.config_hash }}
256+
options: |
299257
../cpython-ro-srcdir/configure \
300258
--config-cache \
301259
--with-pydebug \
302260
--with-openssl=$OPENSSL_DIR
303-
- name: Build CPython out-of-tree
304-
working-directory: ${{ env.CPYTHON_BUILDDIR }}
305-
run: make -j4
306-
- name: Display build info
307-
working-directory: ${{ env.CPYTHON_BUILDDIR }}
308-
run: make pythoninfo
309-
- name: Remount sources writable for tests
310-
# some tests write to srcdir, lack of pyc files slows down testing
311-
run: sudo mount $CPYTHON_RO_SRCDIR -oremount,rw
312-
- name: Tests
313-
working-directory: ${{ env.CPYTHON_BUILDDIR }}
314-
run: xvfb-run make test
261+
262+
build_ubuntu_free_threaded:
263+
name: 'Ubuntu (free-threaded)'
264+
needs: check_source
265+
if: needs.check_source.outputs.run_tests == 'true' && contains(github.event.pull_request.labels.*.name, 'topic-free-threaded')
266+
uses: ./.github/workflows/reusable-build-ubuntu.yml
267+
with:
268+
config_hash: ${{ needs.check_source.outputs.config_hash }}
269+
options: |
270+
../cpython-ro-srcdir/configure \
271+
--config-cache \
272+
--with-pydebug \
273+
--with-openssl=$OPENSSL_DIR \
274+
--disable-gil
315275
316276
build_ubuntu_ssltests:
317277
name: 'Ubuntu SSL tests with OpenSSL'
@@ -582,6 +542,7 @@ jobs:
582542
- build_win_arm64
583543
- build_macos
584544
- build_ubuntu
545+
- build_ubuntu_free_threaded
585546
- build_ubuntu_ssltests
586547
- test_hypothesis
587548
- build_asan
@@ -595,6 +556,7 @@ jobs:
595556
with:
596557
allowed-failures: >-
597558
build_macos,
559+
build_ubuntu_free_threaded,
598560
build_ubuntu_ssltests,
599561
build_win32,
600562
build_win_arm64,
@@ -617,6 +579,7 @@ jobs:
617579
build_win_arm64,
618580
build_macos,
619581
build_ubuntu,
582+
build_ubuntu_free_threaded,
620583
build_ubuntu_ssltests,
621584
build_asan,
622585
'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
config_hash:
5+
required: true
6+
type: string
7+
options:
8+
required: true
9+
type: string
10+
11+
jobs:
12+
build_ubuntu_reusable:
13+
timeout-minutes: 60
14+
runs-on: ubuntu-20.04
15+
env:
16+
OPENSSL_VER: 3.0.11
17+
PYTHONSTRICTEXTENSIONBUILD: 1
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Register gcc problem matcher
21+
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
22+
- name: Install dependencies
23+
run: sudo ./.github/workflows/posix-deps-apt.sh
24+
- name: Configure OpenSSL env vars
25+
run: |
26+
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> $GITHUB_ENV
27+
echo "OPENSSL_DIR=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}" >> $GITHUB_ENV
28+
echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV
29+
- name: 'Restore OpenSSL build'
30+
id: cache-openssl
31+
uses: actions/cache@v3
32+
with:
33+
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
34+
key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
35+
- name: Install OpenSSL
36+
if: steps.cache-openssl.outputs.cache-hit != 'true'
37+
run: python3 Tools/ssl/multissltests.py --steps=library --base-directory $MULTISSL_DIR --openssl $OPENSSL_VER --system Linux
38+
- name: Add ccache to PATH
39+
run: |
40+
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
41+
- name: Configure ccache action
42+
uses: hendrikmuhs/ccache-action@v1.2
43+
- name: Setup directory envs for out-of-tree builds
44+
run: |
45+
echo "CPYTHON_RO_SRCDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-ro-srcdir)" >> $GITHUB_ENV
46+
echo "CPYTHON_BUILDDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-builddir)" >> $GITHUB_ENV
47+
- name: Create directories for read-only out-of-tree builds
48+
run: mkdir -p $CPYTHON_RO_SRCDIR $CPYTHON_BUILDDIR
49+
- name: Bind mount sources read-only
50+
run: sudo mount --bind -o ro $GITHUB_WORKSPACE $CPYTHON_RO_SRCDIR
51+
- name: Restore config.cache
52+
uses: actions/cache@v3
53+
with:
54+
path: ${{ env.CPYTHON_BUILDDIR }}/config.cache
55+
key: ${{ github.job }}-${{ runner.os }}-${{ inputs.config_hash }}
56+
- name: Configure CPython out-of-tree
57+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
58+
run: ${{ inputs.options }}
59+
- name: Build CPython out-of-tree
60+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
61+
run: make -j4
62+
- name: Display build info
63+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
64+
run: make pythoninfo
65+
- name: Remount sources writable for tests
66+
# some tests write to srcdir, lack of pyc files slows down testing
67+
run: sudo mount $CPYTHON_RO_SRCDIR -oremount,rw
68+
- name: Tests
69+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
70+
run: xvfb-run make test

0 commit comments

Comments
 (0)