From 4fc02733cb7bdf517eb5845f2883e04ef2e6f428 Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Wed, 17 Feb 2021 11:07:39 +0100 Subject: [PATCH] cache mxe builds (#41472) --- .github/workflows/mxe.yml | 48 +++++++++++++++++++++++++++++++++-- ms-windows/mxe/build-mxe.sh | 16 +++++++++--- ms-windows/mxe/build.sh | 11 -------- ms-windows/mxe/mxe.Dockerfile | 3 ++- 4 files changed, 60 insertions(+), 18 deletions(-) delete mode 100755 ms-windows/mxe/build.sh diff --git a/.github/workflows/mxe.yml b/.github/workflows/mxe.yml index c624b7cc48e..e60559f57c7 100644 --- a/.github/workflows/mxe.yml +++ b/.github/workflows/mxe.yml @@ -29,14 +29,58 @@ on: jobs: build: + env: + CCACHE_DIR: ${{ github.workspace }}/.ccache + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + + - name: Build Dockerfile + run: | + cd ms-windows/mxe + docker build -f mxe.Dockerfile --tag mxe-qt5-builder:current . + + - name: Prepare build cache for pull request + uses: pat-s/always-upload-cache@v2.1.3 + if: github.event_name == 'pull_request' + with: + path: ${{ github.workspace }}/.ccache + key: mxe-ccache-${{ github.actor }}-${{ github.head_ref }}-${{ github.sha }} + # The head_ref or source branch of the pull request in a workflow run. + # The base_ref or target branch of the pull request in a workflow run. + restore-keys: | + mxe-ccache-${{ github.actor }}-${{ github.head_ref }}- + mxe-ccache-${{ github.base_ref }}- + mxe-ccache-refs/heads/master- + + - name: Prepare build cache for branch/tag + # use a fork of actions/cache@v2 to upload cache even when the build or test failed + uses: pat-s/always-upload-cache@v2.1.3 + if: github.event_name != 'pull_request' + with: + path: ${{ github.workspace }}/.ccache + # The branch or tag ref that triggered the workflow run. For branches this in the format refs/heads/, and for tags it is refs/tags/ + key: mxe-ccache-${{ github.ref }}-${{ github.sha }} + restore-keys: | + mxe-ccache-${{ github.ref }}- + mxe-ccache-refs/heads/master- + - name: Cross build with MXE - run: cd $GITHUB_WORKSPACE && ms-windows/mxe/build.sh + run: | + mkdir -p ${{ github.workspace }}/.ccache + docker run -v ${GITHUB_WORKSPACE}:/root/QGIS \ + -w /root/QGIS \ + --env CCACHE_DIR=/root/QGIS/.ccache \ + mxe-qt5-builder:current \ + /root/QGIS/ms-windows/mxe/build-mxe.sh + - name: Rename artifact - run: cd $GITHUB_WORKSPACE && mv qgis-mxe-release-*.zip qgis-mxe-release.zip + run: | + cd $GITHUB_WORKSPACE + mv qgis-mxe-release-*.zip qgis-mxe-release.zip + - name: Upload build uses: actions/upload-artifact@v2.2.2 with: diff --git a/ms-windows/mxe/build-mxe.sh b/ms-windows/mxe/build-mxe.sh index 4b82a520fb4..a70557b38a7 100755 --- a/ms-windows/mxe/build-mxe.sh +++ b/ms-windows/mxe/build-mxe.sh @@ -50,9 +50,6 @@ TARGET=x86_64-w64-mingw32.shared # Set base path for all tools export PATH=${PATH}:${MXE}/usr/bin -# Fix CCACHE directory -export CCACHE_DIR=${PWD}/.ccache - if [ ! -e ${CCACHE_DIR} ]; then mkdir -p ${CCACHE_DIR} fi @@ -73,9 +70,12 @@ cd ${BUILD_DIR} if [[ "$COMMAND" != *"package"* ]]; then + echo "::group::compile QGIS" + ${MXE}/usr/bin/${TARGET}-cmake .. \ -DCMAKE_BUILD_TYPE=RelWithDebugInfo \ -DCMAKE_INSTALL_PREFIX=${RELEASE_DIR} \ + -DUSE_CCACHE=ON \ -DENABLE_TESTS=OFF \ -DWITH_QSPATIALITE=ON \ -DWITH_APIDOC=OFF \ @@ -90,8 +90,15 @@ if [[ "$COMMAND" != *"package"* ]]; then make -j16 install + echo "::endgroup::" + + #echo "ccache statistics" + ccache -s + fi +echo "::group::package" + # Collect deps $PYDEPLOY --build=${RELEASE_DIR} --objdump=${MXE}/usr/bin/${TARGET}-objdump ${RELEASE_DIR}/qgis.exe @@ -108,7 +115,6 @@ __TXT__ # First cleanup rm -rf ${BUILD_DIR} -rm -rf ${CCACHE_DIR} # Make the zip @@ -119,6 +125,8 @@ zip -r -m ${ZIP_NAME} $(basename ${RELEASE_DIR}) # Second cleanup rm -rf ${RELEASE_DIR} +echo "::endgroup::" + popd echo "Release in $ZIP_NAME ready." diff --git a/ms-windows/mxe/build.sh b/ms-windows/mxe/build.sh deleted file mode 100755 index f20c8e65925..00000000000 --- a/ms-windows/mxe/build.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# Location of current script -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -docker run \ - -v $(pwd):$(pwd) \ - -w $(pwd) --rm \ - --user $(id -u):$(id -g) \ - elpaso/mxe-qt5-builder \ - ${DIR}/build-mxe.sh diff --git a/ms-windows/mxe/mxe.Dockerfile b/ms-windows/mxe/mxe.Dockerfile index 8d20cdf2b50..c5fb18ea8bf 100644 --- a/ms-windows/mxe/mxe.Dockerfile +++ b/ms-windows/mxe/mxe.Dockerfile @@ -10,7 +10,8 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ software-properties-common \ lsb-release \ gpg-agent \ - python3-distutils + python3-distutils \ + ccache RUN apt-key adv \ --keyserver keyserver.ubuntu.com \