mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-22 00:14:55 -05:00
improve build workflow (#56614)
* improve build workflow use upstream cache save/restore actions simplify the build cache saving since we only save build cache on push use native docker action * login on push only * fix tags * fix login * fix tag * do not push local tags * correctly setup ccache * define compiler * fix docker tags * remove personal branch
This commit is contained in:
parent
21e7a107cf
commit
bc080cad16
@ -35,16 +35,11 @@ pushd ${CTEST_BUILD_DIR} > /dev/null
|
|||||||
echo "${bold}Running cmake...${endbold}"
|
echo "${bold}Running cmake...${endbold}"
|
||||||
echo "::group::cmake"
|
echo "::group::cmake"
|
||||||
|
|
||||||
if [[ -f "/usr/lib64/ccache/clang" ]]; then
|
|
||||||
export CC=/usr/lib64/ccache/clang
|
|
||||||
export CXX=/usr/lib64/ccache/clang++
|
|
||||||
else
|
|
||||||
export CC=/usr/lib/ccache/clang
|
|
||||||
export CXX=/usr/lib/ccache/clang++
|
|
||||||
fi
|
|
||||||
|
|
||||||
BUILD_TYPE=Release
|
BUILD_TYPE=Release
|
||||||
|
|
||||||
|
export CC=/usr/bin/clang
|
||||||
|
export CXX=/usr/bin/clang++
|
||||||
|
|
||||||
if [[ "${WITH_CLAZY}" = "ON" ]]; then
|
if [[ "${WITH_CLAZY}" = "ON" ]]; then
|
||||||
# In release mode, all variables in QgsDebugMsg would be considered unused
|
# In release mode, all variables in QgsDebugMsg would be considered unused
|
||||||
BUILD_TYPE=Debug
|
BUILD_TYPE=Debug
|
||||||
@ -75,7 +70,7 @@ fi
|
|||||||
cmake \
|
cmake \
|
||||||
-GNinja \
|
-GNinja \
|
||||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||||
-DUSE_CCACHE=OFF \
|
-DUSE_CCACHE=ON \
|
||||||
-DBUILD_WITH_QT6=${BUILD_WITH_QT6} \
|
-DBUILD_WITH_QT6=${BUILD_WITH_QT6} \
|
||||||
-DWITH_DESKTOP=ON \
|
-DWITH_DESKTOP=ON \
|
||||||
-DWITH_ANALYSIS=ON \
|
-DWITH_ANALYSIS=ON \
|
||||||
|
|||||||
133
.github/workflows/run-tests.yml
vendored
133
.github/workflows/run-tests.yml
vendored
@ -33,8 +33,6 @@ permissions:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
env:
|
env:
|
||||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
QGIS_WORKSPACE: ${{ github.workspace }} # used in docker compose
|
QGIS_WORKSPACE: ${{ github.workspace }} # used in docker compose
|
||||||
RUN_FLAKY_TESTS: ${{ contains( github.event.pull_request.labels.*.name, 'run flaky tests') }}
|
RUN_FLAKY_TESTS: ${{ contains( github.event.pull_request.labels.*.name, 'run flaky tests') }}
|
||||||
|
|
||||||
@ -47,7 +45,6 @@ jobs:
|
|||||||
- distro-version: '22.04'
|
- distro-version: '22.04'
|
||||||
qt-version: 5
|
qt-version: 5
|
||||||
run-tests: true
|
run-tests: true
|
||||||
docker-tag-suffix: ''
|
|
||||||
with-qt6: OFF
|
with-qt6: OFF
|
||||||
with-qt5: ON
|
with-qt5: ON
|
||||||
with-3d: ON
|
with-3d: ON
|
||||||
@ -64,7 +61,6 @@ jobs:
|
|||||||
- distro-version: '39'
|
- distro-version: '39'
|
||||||
qt-version: 6
|
qt-version: 6
|
||||||
run-tests: true
|
run-tests: true
|
||||||
docker-tag-suffix: ''
|
|
||||||
with-qt6: ON
|
with-qt6: ON
|
||||||
with-qt5: OFF
|
with-qt5: OFF
|
||||||
with-3d: ON
|
with-3d: ON
|
||||||
@ -107,7 +103,7 @@ jobs:
|
|||||||
GITHUB_PR_NUMBER: ${{github.event.number}}
|
GITHUB_PR_NUMBER: ${{github.event.number}}
|
||||||
run: |
|
run: |
|
||||||
# Be aware that these instructions are duplicated in run-tests job
|
# Be aware that these instructions are duplicated in run-tests job
|
||||||
DOCKER_TAG=$(echo $( [[ ${GITHUB_EVENT_NAME} == pull_request ]] && echo ${GITHUB_BASE_REF} || echo ${GITHUB_REF##*/} ) | sed 's/^master$/latest/')${{ matrix.docker-tag-suffix }}
|
DOCKER_TAG=$(echo $( [[ ${GITHUB_EVENT_NAME} == pull_request ]] && echo ${GITHUB_BASE_REF} || echo ${GITHUB_REF##*/} ) | sed 's/^master$/latest/')
|
||||||
CTEST_BUILD_NAME=$( [[ ${GITHUB_EVENT_NAME} == pull_request ]] && echo "PR${GITHUB_PR_NUMBER}" || echo ${GITHUB_REF##*/} )"_${GITHUB_SHA}"
|
CTEST_BUILD_NAME=$( [[ ${GITHUB_EVENT_NAME} == pull_request ]] && echo "PR${GITHUB_PR_NUMBER}" || echo ${GITHUB_REF##*/} )"_${GITHUB_SHA}"
|
||||||
echo "DOCKER_TAG=${DOCKER_TAG}" >> $GITHUB_ENV
|
echo "DOCKER_TAG=${DOCKER_TAG}" >> $GITHUB_ENV
|
||||||
echo "CTEST_BUILD_NAME=${CTEST_BUILD_NAME}" >> $GITHUB_ENV
|
echo "CTEST_BUILD_NAME=${CTEST_BUILD_NAME}" >> $GITHUB_ENV
|
||||||
@ -119,57 +115,35 @@ jobs:
|
|||||||
echo CTEST_BUILD_NAME: ${CTEST_BUILD_NAME}
|
echo CTEST_BUILD_NAME: ${CTEST_BUILD_NAME}
|
||||||
echo QT_VERSION: ${QT_VERSION}
|
echo QT_VERSION: ${QT_VERSION}
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
if: ${{ github.event_name == 'push' }}
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Build Docker Container with Build Environment
|
- name: Build Docker Container with Build Environment
|
||||||
id: docker-build
|
id: docker-build
|
||||||
uses: whoan/docker-build-with-cache-action@v8
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
username: ${{ github.actor }}
|
context: .
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
file: .docker/qgis3-qt${{ matrix.qt-version }}-build-deps.dockerfile
|
||||||
registry: ghcr.io
|
tags: qgis/qgis3-build-deps-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}:${{ github.event.pull_request.head.ref || github.ref_name }}
|
||||||
image_name: qgis3-build-deps-${{ matrix.distro-version }}
|
push: ${{ github.event_name == 'push' }}
|
||||||
dockerfile: .docker/qgis3-qt${{ matrix.qt-version }}-build-deps.dockerfile
|
pull: true
|
||||||
build_extra_args: "--build-arg=DISTRO_VERSION=${{ matrix.distro-version }}"
|
build-args:
|
||||||
push_git_tag: true
|
DISTRO_VERSION=${{ matrix.distro-version }}
|
||||||
push_image_and_stages: on:push
|
|
||||||
pull_image_and_stages: ${{ github.event_name != 'workflow_dispatch' }}
|
|
||||||
|
|
||||||
- name: Tag image
|
- name: Tag image
|
||||||
run: |
|
run: docker tag ${{ steps.docker-build.outputs.imageid }} qgis3-build-deps
|
||||||
docker tag ${DOCKER_IMAGE} qgis3-build-deps
|
|
||||||
env:
|
|
||||||
DOCKER_IMAGE: ${{ steps.docker-build.outputs.FULL_IMAGE_NAME }}
|
|
||||||
|
|
||||||
- name: Push Qt5 deps image to Docker hub
|
- name: Restore build cache
|
||||||
if: ${{ github.repository_owner == 'qgis' && github.event_name != 'pull_request' && matrix.qt-version == '5' }}
|
uses: actions/cache/restore@v3
|
||||||
run: |
|
|
||||||
docker tag qgis3-build-deps qgis/qgis3-build-deps:${DOCKER_TAG}
|
|
||||||
docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}"
|
|
||||||
docker push "qgis/qgis3-build-deps:${DOCKER_TAG}"
|
|
||||||
|
|
||||||
- name: Prepare build cache for pull request
|
|
||||||
uses: pat-s/always-upload-cache@v3.0.11
|
|
||||||
if: github.event_name == 'pull_request'
|
|
||||||
with:
|
with:
|
||||||
path: /home/runner/QGIS/.ccache
|
path: /home/runner/QGIS/.ccache
|
||||||
key: build-ccache-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}-${{ github.actor }}-${{ github.head_ref }}-${{ github.sha }}
|
key: build-ccache-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}-${{ github.event.pull_request.head.ref || github.ref_name }}
|
||||||
# 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: |
|
restore-keys: |
|
||||||
build-ccache-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}-${{ github.actor }}-${{ github.head_ref }}-
|
build-ccache-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}-master
|
||||||
build-ccache-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}-refs/heads/${{ github.base_ref }}-
|
|
||||||
build-ccache-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}-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@v3.0.11
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
with:
|
|
||||||
path: /home/runner/QGIS/.ccache
|
|
||||||
# The branch or tag ref that triggered the workflow run. For branches this in the format refs/heads/<branch_name>, and for tags it is refs/tags/<tag_name>
|
|
||||||
key: build-ccache-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}-${{ github.ref }}-${{ github.sha }}
|
|
||||||
restore-keys: |
|
|
||||||
build-ccache-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}-${{ github.ref }}-
|
|
||||||
build-ccache-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}-refs/heads/master-
|
|
||||||
|
|
||||||
- name: Compile QGIS
|
- name: Compile QGIS
|
||||||
id: compile
|
id: compile
|
||||||
@ -178,6 +152,7 @@ jobs:
|
|||||||
-v $(pwd):/root/QGIS \
|
-v $(pwd):/root/QGIS \
|
||||||
-v /home/runner/QGIS/.ccache:/root/.ccache \
|
-v /home/runner/QGIS/.ccache:/root/.ccache \
|
||||||
--env-file .docker/docker-variables.env \
|
--env-file .docker/docker-variables.env \
|
||||||
|
--env CCACHE_DIR=/root/.ccache \
|
||||||
--env PUSH_TO_CDASH=true \
|
--env PUSH_TO_CDASH=true \
|
||||||
--env WITH_QT5=${{ matrix.with-qt5 }} \
|
--env WITH_QT5=${{ matrix.with-qt5 }} \
|
||||||
--env BUILD_WITH_QT6=${{ matrix.with-qt6 }} \
|
--env BUILD_WITH_QT6=${{ matrix.with-qt6 }} \
|
||||||
@ -193,6 +168,13 @@ jobs:
|
|||||||
qgis3-build-deps \
|
qgis3-build-deps \
|
||||||
/root/QGIS/.docker/docker-qgis-build.sh
|
/root/QGIS/.docker/docker-qgis-build.sh
|
||||||
|
|
||||||
|
- name: Save build cache for push only
|
||||||
|
uses: actions/cache/save@v3
|
||||||
|
if: ${{ github.event_name == 'push' }}
|
||||||
|
with:
|
||||||
|
path: /home/runner/QGIS/.ccache
|
||||||
|
key: build-ccache-${{ matrix.distro-version }}-qt${{ matrix.qt-version }}-${{ github.ref }}
|
||||||
|
|
||||||
- name: Push artifact
|
- name: Push artifact
|
||||||
id: push_artifact
|
id: push_artifact
|
||||||
if: ${{ matrix.run-tests }}
|
if: ${{ matrix.run-tests }}
|
||||||
@ -301,8 +283,6 @@ jobs:
|
|||||||
run-tests:
|
run-tests:
|
||||||
name: Run tests
|
name: Run tests
|
||||||
env:
|
env:
|
||||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
QGIS_WORKSPACE: ${{ github.workspace }} # used in docker compose
|
QGIS_WORKSPACE: ${{ github.workspace }} # used in docker compose
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -366,25 +346,28 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo CTEST_BUILD_NAME: ${CTEST_BUILD_NAME}
|
echo CTEST_BUILD_NAME: ${CTEST_BUILD_NAME}
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
if: ${{ github.event_name == 'push' }}
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Build Docker Container with Testing Environment
|
- name: Build Docker Container with Testing Environment
|
||||||
id: docker-build
|
id: docker-build
|
||||||
uses: whoan/docker-build-with-cache-action@v8
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
username: ${{ github.actor }}
|
context: .
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
file: .docker/qgis3-qt${{ matrix.qt-version }}-build-deps.dockerfile
|
||||||
registry: ghcr.io
|
tags: qgis/qgis3-qt${{ matrix.qt-version }}-build-deps-bin-only:${{ github.event.pull_request.head.ref || github.ref_name }}
|
||||||
image_name: qgis3-qt${{ matrix.qt-version }}-build-deps-bin-only
|
push: ${{ github.event_name == 'push' }}
|
||||||
dockerfile: .docker/qgis3-qt${{ matrix.qt-version }}-build-deps.dockerfile
|
pull: true
|
||||||
build_extra_args: "--target ${{ matrix.docker-target }} --build-arg=DISTRO_VERSION=${{ matrix.distro-version }}"
|
target: ${{ matrix.docker-target }}
|
||||||
push_git_tag: true
|
build-args:
|
||||||
push_image_and_stages: on:push
|
DISTRO_VERSION=${{ matrix.distro-version }}
|
||||||
pull_image_and_stages: ${{ github.event_name != 'workflow_dispatch' }}
|
|
||||||
|
|
||||||
- name: Tag image
|
- name: Tag image
|
||||||
run: |
|
run: docker tag ${{ steps.docker-build.outputs.imageid }} qgis3-build-deps-binary-image
|
||||||
docker tag ${DOCKER_IMAGE} qgis3-build-deps-binary-image
|
|
||||||
env:
|
|
||||||
DOCKER_IMAGE: ${{ steps.docker-build.outputs.FULL_IMAGE_NAME }}
|
|
||||||
|
|
||||||
- name: Print disk space
|
- name: Print disk space
|
||||||
run: |
|
run: |
|
||||||
@ -476,23 +459,19 @@ jobs:
|
|||||||
|
|
||||||
- name: Build Docker Container with Testing Environment
|
- name: Build Docker Container with Testing Environment
|
||||||
id: docker-build
|
id: docker-build
|
||||||
uses: whoan/docker-build-with-cache-action@v8
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
username: ${{ github.actor }}
|
context: .
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
file: .docker/qgis3-qt${{ matrix.qt-version }}-build-deps.dockerfile
|
||||||
registry: ghcr.io
|
tags: qgis/qgis3-qt${{ matrix.qt-version }}-build-deps-bin-only:${{ github.event.pull_request.head.ref || github.ref_name }}
|
||||||
image_name: qgis3-qt${{ matrix.qt-version }}-build-deps-bin-only
|
push: ${{ github.event_name == 'push' }}
|
||||||
dockerfile: .docker/qgis3-qt${{ matrix.qt-version }}-build-deps.dockerfile
|
pull: true
|
||||||
build_extra_args: "--build-arg=DISTRO_VERSION=${{ matrix.distro-version }}"
|
target: ${{ matrix.docker-target }}
|
||||||
push_git_tag: true
|
build-args:
|
||||||
push_image_and_stages: on:push
|
DISTRO_VERSION=${{ matrix.distro-version }}
|
||||||
pull_image_and_stages: ${{ github.event_name != 'workflow_dispatch' }}
|
|
||||||
|
|
||||||
- name: Tag image
|
- name: Tag image
|
||||||
run: |
|
run: docker tag ${{ steps.docker-build.outputs.imageid }} qgis3-build-deps-binary-image
|
||||||
docker tag ${DOCKER_IMAGE} qgis3-build-deps
|
|
||||||
env:
|
|
||||||
DOCKER_IMAGE: ${{ steps.docker-build.outputs.FULL_IMAGE_NAME }}
|
|
||||||
|
|
||||||
- name: Download build artifact
|
- name: Download build artifact
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user