From: Shane Synan Date: Mon, 9 Nov 2020 04:21:49 +0000 (-0500) Subject: ci: Workaround macOS hdiutil out of space errors X-Git-Tag: 0.14-rc1~28 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=f09a86ab1cc01a80aa6fd52a875920e18d1d3a5b ci: Workaround macOS hdiutil out of space errors Workaround "hdiutil: create failed - No space left on device" by letting hdiutil auto-detect the required disk space. Keep the old method around via documentation in case this issue arises again. https://stackoverflow.com/questions/18621467/error-creating-disk-image-using-hdutil https://apple.stackexchange.com/questions/156994/yosemite-hdiutil-create-failed-error-5341 https://asmaloney.com/2013/07/howto/packaging-a-mac-os-x-application-using-a-dmg/ https://github.com/autopkg/jps3-recipes/issues/57 Make this issue easier to detect by changing the build script macosx_makePackage.sh to fail early if any individual command fails. This includes fixing up optional parameters to use default values. Re-enable the "Check artifacts" step of the "Post-Build" process now that macOS builds are hopefully more reliable. --- diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 111f51d5..a8bd58dc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -224,7 +224,6 @@ jobs: run: ls -lhR artifacts - name: Check artifacts - continue-on-error: true # macOS packaging is unreliable run: | # Sanity check: We should have exactly 5 files matching the given patterns [[ 5 -eq $(find artifacts/ \( -type f -name 'Quassel*.dmg' -o -name 'quassel*.exe' -o -name 'quassel*.7z' \) -printf '.' | wc -c) ]] diff --git a/scripts/build/macosx_makePackage.sh b/scripts/build/macosx_makePackage.sh index 3c560dde..a359ecd1 100755 --- a/scripts/build/macosx_makePackage.sh +++ b/scripts/build/macosx_makePackage.sh @@ -1,4 +1,7 @@ #!/bin/bash +# Don't consider packaging a success if any commands fail +# See http://redsymbol.net/articles/unofficial-bash-strict-mode/ +set -euo pipefail myname=$0 if [ -s "$myname" ] && [ -x "$myname" ]; then @@ -45,17 +48,18 @@ QUASSEL_VERSION=$(git describe) BUILDTYPE=$1 # check the working dir -WORKINGDIR=$2 -if [[ ! -n $2 ]]; then - WORKINGDIR="." -fi +# Default to "." using Bash default-value syntax +WORKINGDIR="${2:-.}" WORKINGDIR="${WORKINGDIR}/" PACKAGETMPDIR="${WORKINGDIR}PACKAGE_TMP_DIR_${BUILDTYPE}" QUASSEL_DMG="Quassel${BUILDTYPE}_MacOSX-x86_64_${QUASSEL_VERSION}.dmg" -ADDITIONAL_PLUGINS=",$3" -if [[ ! -n $3 ]]; then +# Default to null string +if [[ -z ${3:-} ]]; then ADDITIONAL_PLUGINS="" +else + # Options provided, append to list + ADDITIONAL_PLUGINS=",$3" fi echo "ADDITIONAL_PLUGINS: ${ADDITIONAL_PLUGINS}" @@ -80,6 +84,38 @@ case $BUILDTYPE in exit 1 ;; esac -PACKAGESIZE=$(echo "$(du -ms ${PACKAGETMPDIR} | cut -f1) * 1.1" | bc) -hdiutil create -srcfolder ${PACKAGETMPDIR} -format UDBZ -size ${PACKAGESIZE}M -volname "Quassel ${BUILDTYPE} - ${QUASSEL_VERSION}" "${WORKINGDIR}${QUASSEL_DMG}" >/dev/null + +echo "Creating macOS disk image with hdiutil: 'Quassel ${BUILDTYPE} - ${QUASSEL_VERSION}'" + +# hdiutil seems to have a bit of a reputation for failing to create disk images +# for various reasons. +# +# If you've come here to see why on earth your macOS build is failing despite +# making changes entirely unrelated to macOS, you have my sympathy. +# +# There are two main approaches: +# +# 1. Let hdiutil calculate a size automatically +# +# 2. Separately calculate the size with a margin of error, then specify this +# to hdiutil during disk image creation. +# +# Both seem to have caused issues, but in recent tests, option #1 seemed more +# reliable. +# +# Option 1: + +hdiutil create -srcfolder ${PACKAGETMPDIR} -format UDBZ -volname "Quassel ${BUILDTYPE} - ${QUASSEL_VERSION}" "${WORKINGDIR}${QUASSEL_DMG}" >/dev/null + +# If hdiutil changes over time and fails often, you can try the other option. +# +# Option 2: +# +#PACKAGESIZE_MARGIN="1.1" +#PACKAGESIZE=$(echo "$(du -ms ${PACKAGETMPDIR} | cut -f1) * $PACKAGESIZE_MARGIN" | bc) +#echo "PACKAGESIZE: $PACKAGESIZE MB" +#hdiutil create -srcfolder ${PACKAGETMPDIR} -format UDBZ -size ${PACKAGESIZE}M -volname "Quassel ${BUILDTYPE} - ${QUASSEL_VERSION}" "${WORKINGDIR}${QUASSEL_DMG}" >/dev/null + + +# Regardless of choice, clean up the packaging temporary directory rm -rf ${PACKAGETMPDIR}