MacVim GitHub CI #633
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: MacVim GitHub CI | |
on: | |
push: | |
pull_request: | |
# Cancels all previous workflow runs for pull requests that have not completed. | |
concurrency: | |
# The concurrency group contains the workflow name and the branch name for | |
# pull requests or the commit hash for any other events. | |
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} | |
cancel-in-progress: true | |
env: | |
MACOSX_DEPLOYMENT_TARGET: '10.13' | |
MACOSX_DEPLOYMENT_TARGET_LEGACY: '10.9' | |
MACVIM_ARCHS: "x86_64 arm64" # Universal app for Intel/Apple Silicon | |
MACVIM_ARCHS_LEGACY: "x86_64" # Legacy builds only need to build x86-64 because Apple Silicon can't run on these old OSes | |
CC: clang | |
VERSIONER_PERL_VERSION: '5.30' # macOS default Perl installation uses this to determine which one to use | |
vi_cv_path_python: /usr/local/bin/python | |
vi_cv_path_python3: /usr/local/bin/python3 | |
vi_cv_path_plain_lua: /usr/local/bin/lua | |
vi_cv_path_ruby: /usr/local/opt/ruby/bin/ruby | |
vi_cv_dll_name_perl: /System/Library/Perl/%s/darwin-thread-multi-2level/CORE/libperl.dylib | |
vi_cv_dll_name_python: /usr/local/Frameworks/Python.framework/Versions/2.7/Python | |
vi_cv_dll_name_python3: /usr/local/Frameworks/Python.framework/Versions/Current/Python | |
vi_cv_dll_name_python3_arm64: /opt/homebrew/Frameworks/Python.framework/Versions/Current/Python | |
vi_cv_dll_name_ruby: /usr/local/opt/ruby/lib/libruby.dylib | |
vi_cv_dll_name_ruby_arm64: /opt/homebrew/opt/ruby/lib/libruby.dylib | |
vi_cv_dll_name_lua_arm64: /opt/homebrew/lib/liblua.dylib | |
MACVIM_APP: src/MacVim/build/Release/MacVim.app | |
VIM_BIN: src/MacVim/build/Release/MacVim.app/Contents/MacOS/Vim | |
MACVIM_BIN: src/MacVim/build/Release/MacVim.app/Contents/MacOS/MacVim | |
TERM: xterm | |
BASH_SILENCE_DEPRECATION_WARNING: 1 | |
jobs: | |
# Builds and test MacVim | |
build-and-test: | |
# Test on macOS 11.x / 12.x, and also older versions of Xcode for compatibility testing. | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# Oldest version of Xcode supported on GitHub Action to test source code backwards compatibility | |
- os: macos-11 | |
xcode: '11.7' | |
extra: [vimtags] | |
# Older version of Xcode, and used to publish legacy builds (for macOS 10.9 - 10.12) | |
- os: macos-12 | |
xcode: '14.0' # last version of Xcode that uses the macOS 12 SDK, which still supports deploying to macOS 10.9 | |
publish: true | |
legacy: true | |
publish_postfix: '_10.9' | |
# Most up to date OS and Xcode. Used to publish release for the main build. | |
- os: macos-12 | |
xcode: '14.2' | |
publish: true | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up legacy build | |
if: matrix.legacy | |
run: | | |
# Set the correct build env vars to target the correct architectures and min OS targets. | |
echo "MACOSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET_LEGACY" >> $GITHUB_ENV | |
echo "MACVIM_ARCHS=$MACVIM_ARCHS_LEGACY" >> $GITHUB_ENV | |
# Use Sparkle 1 because Sparkle 2 requires newer OS version than our legacy build. | |
# Later, we pass the --enable-sparkle_1 flag to configure to set the corresponding ifdef. | |
ln -fhs Sparkle_1.framework src/MacVim/Sparkle.framework | |
- name: Set up Xcode | |
if: matrix.xcode != '' | |
run: | | |
sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer | |
xcode-select -p | |
xcodebuild -version | |
# Set up, install, and cache gettext library for localization. | |
# | |
# Instead of using the default binary installed by Homebrew, need to build our own because gettext is statically | |
# linked in MacVim, and need to be built against MACOSX_DEPLOYMENT_TARGET to ensure the built binary will work on | |
# supported macOS versions. | |
# | |
# In addition, to support building a universal MacVim, we need an arm64 version of gettext as well in order to | |
# create a universal gettext binary to link against (Homebrew only distributes thin binaries and therefore this | |
# has to be done manually). To do that, we will just pull the bottle directly from Homebrew and patch it in using | |
# lipo. We can't use normal brew commands to get the bottle because brew doesn't natively support cross-compiling | |
# and we are running CI on x86_64 Macs. We also don't need to worry about the min deployment target fix on arm64 | |
# because all Apple Silicon Macs have to run on macOS 11+. | |
- name: Set up gettext | |
if: matrix.publish | |
uses: ./.github/actions/universal-package | |
with: | |
formula: gettext | |
contents: lib/libintl.a,lib/libintl.dylib | |
# Set up, install, and cache libsodium library for encryption. | |
- name: Set up libsodium | |
if: matrix.publish | |
uses: ./.github/actions/universal-package | |
with: | |
formula: libsodium | |
contents: lib/libsodium.a,lib/libsodium.dylib | |
# Set up remaining packages and tools | |
- name: Install packages | |
if: matrix.publish | |
run: | | |
brew install python3 | |
brew install ruby | |
brew install lua | |
# CI sometimes have custom installed Python instead of using Homebrew. Forcefully re- | |
# link Python, and then check that we are using the Homebrew version. This avoids us | |
# using a mystery Python installation that we don't control. | |
brew unlink python3 && brew link --overwrite python3 | |
readlink -f $vi_cv_path_python3 | grep "^$(brew --cellar python3)" | |
if [[ -d /usr/local/Cellar/perl ]]; then | |
# We just use system perl to reduce dependencies | |
brew unlink perl | |
fi | |
# With Perl, we need to manually specify the version number because the dylib path depends on it. | |
echo "vi_cv_dll_name_perl=$(printf $vi_cv_dll_name_perl $VERSIONER_PERL_VERSION)" >> $GITHUB_ENV | |
# All set up steps are done. Build and test MacVim below. | |
- name: Configure | |
run: | | |
set -o verbose | |
CONFOPT=( | |
--with-features=huge | |
--enable-netbeans | |
--with-tlib=ncurses | |
--enable-cscope | |
--enable-gui=macvim | |
--with-compiledby="GitHub Actions" | |
) | |
if ${{ matrix.publish == true }}; then | |
CONFOPT+=( | |
--enable-perlinterp=dynamic | |
--enable-pythoninterp=dynamic | |
--enable-python3interp=dynamic | |
--with-python3-stable-abi=3.9 # macOS and Xcode currently ships 3.9, so we don't want go higher than that. | |
--enable-rubyinterp=dynamic | |
--enable-luainterp=dynamic | |
--with-lua-prefix=/usr/local | |
--with-macarchs="$MACVIM_ARCHS" | |
) | |
else | |
CONFOPT+=( | |
--with-macarchs=x86_64 | |
--disable-sparkle # Disable Sparkle for testing that this flag builds and works | |
) | |
fi | |
if ${{ matrix.legacy == true }}; then | |
CONFOPT+=( | |
--enable-sparkle_1 | |
) | |
fi | |
echo "CONFOPT: ${CONFOPT[@]}" | |
./configure "${CONFOPT[@]}" --enable-fail-if-missing | |
sed -i.bak -f ci/config.mk.sed -f ci/config.mk.clang.sed src/auto/config.mk | |
if clang --version | grep -qs '^Apple clang version \(1[3-9]\|[2-9]\d\)\.'; then | |
sed -i.bak -f ci/config.mk.clang-12.sed src/auto/config.mk | |
fi | |
- name: Modify configure result | |
if: matrix.publish | |
run: | | |
# Ruby is keg-only in Homebrew, so need to manually link in the path so Vim will know where to look for the binaries. | |
perl -p -i -e "s#(?<=-DDYNAMIC_RUBY_DLL=\\\\\").*?(?=\\\\\")#${vi_cv_dll_name_ruby}#" src/auto/config.mk | |
grep -q -- "-DDYNAMIC_PERL_DLL=\\\\\"${vi_cv_dll_name_perl}\\\\\"" src/auto/config.mk | |
grep -q -- "-DDYNAMIC_PYTHON_DLL=\\\\\"${vi_cv_dll_name_python}\\\\\"" src/auto/config.mk | |
grep -q -- "-DDYNAMIC_PYTHON3_DLL=\\\\\"${vi_cv_dll_name_python3}\\\\\"" src/auto/config.mk | |
grep -q -- "-DDYNAMIC_RUBY_DLL=\\\\\"${vi_cv_dll_name_ruby}\\\\\"" src/auto/config.mk | |
# Also search for the arm64 overrides for the default library locations, which are different from x86_64 | |
# because Homebrew puts them at a different place. | |
grep -q -- "-DDYNAMIC_PYTHON3_DLL_ARM64=\\\\\"${vi_cv_dll_name_python3_arm64}\\\\\"" src/auto/config.mk | |
grep -q -- "-DDYNAMIC_RUBY_DLL_ARM64=\\\\\"${vi_cv_dll_name_ruby_arm64}\\\\\"" src/auto/config.mk | |
grep -q -- "-DDYNAMIC_LUA_DLL_ARM64=\\\\\"${vi_cv_dll_name_lua_arm64}\\\\\"" src/auto/config.mk | |
- name: Show configure output | |
run: | | |
cat src/auto/config.mk | |
cat src/auto/config.h | |
- name: Build | |
env: | |
LC_ALL: C | |
run: | | |
set -o verbose | |
NPROC=$(getconf _NPROCESSORS_ONLN) | |
echo "Building MacVim with ${NPROC} cores" | |
make -j${NPROC} | |
- name: Check version | |
run: | | |
${VIM_BIN} --version | |
${VIM_BIN} -u NONE -i NONE --not-a-term -esNX -V1 -c 'echo "\nprof_nsec:" .. has("prof_nsec") .. "\n"' -c quit | |
${VIM_BIN} -u NONE -i NONE --not-a-term -esNX -V1 -S ci/if_ver-1.vim -c quit | |
${VIM_BIN} -u NONE -i NONE --not-a-term -esNX -V1 -S ci/if_ver-2.vim -c quit | |
- name: Smoketest | |
run: | | |
set -o verbose | |
# Make sure there isn't any dynamic linkage to third-party dependencies in the built binary, as we should only use | |
# static linkage to avoid dependency hell. Test that all those dylib's are in /usr/lib which is bundled with macOS and not third-party. | |
if otool -L ${VIM_BIN} | grep '\.dylib\s' | grep -v '^\s*/usr/lib/'; then | |
echo 'Found external dynamic linkage!'; false | |
fi | |
# Make sure that --disable-sparkle flag will properly exclude all references to Sparkle symbols. This is | |
# necessary because we still use weak linking to Sparkle when that flag is set and so references to Sparkle | |
# wouldn't fail the build (we just remove Sparkle.framework from the built app after the fact). | |
if ${{ matrix.publish == false }}; then | |
# Currently we pass --disable-sparkle flag when publish==false | |
if objdump -t ${MACVIM_BIN} | grep "_SPU\|_SUUpdate"; then | |
echo 'Found references to Sparkle even when using --disable-sparkle'; false | |
fi | |
fi | |
# Make sure man pages were bundled | |
man -M `pwd`/${MACVIM_APP}/Contents/man -w mvim | |
# Make sure xxd was bundled | |
echo "AB" | ${MACVIM_APP}/Contents/bin/xxd | grep "4142" | |
- name: Smoketest (publish) | |
if: matrix.publish | |
run: | | |
set -o verbose | |
macvim_excmd() { | |
${VIM_BIN} -u NONE -i NONE -g -f -X -V1 -es "$@" -c 'echo ""' -c 'qall!' 2>&1 | |
} | |
# Smoketest scripting languages | |
macvim_excmd -c 'lua print("Test")' | grep Test | |
macvim_excmd -c 'perl VIM::Msg("Test")' | grep Test | |
macvim_excmd -c 'py print "Test"' | grep Test | |
macvim_excmd -c 'py3 print("Test")' | grep Test | |
macvim_excmd -c 'ruby puts("Test")' | grep Test | |
# Check that localized messages work by printing ':version' and checking against localized word | |
macvim_excmd -c 'lang es_ES' -c 'version' | grep Enlazado | |
# Check that libsodium is working | |
macvim_excmd -c 'set cryptmethod=xchacha20' | |
# Make sure we are building universal x86_64 / arm64 builds and didn't accidentally create a thin app. | |
check_arch() { | |
local archs=($(lipo -archs "$1")) | |
if [[ ${archs[@]} != "$MACVIM_ARCHS" ]]; then | |
echo "Wrong arch(s) in $1: ${archs[@]}"; false | |
else | |
lipo -info "$1" | |
fi | |
} | |
check_arch "${VIM_BIN}" | |
check_arch "${MACVIM_BIN}" | |
- name: Check Vim help tags | |
if: contains(matrix.extra, 'vimtags') | |
run: | | |
# Confirm that we can build the help tags, and they match what's in source. | |
make -C runtime/doc vimtags VIMEXE=../../${VIM_BIN} | |
git diff --exit-code -- runtime/doc/tags | |
- name: Test | |
timeout-minutes: 20 | |
run: make test | |
- name: Test GUI | |
timeout-minutes: 20 | |
run: | | |
make -C src/testdir clean | |
make -C src testgui | |
# Creates a DMG package of MacVim. Note that this doesn't create a GitHub release for us, because we would prefer to | |
# do it manually, for two reasons: 1) signing / notarization are currently done out of CI, 2) we want to manually | |
# format our release notes and add pictures to make them look nice. | |
- name: Build MacVim dmg image | |
if: startsWith(github.ref, 'refs/tags/') && matrix.publish | |
run: | | |
# Use the --skip-jenkins flag to skip the prettify osascript calls which could fail due to permission issues in | |
# CI environment. | |
if ${{ matrix.legacy == true }}; then | |
make -C src macvim-dmg-legacy CREATEDMG_FLAGS=--skip-jenkins | |
else | |
make -C src macvim-dmg CREATEDMG_FLAGS=--skip-jenkins | |
fi | |
if ${{ matrix.publish_postfix != '' }}; then | |
mv src/MacVim/build/Release/MacVim.dmg src/MacVim/build/Release/MacVim${{ matrix.publish_postfix }}.dmg | |
fi | |
- name: Upload MacVim image | |
if: startsWith(github.ref, 'refs/tags/') && matrix.publish | |
uses: actions/upload-artifact@v3 | |
with: | |
name: MacVim${{ matrix.publish_postfix }}.dmg | |
path: src/MacVim/build/Release/MacVim${{ matrix.publish_postfix }}.dmg |