From 15272335f8bdb5e811174e598f6c73c466c74e88 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sat, 31 Jul 2021 14:00:36 +0200 Subject: [PATCH] ci: use cache for OpenSSL build --- .github/workflows/build.yml | 7 ++ .gitignore | 3 + pyproject.toml | 1 + .../manylinux-build-and-install-openssl.sh | 73 +++++++++++-------- 4 files changed, 53 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9754a7b0..1303d0352 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,6 +73,13 @@ jobs: uses: docker/setup-qemu-action@v1.2.0 if: matrix.use_qemu && fromJSON(env.USE_QEMU) + - name: Cache OpenSSL build + if: runner.os == 'Linux' + uses: actions/cache@v2 + with: + path: .cache-openssl + key: ${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles('scripts/manylinux-build-and-install-openssl.sh') }} + - name: Build wheels uses: pypa/cibuildwheel@v2.1.1 if: (!matrix.use_qemu) || fromJSON(env.USE_QEMU) diff --git a/.gitignore b/.gitignore index 18f666f1c..ddc3869ab 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,6 @@ docs/_build # IDE junk .idea/* *.swp + +# OpenSSL build cache +.cache-openssl/ diff --git a/pyproject.toml b/pyproject.toml index 37b9a89a8..2e2453040 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,7 @@ before-all = [ [tool.cibuildwheel.linux.environment] SKBUILD_CONFIGURE_OPTIONS = "-DOPENSSL_ROOT_DIR:PATH=/usr/local/ssl -DCMAKE_JOB_POOL_COMPILE:STRING=compile -DCMAKE_JOB_POOL_LINK:STRING=link -DCMAKE_JOB_POOLS:STRING=compile=2;link=1" +OPENSSL_CACHE_DIR = "home/runner/work/cmake-python-distributions/cmake-python-distributions/.cache-openssl" [tool.cibuildwheel.macos.environment] MACOSX_DEPLOYMENT_TARGET = "10.10" diff --git a/scripts/manylinux-build-and-install-openssl.sh b/scripts/manylinux-build-and-install-openssl.sh index ba30049b5..dd9b97ea1 100755 --- a/scripts/manylinux-build-and-install-openssl.sh +++ b/scripts/manylinux-build-and-install-openssl.sh @@ -14,42 +14,53 @@ OPENSSL_ROOT=openssl-1.1.1l # Hash from https://www.openssl.org/source/openssl-1.1.1l.tar.gz.sha256 OPENSSL_HASH=0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1 -cd /tmp +OPENSSL_ARCHIVE=/host/${OPENSSL_CACHE_DIR}/${OPENSSL_ROOT}-${AUDITWHEEL_PLAT}.tar.gz -if ! perl -e 'use 5.10.0' &> /dev/null; then - # perl>=5.10.0 is needed to build openssl - PERL_ROOT=perl-5.32.1 - # Hash from https://www.cpan.org/src/5.0/perl-5.32.1.tar.gz.sha256.txt - PERL_HASH=03b693901cd8ae807231b1787798cf1f2e0b8a56218d07b7da44f784a7caeb2c - curl -fsSLO https://www.cpan.org/src/5.0/${PERL_ROOT}.tar.gz - check_sha256sum ${PERL_ROOT}.tar.gz ${PERL_HASH} - tar -xzf ${PERL_ROOT}.tar.gz - rm -rf ${PERL_ROOT}.tar.gz +if ! [ -e "${OPENSSL_ARCHIVE}" ]; then + cd /tmp - pushd ${PERL_ROOT} - ./Configure -des -Dprefix=/tmp/perl-openssl > /dev/null - make -j$(nproc) > /dev/null - make install > /dev/null - popd - export PATH=/tmp/perl-openssl/bin:${PATH} -fi + if ! perl -e 'use 5.10.0' &> /dev/null; then + # perl>=5.10.0 is needed to build openssl + PERL_ROOT=perl-5.32.1 + # Hash from https://www.cpan.org/src/5.0/perl-5.32.1.tar.gz.sha256.txt + PERL_HASH=03b693901cd8ae807231b1787798cf1f2e0b8a56218d07b7da44f784a7caeb2c + + curl -fsSLO https://www.cpan.org/src/5.0/${PERL_ROOT}.tar.gz + check_sha256sum ${PERL_ROOT}.tar.gz ${PERL_HASH} + tar -xzf ${PERL_ROOT}.tar.gz + rm -rf ${PERL_ROOT}.tar.gz + + pushd ${PERL_ROOT} + ./Configure -des -Dprefix=/tmp/perl-openssl > /dev/null + make -j$(nproc) > /dev/null + make install > /dev/null + popd + export PATH=/tmp/perl-openssl/bin:${PATH} + fi -# Download -curl -fsSLO http://www.openssl.org/source/${OPENSSL_ROOT}.tar.gz -check_sha256sum ${OPENSSL_ROOT}.tar.gz ${OPENSSL_HASH} -tar -xzf ${OPENSSL_ROOT}.tar.gz -rm -rf ${OPENSSL_ROOT}.tar.gz + # Download + curl -fsSLO http://www.openssl.org/source/${OPENSSL_ROOT}.tar.gz + check_sha256sum ${OPENSSL_ROOT}.tar.gz ${OPENSSL_HASH} + tar -xzf ${OPENSSL_ROOT}.tar.gz + rm -rf ${OPENSSL_ROOT}.tar.gz -# Configure -pushd ${OPENSSL_ROOT} -./config no-shared -fPIC --prefix=/usr/local/ssl --openssldir=/usr/local/ssl > /dev/null + # Configure + pushd ${OPENSSL_ROOT} + ./config no-shared -fPIC --prefix=/usr/local/ssl --openssldir=/usr/local/ssl > /dev/null -# Build -make -j$(nproc) > /dev/null + # Build + make -j$(nproc) > /dev/null + + # Install + make install_sw DESTDIR=/tmp/${OPENSSL_ROOT}-root > /dev/null + + # Create cache archive + mkdir -p "$(dirname ${OPENSSL_ARCHIVE})" + tar -C /tmp/${OPENSSL_ROOT}-root -czf "${OPENSSL_ARCHIVE}" usr -# Install -make install_sw > /dev/null + popd + rm -rf ${OPENSSL_ROOT} +fi -popd -rm -rf ${OPENSSL_ROOT} +tar -C / -xf "${OPENSSL_ARCHIVE}"