From 06e2ebfea4f3e8da38218644a15e170539912efb Mon Sep 17 00:00:00 2001 From: Bruno Lopes Date: Sat, 24 Jan 2026 10:05:01 -0300 Subject: [PATCH] gitlab-ci, build/macos: Add caching to MacPorts builds This makes the macOS builds way faster (aprox. 1hr instead of 3.5hr) thanks to local caching of GNOME runner. We, however, still need to split them since the timeout is relatively small on such runner. --- .gitlab-ci.yml | 18 +++++++++++++++--- build/macos/1_build-deps-macports.sh | 23 +++++++++++++++-------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6e6185695e..9d0b6cdae5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -683,17 +683,24 @@ gimp-win-eol: - printf "\e[0Ksection_end:`date +%s`:macos_environ\r\e[0K\n" deps-macos-inhouse-part1: + #This splitted job is needed to rebuild 'vala' in time when it is bumped extends: .macos-inhouse stage: dependencies + cache: + - key: $CI_PROJECT_NAMESPACE + paths: + - macports-cached + policy: pull script: # Do not call sh since it is old bash on macOS, not the default zsh - zsh build/macos/1_build-deps-macports.sh --part1 artifacts: paths: - - macports.tar.gz + - macports expire_in: 2 hours deps-macos-inhouse-part2: + #This splitted job is needed to rebuild 'rust' in time when it is bumped extends: .macos-inhouse needs: ["deps-macos-inhouse-part1"] stage: dependencies @@ -702,7 +709,7 @@ deps-macos-inhouse-part2: - zsh build/macos/1_build-deps-macports.sh --part2 artifacts: paths: - - macports.tar.gz + - macports expire_in: 2 hours deps-macos-inhouse: @@ -712,12 +719,17 @@ deps-macos-inhouse: #to allow running the Homebrew builds which use precompiled binaries optional: true stage: dependencies + cache: + - key: $CI_PROJECT_NAMESPACE + paths: + - macports-cached + policy: push script: # Do not call sh since it is old bash on macOS, not the default zsh - zsh build/macos/1_build-deps-macports.sh artifacts: paths: - - macports.tar.gz + - macports - _install-* # The full build dir is needed due to its .o for .dSYM creation on next job - babl/_build-* diff --git a/build/macos/1_build-deps-macports.sh b/build/macos/1_build-deps-macports.sh index f42a0fa2e0..31db07b548 100644 --- a/build/macos/1_build-deps-macports.sh +++ b/build/macos/1_build-deps-macports.sh @@ -38,21 +38,28 @@ fi #End of config printf "\e[0Ksection_start:`date +%s`:deps_install[collapsed=true]\r\e[0KInstalling dependencies provided by $( [ -f "$OPT_PREFIX/bin/port" ] && echo MacPorts || echo Homebrew )\n" if [ -f "$OPT_PREFIX/bin/port" ]; then eval $( [ "$OPT_PREFIX" = /opt/local ] && echo sudo ) port sync && eval $( [ "$OPT_PREFIX" = /opt/local ] && echo sudo ) port upgrade outdated - if [ -f 'macports.tar.gz' ]; then - bsdtar xf macports.tar.gz -C / || true + if [ "$CI_JOB_NAME" ] && ls -d macports* 2>/dev/null | grep -q .; then + if echo "$CI_JOB_NAME" | grep -q 'part1' && [ -d 'macports-cached' ]; then + cp -fa macports-cached/* $OPT_PREFIX/var/macports || true + elif [ -d 'macports' ]; then + cp -fa macports/* $OPT_PREFIX/var/macports || true + fi + eval $( [ "$OPT_PREFIX" = /opt/local ] && echo sudo ) port deactivate -fN installed fi - if [ "$1" = '--part1' ]; then + if echo "$CI_JOB_NAME" | grep -q 'part1'; then eval $( [ "$OPT_PREFIX" = /opt/local ] && echo sudo ) port install -N $(grep -v '^#' build/macos/all-deps-uni.txt | sed 's/|homebrew:[^ ]*//g' | tr -d '\' | awk '{print} /vala/{exit}' | xargs) - elif [ "$1" = '--part2' ]; then + elif echo "$CI_JOB_NAME" | grep -q 'part2'; then eval $( [ "$OPT_PREFIX" = /opt/local ] && echo sudo ) port install -N $(grep -v '^#' build/macos/all-deps-uni.txt | sed 's/|homebrew:[^ ]*//g' | tr -d '\' | awk '{print} /appstream/{exit}' | xargs) else eval $( [ "$OPT_PREFIX" = /opt/local ] && echo sudo ) port install -N $(grep -v '^#' build/macos/all-deps-uni.txt | sed 's/|homebrew:[^ ]*//g' | tr -d '\' | xargs) fi if echo "$CI_JOB_NAME" | grep -q 'deps'; then - bsdtar -cf macports.tar.gz --gzip "$OPT_PREFIX" || true - fi - if echo "$1" | grep -q 'part'; then - exit 0 + cp -fa $OPT_PREFIX/var/macports . || true + if echo "$CI_JOB_NAME" | grep -q 'part'; then + exit 0 + elif [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then + cp -fa macports macports-cached || true + fi fi git apply -v build/macos/patches/0001-meson-Patch-python-version.patch || true else