From 165b4fe9025607b7b716f08241ee17085a711079 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Fri, 3 Dec 2021 13:38:26 +0100 Subject: [PATCH 1/2] 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 --- .github/workflows/build.yml | 21 ++++++++++++++++--- .../2021-12-03-14-19-16.bpo-45695.QKBn2E.rst | 3 +++ 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Tests/2021-12-03-14-19-16.bpo-45695.QKBn2E.rst diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fe4b14828699c7..fbf7bb6fe2128a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -179,13 +179,28 @@ jobs: echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV - name: Configure ccache action uses: hendrikmuhs/ccache-action@v1 - - name: Configure CPython - run: ./configure --with-pydebug --with-openssl=$OPENSSL_DIR - - name: Build CPython + - name: Setup directory envs for out-of-tree builds + run: | + echo "CPYTHON_RO_SRCDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-ro-srcdir)" >> $GITHUB_ENV + echo "CPYTHON_BUILDDIR=$(realpath -m ${GITHUB_WORKSPACE}/../cpython-builddir)" >> $GITHUB_ENV + - name: Create directories for read-only out-of-tree builds + run: mkdir -p $CPYTHON_RO_SRCDIR $CPYTHON_BUILDDIR + - name: Bind mount sources read-only + run: sudo mount --bind -o ro $GITHUB_WORKSPACE $CPYTHON_RO_SRCDIR + - name: Configure CPython out-of-tree + working-directory: ${{ env.CPYTHON_BUILDDIR }} + run: ../cpython-ro-srcdir/configure --with-pydebug --with-openssl=$OPENSSL_DIR + - name: Build CPython out-of-tree + working-directory: ${{ env.CPYTHON_BUILDDIR }} run: make -j4 - name: Display build info + working-directory: ${{ env.CPYTHON_BUILDDIR }} run: make pythoninfo + - name: Remount sources writable for tests + # some tests write to srcdir, lack of pyc files slows down testing + run: sudo mount $CPYTHON_RO_SRCDIR -oremount,rw - name: Tests + working-directory: ${{ env.CPYTHON_BUILDDIR }} run: xvfb-run make buildbottest TESTOPTS="-j4 -uall,-cpu" build_ubuntu_ssltests: diff --git a/Misc/NEWS.d/next/Tests/2021-12-03-14-19-16.bpo-45695.QKBn2E.rst b/Misc/NEWS.d/next/Tests/2021-12-03-14-19-16.bpo-45695.QKBn2E.rst new file mode 100644 index 00000000000000..e334855d0f6d60 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2021-12-03-14-19-16.bpo-45695.QKBn2E.rst @@ -0,0 +1,3 @@ +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. From 0381848559f28af91f8ec542120f7dc742e441a3 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Fri, 3 Dec 2021 23:16:17 +0100 Subject: [PATCH 2/2] Simplify news entry --- .../next/Tests/2021-12-03-14-19-16.bpo-45695.QKBn2E.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Misc/NEWS.d/next/Tests/2021-12-03-14-19-16.bpo-45695.QKBn2E.rst b/Misc/NEWS.d/next/Tests/2021-12-03-14-19-16.bpo-45695.QKBn2E.rst index e334855d0f6d60..14ecd923dbd553 100644 --- a/Misc/NEWS.d/next/Tests/2021-12-03-14-19-16.bpo-45695.QKBn2E.rst +++ b/Misc/NEWS.d/next/Tests/2021-12-03-14-19-16.bpo-45695.QKBn2E.rst @@ -1,3 +1 @@ -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. +Out-of-tree builds with a read-only source directory are now tested by CI.