Skip to content

Commit 165b4fe

Browse files
committed
bpo-45695: Test out-of-tree builds on GHA
The Ubuntu test runner now configures and compiles CPython out of tree. The source directory is a read-only bind mount to ensure that the build cannot create or modify any files in the source tree. For testing the source directory is re-mounted writable. 15 test modules depend on writable sources and lack of .pyc files slows CI down. Signed-off-by: Christian Heimes <christian@python.org>
1 parent 135ecc3 commit 165b4fe

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,28 @@ jobs:
179179
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
180180
- name: Configure ccache action
181181
uses: hendrikmuhs/ccache-action@v1
182-
- name: Configure CPython
183-
run: ./configure --with-pydebug --with-openssl=$OPENSSL_DIR
184-
- name: Build CPython
182+
- name: Setup directory envs for out-of-tree builds
183+
run: |
184+
echo "CPYTHON_RO_SRCDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-ro-srcdir)" >> $GITHUB_ENV
185+
echo "CPYTHON_BUILDDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-builddir)" >> $GITHUB_ENV
186+
- name: Create directories for read-only out-of-tree builds
187+
run: mkdir -p $CPYTHON_RO_SRCDIR $CPYTHON_BUILDDIR
188+
- name: Bind mount sources read-only
189+
run: sudo mount --bind -o ro $GITHUB_WORKSPACE $CPYTHON_RO_SRCDIR
190+
- name: Configure CPython out-of-tree
191+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
192+
run: ../cpython-ro-srcdir/configure --with-pydebug --with-openssl=$OPENSSL_DIR
193+
- name: Build CPython out-of-tree
194+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
185195
run: make -j4
186196
- name: Display build info
197+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
187198
run: make pythoninfo
199+
- name: Remount sources writable for tests
200+
# some tests write to srcdir, lack of pyc files slows down testing
201+
run: sudo mount $CPYTHON_RO_SRCDIR -oremount,rw
188202
- name: Tests
203+
working-directory: ${{ env.CPYTHON_BUILDDIR }}
189204
run: xvfb-run make buildbottest TESTOPTS="-j4 -uall,-cpu"
190205

191206
build_ubuntu_ssltests:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The Ubuntu test runner now configures and compiles CPython out of tree. The
2+
source directory is a read-only bind mount to ensure that the build cannot
3+
create or modify any files in the source tree.

0 commit comments

Comments
 (0)