🔨 Build Mudlet #1583
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: 🔨 Build Mudlet | |
on: | |
push: | |
branches: [master, development, release-*] | |
tags: [Mudlet-*] | |
pull_request: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 2 * * *' | |
jobs: | |
compile-mudlet: | |
name: ${{matrix.buildname}} | |
runs-on: ${{matrix.os}} | |
if: ${{ github.repository_owner == 'Mudlet' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# oldest OS supported for maximum compatibility of built AppImage | |
- os: ubuntu-20.04 | |
buildname: 'ubuntu / gcc / lua tests' | |
triplet: x64-linux | |
compiler: gcc_64 | |
gcc_compiler_version: 8 | |
qt: '5.14.2' | |
deploy: 'deploy' | |
run_tests: 'true' | |
- os: ubuntu-latest | |
buildname: 'ubuntu / clang' | |
triplet: x64-linux | |
compiler: clang_64 | |
# We still need a gcc for some sub-stages - and it ain't always the same one: | |
gcc_compiler_version: 9 | |
qt: '5.14.2' | |
- os: macos-11 | |
buildname: 'macos / c++ tests' | |
triplet: x64-osx | |
compiler: clang_64 | |
qt: '5.14.2' | |
deploy: 'deploy' | |
# - os: windows-2019 | |
# buildname: 'windows' | |
# triplet: x64-mingw-dynamic | |
# # compiler: flag not used in windows pipeline | |
# qt: '5.14.2' | |
env: | |
BOOST_ROOT: ${{github.workspace}}/3rdparty/boost | |
BOOST_URL: https://sourceforge.net/projects/boost/files/boost/1.77.0/boost_1_77_0.tar.bz2/download | |
# APP_BUILD embeds the git sha which changes on every commit, throwing the cache off - ignore it | |
CCACHE_IGNOREOPTIONS: "-DAPP_BUILD=*" | |
steps: | |
- name: Checkout Mudlet source code | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: (Windows) Install Qt | |
uses: jurplel/install-qt-action@v3 | |
if: runner.os == 'Windows' | |
with: | |
version: ${{matrix.qt}} | |
dir: ${{runner.workspace}} | |
arch: win64_mingw73 | |
cache: true | |
- name: (Linux/macOS) Install Qt | |
uses: jurplel/install-qt-action@v3 | |
if: runner.os == 'Linux' || runner.os == 'macOS' | |
with: | |
version: ${{matrix.qt}} | |
dir: ${{runner.workspace}} | |
cache: true | |
- name: Restore Boost cache | |
uses: actions/cache@v3 | |
id: cache-boost | |
with: | |
path: ${{env.BOOST_ROOT}} | |
key: boost | |
- name: Install Boost | |
if: steps.cache-boost.outputs.cache-hit != 'true' | |
run: | | |
if [ "$OS" == "Windows_NT" ]; then | |
# fix up paths to be forward slashes consistently | |
BOOST_ROOT=$(echo $BOOST_ROOT | sed 's/\\/\//g') | |
fi | |
mkdir -p $BOOST_ROOT | |
curl --progress-bar --location --output $BOOST_ROOT/download.tar.bz2 $BOOST_URL | |
7z -o$BOOST_ROOT x $BOOST_ROOT/download.tar.bz2 -y -bd | |
7z -o$BOOST_ROOT x $BOOST_ROOT/download.tar -y -bd | |
cd $BOOST_ROOT && cp -r boost_*/* . | |
rm -rf boost_*/* download.tar.bz2 download.tar | |
shell: bash | |
# workaround a poor interaction between github actions/cmake/vcpkg, see https://github.com/lukka/run-vcpkg/issues/88#issuecomment-885758902 | |
- name: Use CMake 3.20.1 | |
uses: lukka/[email protected] | |
- name: (macOS) Install non-vcpkg dependencies (1/2) | |
if: runner.os == 'macOS' | |
env: | |
HOMEBREW_NO_ANALYTICS: "ON" | |
HOMEBREW_NO_AUTO_UPDATE: "ON" | |
HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: "ON" | |
HOMEBREW_NO_INSTALL_CLEANUP: "ON" | |
run: | | |
# dependencies needed for vcpkg specifically | |
brew install automake autoconf pkg-config | |
- name: (Linux) Install non-vcpkg dependencies (1/2) | |
if: runner.os == 'Linux' | |
run: | | |
# gettext is needed for vcpkg | |
sudo apt-get install gettext -y | |
- name: Restore from cache and run vcpkg | |
uses: lukka/run-vcpkg@v7 | |
env: | |
vcpkgResponseFile: ${{github.workspace}}/3rdparty/our-vcpkg-dependencies/vcpkg-${{matrix.triplet}}-dependencies | |
with: | |
vcpkgArguments: '@${{env.vcpkgResponseFile}}' | |
vcpkgDirectory: '${{github.workspace}}/3rdparty/vcpkg' | |
appendedCacheKey: ${{hashFiles(env.vcpkgResponseFile)}}-cachekey | |
- name: (macOS) Install non-vcpkg dependencies (2/2) | |
if: runner.os == 'macOS' | |
env: | |
HOMEBREW_NO_ANALYTICS: "ON" | |
HOMEBREW_NO_AUTO_UPDATE: "ON" | |
HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: "ON" | |
HOMEBREW_NO_INSTALL_CLEANUP: "ON" | |
run: | | |
# these aren't available or don't work well in vcpkg | |
brew install libzzip libzip ccache luarocks expect mitchellh/gon/gon | |
echo "/usr/local/opt/ccache/libexec" >> $GITHUB_PATH | |
echo "CCACHE_DIR=${{runner.workspace}}/ccache" >> $GITHUB_ENV | |
# Install lua-yajl early to generate translation statistics | |
export PATH="${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/tools/lua:$PATH" | |
# workaround https://github.com/lloyd/yajl/issues/209 | |
# Rock locations search is hardcoded to -L/usr/local/lib and not adjustable | |
export LIBRARY_PATH="${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/lib:$LIBRARY_PATH" | |
# LUA_INCDIR needs to be passed as well due to https://github.com/luarocks/luarocks/issues/1239 | |
luarocks --lua-dir "${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/tools/lua" --lua-version "5.1" LUA_INCDIR="${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/include" install YAJL_INCDIR="${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/include" YAJL_LIBDIR="${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/lib" LUA_INCDIR="${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/include" --local lua-yajl | |
# for some reason it gets installed in a place where lua-yajl can't find it after, fix that | |
mkdir -p /Users/runner/work/Mudlet/Mudlet/3rdparty/vcpkg/packages/yajl_x64-osx/lib/ | |
cp /Users/runner/work/Mudlet/Mudlet/3rdparty/vcpkg/installed/x64-osx/lib/libyajl.2.dylib /Users/runner/work/Mudlet/Mudlet/3rdparty/vcpkg/packages/yajl_x64-osx/lib/libyajl.2.dylib | |
# Allow stats generation script to see location of lua-yajl | |
eval "$(luarocks path --local --lua-version "5.1")" | |
echo "LUA_PATH=$LUA_PATH" >> $GITHUB_ENV | |
echo "LUA_CPATH=$LUA_CPATH" >> $GITHUB_ENV | |
# Use latest available XCode | |
echo "DEVELOPER_DIR=/Applications/Xcode_12.4.app/Contents/Developer" >> $GITHUB_ENV | |
# though we vcpkg installs Lua for us, the way it arranges directories is not compatible with Luarocks, | |
# so install it in a format that works | |
- name: (Linux) Install Lua | |
uses: leafo/gh-actions-lua@v10 | |
if: runner.os == 'Linux' | |
with: | |
luaVersion: "5.1.5" | |
buildCache: false | |
- name: (Linux) Install latest Luarocks | |
uses: leafo/gh-actions-luarocks@v4 | |
if: runner.os == 'Linux' | |
- name: (Linux) Install non-vcpkg dependencies (2/2) | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update | |
# Install from vcpkg everything we can for cross-platform consistency | |
# If not available, use other methods | |
# imagemagick is for the desktop screenshot | |
sudo apt-get install ccache pkg-config pcregrep expect libzip-dev libglu1-mesa-dev libpulse-dev g++-${{matrix.gcc_compiler_version}} \ | |
libxkbcommon-x11-0 imagemagick -y | |
# switch to GCC that supports C++17 while retaining support for older OS's | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{matrix.gcc_compiler_version}} ${{matrix.gcc_compiler_version}} | |
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${{matrix.gcc_compiler_version}} ${{matrix.gcc_compiler_version}} | |
sudo update-alternatives --set gcc /usr/bin/gcc-${{matrix.gcc_compiler_version}} | |
sudo update-alternatives --set g++ /usr/bin/g++-${{matrix.gcc_compiler_version}} | |
echo "CCACHE_DIR=${{runner.workspace}}/ccache" >> $GITHUB_ENV | |
# Install lua-yajl early to generate translation statistics | |
export PATH="${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/tools/lua:$PATH" | |
# workaround https://github.com/lloyd/yajl/issues/209 | |
mv ${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/lib/libyajl_s.a ${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/lib/libyajl.a | |
mv ${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/debug/lib/libyajl_s.a ${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/debug/lib/libyajl.a | |
# Rock locations search is hardcoded to -L/usr/local/lib and not adjustable | |
export LIBRARY_PATH="${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/lib:$LIBRARY_PATH" | |
# LUA_INCDIR needs to be passed as well due to https://github.com/luarocks/luarocks/issues/1239 | |
luarocks install YAJL_INCDIR="${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/include" YAJL_LIBDIR="${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/lib" LUA_INCDIR="${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/include" --local lua-yajl | |
# Allow stats generation script to see location of lua-yajl | |
eval "$(luarocks path --local --lua-version "5.1")" | |
echo "LUA_PATH=$LUA_PATH" >> $GITHUB_ENV | |
echo "LUA_CPATH=$LUA_CPATH" >> $GITHUB_ENV | |
- name: (Windows) Install non-vcpkg dependencies | |
if: runner.os == 'Windows' | |
shell: powershell | |
run: | | |
# Install dependencies not available on machine | |
$env:WORKING_BASE_DIR = "${{runner.workspace}}\src" | |
$env:MINGW_BASE_DIR = "${{runner.workspace}}\mingw73_64" | |
echo "MINGW_BASE_DIR=$env:MINGW_BASE_DIR" >> $env:GITHUB_ENV | |
. ${{github.workspace}}\CI\appveyor.functions.ps1 | |
# Libzip install complains when \bin is missing | |
New-Item -ItemType Directory -Path "$env:MINGW_BASE_DIR\bin" | |
SetQtBaseDir "$env:WORKING_BASE_DIR\verbose_output.log" | |
SetMingwBaseDir "$env:WORKING_BASE_DIR\verbose_output.log" | |
SetLuarocksPath "$env:WORKING_BASE_DIR\verbose_output.log" | |
$NoShPath = filterPathForSh | |
CheckAndInstallZlib | |
CheckAndInstallLibzip | |
- name: (Linux Clang) change compiler & disable optional components | |
if: runner.os == 'Linux' && matrix.compiler == 'clang_64' | |
run: | | |
echo "CXX=clang++" >> $GITHUB_ENV | |
echo "CC=clang" >> $GITHUB_ENV | |
echo "WITH_UPDATER=no" >> $GITHUB_ENV | |
echo "WITH_3DMAPPER=no" >> $GITHUB_ENV | |
echo "WITH_FONTS=no" >> $GITHUB_ENV | |
- name: (Linux/macOS) restore ccache | |
uses: pat-s/[email protected] | |
with: | |
path: ${{runner.workspace}}/ccache | |
key: ccache-${{matrix.os}}-${{matrix.compiler}}-${{matrix.qt}}-${{ github.sha }} | |
restore-keys: ccache-${{matrix.os}}-${{matrix.compiler}}-${{matrix.qt}} | |
if: matrix.os != 'windows-latest' | |
- name: (Linux) Set build info | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get -y install pcregrep | |
${{github.workspace}}/CI/travis.validate_deployment.sh | |
${{github.workspace}}/CI/travis.set-build-info.sh | |
- name: (macOS) Set build info | |
if: runner.os == 'macOS' | |
run: | | |
brew install pcre | |
${{github.workspace}}/CI/travis.validate_deployment.sh | |
${{github.workspace}}/CI/travis.set-build-info.sh | |
# remove it as it breaks packaging down the line: https://github.com/Mudlet/Mudlet/issues/6668 | |
brew uninstall pcre | |
- name: (Linux/macOS) check ccache stats prior to build | |
if: runner.os == 'Linux' || runner.os == 'macOS' | |
run: ccache --zero-stats --show-stats | |
- name: Build Mudlet | |
uses: lukka/run-cmake@v3 | |
with: | |
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced | |
cmakeListsTxtPath: '${{github.workspace}}/CMakeLists.txt' | |
useVcpkgToolchainFile: true | |
buildDirectory: '${{runner.workspace}}/b/ninja' | |
# enable for a debug build (1/2) | |
# buildWithCMakeArgs: --config RelWithDebInfo | |
cmakeAppendedArgs: >- | |
-G Ninja | |
-DCMAKE_PREFIX_PATH=${{env.MINGW_BASE_DIR}} | |
-DVCPKG_APPLOCAL_DEPS=OFF | |
env: | |
NINJA_STATUS: '[%f/%t %o/sec] ' | |
- name: Upload GitHub Actions artifact of vcpkg build logs | |
if: failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: vcpkg-logs-${{ runner.os }} | |
path: ${{ github.workspace }}/vcpkg/buildtrees/**/*.log | |
- name: (Linux/macOS) check ccache stats post build | |
if: runner.os == 'Linux' || runner.os == 'macOS' | |
run: ccache --show-stats | |
- name: (macOS) Run C++ tests | |
if: runner.os == 'macOS' | |
working-directory: '${{runner.workspace}}/b/ninja' | |
run: ctest --output-on-failure | |
- name: (Linux/macOS) restore Luarocks for packaging | |
uses: actions/cache@v3 | |
with: | |
path: $HOME/.luarocks | |
key: ccache-${{matrix.os}}-${{matrix.compiler}}-${{hashFiles('.github/workflows/build-mudlet.yml')}} | |
restore-keys: ccache-${{matrix.os}}-${{matrix.compiler}}- | |
if: runner.os == 'Linux' || runner.os == 'macOS' | |
- name: (Linux/macOS) install dependencies for packaging/tests | |
if: matrix.deploy == 'deploy' || matrix.run_tests == 'true' | |
run: | | |
export PATH="${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/tools/lua:$PATH" | |
shopt -s expand_aliases | |
if [ "${RUNNER_OS}" = "macOS" ]; then | |
alias run-luarocks="luarocks --lua-dir "${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/tools/lua" --lua-version "5.1" LUA_INCDIR="${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/include"" | |
else | |
alias run-luarocks="luarocks" | |
fi | |
run-luarocks install --local LuaFileSystem | |
run-luarocks install --local luautf8 | |
run-luarocks install --local lua-zip | |
run-luarocks install SQLITE_INCDIR="${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/include" --local LuaSQL-SQLite3 | |
run-luarocks install PCRE_INCDIR="${{env.VCPKG_ROOT}}/installed/${{matrix.triplet}}/include" --local lrexlib-pcre | |
# CI changelog generation dependencies | |
run-luarocks install --local argparse | |
run-luarocks install --local lunajson | |
# Lua-based tests | |
run-luarocks install --local busted | |
# necessary for Qt multimedia and modern Qt | |
if [ "${RUNNER_OS}" = "Linux" ]; then | |
sudo apt-get install libgstreamer-plugins-base1.0-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xinerama0 -y | |
fi | |
env: | |
BUILD_FOLDER: ${{runner.workspace}}/b/ninja | |
RUNNER_OS: ${{runner.os}} | |
DEPLOY: ${{matrix.deploy}} | |
- name: (Linux/macOS) add ssh-agent for tag deployment | |
if: (runner.os == 'Linux' || runner.os == 'macOS') && matrix.deploy == 'deploy' && startsWith(github.ref, 'refs/tags/Mudlet-') | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{secrets.UPLOAD_PRIVATEKEY}} | |
- name: (Linux/macOS) package Mudlet | |
if: (runner.os == 'Linux' || runner.os == 'macOS') && matrix.deploy == 'deploy' | |
run: ${{github.workspace}}/CI/travis.after_success.sh | |
env: | |
BUILD_FOLDER: ${{runner.workspace}}/b/ninja | |
RUNNER_OS: ${{runner.os}} | |
DEPLOY: ${{matrix.deploy}} | |
DBLSQD_USER: ${{secrets.DBLSQD_USER}} | |
DBLSQD_PASS: ${{secrets.DBLSQD_PASS}} | |
DEPLOY_KEY_PASS: ${{secrets.DEPLOY_KEY_PASS}} | |
MACOS_SIGNING_PASS: ${{secrets.MACOS_SIGNING_PASS}} | |
AC_USERNAME: ${{secrets.APPLE_USERNAME}} | |
AC_PASSWORD: ${{secrets.APPLE_PASSWORD}} | |
- name: Upload packaged Mudlet | |
uses: actions/upload-artifact@v3 | |
if: env.UPLOAD_FILENAME | |
with: | |
name: ${{env.UPLOAD_FILENAME}} | |
path: ${{env.FOLDER_TO_UPLOAD}} | |
- name: Submit to make.mudlet.org | |
if: env.UPLOAD_FILENAME | |
run: curl -X POST "https://make.mudlet.org/snapshots/gha_queue.php?artifact_name=${{env.UPLOAD_FILENAME}}&unzip=1" | |
shell: bash | |
# we need to be in the right place for LuaGlobals.lua to load | |
- name: Prep binary for running tests | |
if: matrix.run_tests == 'true' | |
run: cp ${{runner.workspace}}/b/ninja/src/mudlet ${{github.workspace}}/src | |
shell: bash | |
- name: Run Lua tests | |
if: matrix.run_tests == 'true' | |
timeout-minutes: 5 | |
uses: GabrielBB/[email protected] | |
with: | |
run: ${{github.workspace}}/src/mudlet --profile "Mudlet self-test" --mirror | |
env: | |
AUTORUN_BUSTED_TESTS: 'true' | |
TESTS_DIRECTORY: ${{github.workspace}}/src/mudlet-lua/tests | |
QUIT_MUDLET_AFTER_TESTS: 'true' | |
- name: Passed Lua tests | |
if: matrix.run_tests == 'true' | |
run: | | |
if [ -e /tmp/busted-tests-failed ] | |
then | |
echo "Lua tests failed - see the action above for detailed output." | |
exit 1 | |
fi | |
- name: (windows) Show relevant setup logs | |
if: failure() && runner.os == 'Windows' | |
run: | | |
$env:WORKING_BASE_DIR = "${{runner.workspace}}\src" | |
if (Test-Path -Path "$env:WORKING_BASE_DIR\stderr.log") { | |
echo "Standard error log from non-vcpkg dependencies: " | |
cat $env:WORKING_BASE_DIR\stderr.log | |
} | |
if (Test-Path -Path "$env:WORKING_BASE_DIR\stdout.log") { | |
echo "Standard output log from non-vcpkg dependencies: " | |
cat $env:WORKING_BASE_DIR\stdout.log | |
} | |
if (Test-Path -Path "${{runner.workspace}}/b/ninja/CMakeFiles/CMakeOutput.log") { | |
echo "CMakeOutput.log: " | |
cat "${{runner.workspace}}/b/ninja/CMakeFiles/CMakeOutput.log" | |
} |