GitLab CI: Add a macOS merge request build.

Add an initial "macOS Build" job that uses GitLab's macOS beta.
https://about.gitlab.com/blog/2021/08/23/build-cloud-for-macos-beta/

Add command line options to macos-setup-brew.sh and use it to install
our packages.

Skip running tests for now.
This commit is contained in:
Gerald Combs 2023-02-01 16:38:01 -08:00
parent e93f423504
commit 1bcc5d097d
2 changed files with 170 additions and 16 deletions

View File

@ -183,6 +183,51 @@ variables:
- cd build
needs: []
# macOS runners are still beta:
# https://about.gitlab.com/blog/2021/08/23/build-cloud-for-macos-beta/
# https://docs.gitlab.com/ee/ci/runners/saas/macos/environment.html#vm-images
# https://gitlab.com/gitlab-org/ci-cd/shared-runners/images/macstadium/orka/-/blob/main/toolchain/monterey.yml
.build-macos:
stage: build
tags: [ shared-macos-amd64 ]
image: macos-11-xcode-12 # https://docs.gitlab.com/ee/ci/runners/saas/macos/environment.html
retry: 1
# https://gould.cx/ted/blog/2017/06/10/ccache-for-Gitlab-CI/
cache:
key: ${CI_JOB_NAME}-master
paths:
- ccache/
variables:
HOMEBREW_COLOR: "1"
HOMEBREW_DISPLAY_INSTALL_TIMES: "1"
HOMEBREW_NO_AUTO_UPDATE: "1"
HOMEBREW_NO_INSTALL_CLEANUP: "1"
HOMEBREW_NO_INSTALL_UPGRADE: "1"
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: "1"
before_script:
- printf "\e[0Ksection_start:%s:brew_section[collapsed=true]\r\e[0KInstalling prerequisites" "$( date +%s)"
- ./tools/macos-setup-brew.sh --install-optional
- printf "\e[0Ksection_end:%s:brew_section\r\e[0K" "$( date +%s)"
- export PYTEST_ADDOPTS=--skip-missing-programs=dumpcap,rawshark
- mkdir -p ccache
- ccache --show-stats
- NUM_COMMITS=$(curl $CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID/commits | jq length)
- echo "$NUM_COMMITS commit(s) in this MR"
- mkdir build
- cd build
script:
- printf "\e[0Ksection_start:%s:cmake_section[collapsed=true]\r\e[0KRunning CMake" "$( date +%s)"
- cmake -G Ninja -DENABLE_CCACHE=ON ..
- printf "\e[0Ksection_end:%s:cmake_section\r\e[0K" "$( date +%s)"
- ninja
- ninja test-programs
- ../test/test.py --program-path ./run --disable-capture
after_script:
# The cache should be large enough to be useful but it shouldn't take
# too long to restore+save each run.
- ccache --max-size $( gdu --summarize --block-size=1M "$CI_PROJECT_DIR/build" | awk '{printf ("%dM", $1 * 1.5)}' )
needs: []
Source Package:
extends: .build-ubuntu
stage: .pre
@ -602,6 +647,11 @@ Windows Qt5 Build:
- cmake -G "Visual Studio 17 2022" -A x64 -DUSE_qt6=OFF -DENABLE_LTO=off ..
- msbuild /verbosity:minimal /maxcpucount ui\qt\qtui.vcxproj
macOS Build:
extends: .build-macos
rules: !reference [.if-merge-request]
needs: [ 'Commit Check' ]
# Adapted from https://www.synopsys.com/blogs/software-security/integrating-coverity-scan-with-gitlab-ci/
# and https://gitlab.gnome.org/GNOME/glib/-/blob/8f57a5b9/.gitlab-ci.yml#L481
Coverity GCC Scan:

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Copyright 2014, Evan Huus (See AUTHORS file)
#
# Enhance (2016) by Alexis La Goutte (For use with Travis CI)
@ -9,20 +9,126 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
set -e -u -o pipefail
# Update to last brew release
brew update
if [ -z "$HOMEBREW_NO_AUTO_UPDATE" ] ; then
brew update
fi
# install some libs needed by Wireshark
brew install opus c-ares glib libgcrypt gnutls lua@5.1 cmake python nghttp2 snappy lz4 libxml2 ninja \
libmaxminddb libsmi spandsp brotli minizip zstd libssh libilbc speexdsp gettext pcre2 qt6 "$@"
function print_usage() {
printf "\\nUtility to setup a macOS system for Wireshark Development using Homebrew.\\n"
printf "The basic usage installs the needed software\\n\\n"
printf "Usage: %s [--install-optional] [--install-dmg-deps] [...other options...]\\n" "$0"
printf "\\t--install-optional: install optional software as well\\n"
printf "\\t--install-dmg-deps: install packages required to build the .dmg file\\n"
printf "\\t--install-sparkle-deps: install the Sparkle automatic updater\\n"
printf "\\t--install-all: install everything\\n"
printf "\\t[other]: other options are passed as-is to apt\\n"
}
# install custom tap of sparkle v1 as homebrew now uses sparkle v2 per default which is not compatible
curl -o /tmp/sparkle.rb https://raw.githubusercontent.com/Homebrew/homebrew-cask/c6dfe6baf1639998ba1707f68668cf8fa97bac9d/Casks/sparkle.rb
brew install /tmp/sparkle.rb
rm /tmp/sparkle.rb
INSTALLED_FORMULAE=$( brew list --formulae )
function install_formulae() {
INSTALL_LIST=()
for FORMULA in "$@" ; do
if ! grep --word-regexp "$FORMULA" > /dev/null 2>&1 <<<"$INSTALLED_FORMULAE" ; then
INSTALL_LIST+=( "$FORMULA" )
fi
done
if (( ${#INSTALL_LIST[@]} != 0 )); then
brew install "${INSTALL_LIST[@]}"
else
printf "Nothing to install.\n"
fi
}
# Uncomment to enable automatic updates using Sparkle
# brew cask install sparkle
ADDITIONAL=0
DMGDEPS=0
SPARKLEDEPS=0
OPTIONS=()
for arg; do
case $arg in
--help)
print_usage
exit 0
;;
--install-optional)
ADDITIONAL=1
;;
--install-dmg-deps)
DMGDEPS=1
;;
--install-sparkle-deps)
DMGDEPS=1
;;
--install-all)
ADDITIONAL=1
DMGDEPS=1
SPARKLEDEPS=1
;;
*)
OPTIONS+=("$arg")
;;
esac
done
BUILD_LIST=(
ccache
cmake
ninja
)
# Qt isn't technically required, but...
REQUIRED_LIST=(
c-ares
glib
libgcrypt
pcre2
qt6
)
ADDITIONAL_LIST=(
brotli
gettext
gnutls
libilbc
libmaxminddb
libsmi
libssh
libxml2
lua@5.1
lz4
minizip
nghttp2
opus
snappy
spandsp
speexdsp
zstd
)
ACTUAL_LIST=( "${BUILD_LIST[@]}" "${REQUIRED_LIST[@]}" )
# Now arrange for optional support libraries
if [ $ADDITIONAL -ne 0 ] ; then
ACTUAL_LIST+=( "${ADDITIONAL_LIST[@]}" )
fi
if (( ${#OPTIONS[@]} != 0 )); then
ACTUAL_LIST+=( "${OPTIONS[@]}" )
fi
install_formulae "${ACTUAL_LIST[@]}"
if [ $DMGDEPS -ne 0 ] ; then
pip3 install dmgbuild
pip3 install biplist
fi
if [ $SPARKLEDEPS -ne 0 ] ; then
brew cask install sparkle
fi
# Uncomment to add PNG compression utilities used by compress-pngs:
# brew install advancecomp optipng oxipng pngcrush
@ -30,11 +136,9 @@ rm /tmp/sparkle.rb
# Uncomment to enable generation of documentation
# brew install asciidoctor
# Uncomment to build dmg bundle
# /usr/local/bin/pip3 install dmgbuild
# /usr/local/bin/pip3 install biplist
brew doctor
if [ -z "$HOMEBREW_NO_AUTO_UPDATE" ] ; then
brew doctor
fi
exit 0
#