Merge pull request #140 from cooljeanius/dependabot/submodules/utils/… #373
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: CI | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
workflow_dispatch: | |
jobs: | |
checks: # checks that don't need a wesnoth binary | |
runs-on: ubuntu-latest | |
container: | |
image: wesnoth/wesnoth:2204-master | |
options: --tty # docker create options | |
env: | |
CLICOLOR_FORCE: 1 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set git safe directory | |
if: success() || failure() | |
run: | | |
git config --global --add safe.directory '*' | |
- name: Check for invalid characters | |
if: success() || failure() | |
run: | | |
./utils/CI/check_utf8.sh | |
./utils/CI/utf8_bom_dog.sh | |
- name: Whitespace and WML indentation check | |
if: success() || failure() | |
run: ./utils/CI/fix_whitespace.sh; git status; git diff --exit-code | |
- name: Run luacheck | |
if: success() || failure() | |
run: luacheck . | |
- name: Doxygen check | |
if: success() || failure() | |
run: doxygen doc/doxygen/Doxyfile | |
- name: Lints and stuff | |
if: success() || failure() | |
run: | | |
sync && echo "Possibly running some linters..." | |
if test -x "$(which actionlint)"; then actionlint; else \ | |
sync && echo "skipping actionlint..."; \ | |
fi | |
if test -x "$(which yamllint)"; then \ | |
find .github -name '*.yml' -print0 | xargs -0 yamllint; \ | |
else \ | |
sync && echo "skipping yamllint..."; \ | |
fi | |
if test -x "$(which pylint)"; then \ | |
find . -name '*.py' -print0 | xargs -0 pylint --exit-zero; \ | |
else \ | |
sync && echo "skipping pylint..."; \ | |
fi | |
if test -x "$(which flake8)"; then \ | |
flake8 --exit-zero; \ | |
else \ | |
sync && echo "skipping flake8..."; \ | |
fi | |
if test -x "$(which ruff)"; then \ | |
ruff check || stat "$(which ruff)"; \ | |
else \ | |
sync && echo "skipping ruff..."; \ | |
fi | |
if test -x "$(which shellcheck)"; then \ | |
find . -name '*.sh' -print0 | xargs -0 shellcheck -S warning; \ | |
else \ | |
sync && echo "skipping shellcheck..."; \ | |
fi | |
# (bandit has its own separate workflow file, so omit that here) | |
copyright: # check takes a bit longer and does not need to run in docker | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: {fetch-depth: 0, submodules: "recursive"} | |
- name: Dependencies | |
run: pip install pylint flake8 ruff black pyupgrade bandit | |
- name: Copyright check | |
run: | | |
./update_copyrights --output= || \ | |
(ret="$?"; sync && echo "./update_copyrights returned '${ret}'"; \ | |
if test -x "$(which pylint)"; then \ | |
sync && which pylint && pylint ./update_copyrights; \ | |
elif test -x "$(which flake8)"; then \ | |
sync && which flake8 && flake8 ./update_copyrights; \ | |
elif test -x "$(which ruff)"; then \ | |
sync && which ruff && ruff check ./update_copyrights; \ | |
elif test -x "$(which black)"; then \ | |
sync && which black && black ./update_copyrights; \ | |
elif test -x "$(which pyupgrade)"; then \ | |
sync && which pyupgrade && pyupgrade ./update_copyrights; \ | |
elif test -x "$(which bandit)"; then \ | |
sync && which bandit && bandit ./update_copyrights; \ | |
else \ | |
sync && echo "No python code quality tools found!" && sleep 1; \ | |
echo "warning: unable to lint ./update_copyrights script!" >&2; \ | |
if test -n "${ret}"; then exit "${ret}"; else exit 1; fi; \ | |
fi) | |
ubuntu: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- {tool: scons, cc: gcc, cxx: g++, cfg: debug, lto: false} | |
- {tool: cmake, cc: clang, cxx: clang++, cfg: release, lto: true} | |
runs-on: ubuntu-latest | |
container: | |
image: wesnoth/wesnoth:2204-master | |
options: --tty # docker create options | |
env: | |
TOOL: ${{matrix.tool}} | |
CFG: ${{matrix.cfg}} | |
CC: ${{matrix.cc}} | |
CXX: ${{matrix.cxx}} | |
CXX_STD: 17 | |
LTO: ${{matrix.lto}} | |
CLICOLOR_FORCE: 1 | |
SDL_VIDEODRIVER: dummy | |
steps: | |
- {uses: actions/checkout@v3, with: {submodules: "recursive"}} | |
# 1) wesnothd and campaignd should be buildable without SDL2 being present | |
# 2) boost is installed via apt as well as built and installed into | |
# /usr/local (for _GLIBCXX_DEBUG support in boost program options) | |
# 3) mariadbpp currently has a deprecation warning that causes strict | |
# builds to fail | |
# scons doesn't build it for the wesnoth client and the boost tests, | |
# but cmake apparently does | |
- name: Build wesnoth, wesnothd, campaignd and unit tests | |
id: build # needed to check step outcome | |
run: | | |
case $TOOL in | |
scons) | |
build() { | |
ldconfig | |
scons "$@" build="$CFG" ctool="$CC" cxxtool="$CXX" \ | |
cxx_std="$CXX_STD" extra_flags_config="-pipe" \ | |
forum_user_handler=true nls=false enable_lto="$LTO" \ | |
force_color=true jobs=2 --debug=time \ | |
glibcxx_debug=true glibcxx_assertions=true | |
} | |
build strict=true wesnoth boost_unit_tests | |
apt remove -y -qq libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev | |
build strict=false wesnothd campaignd | |
;; | |
cmake) | |
build() { | |
ldconfig | |
cmake "$@" -DCMAKE_BUILD_TYPE="$CFG" -DCXX_STD="$CXX_STD" \ | |
-DEXTRA_FLAGS_CONFIG="-pipe" -DENABLE_MYSQL=true \ | |
-DENABLE_NLS=false -DENABLE_LTO="$LTO" \ | |
-DFORCE_COLOR_OUTPUT=true -DLTO_JOBS=2 . | |
} | |
rm -R /usr/local/lib/cmake | |
rm /usr/local/lib/libboost* | |
rm -R /usr/local/include/boost | |
build -DENABLE_GAME=true -DENABLE_SERVER=false \ | |
-DENABLE_CAMPAIGN_SERVER=false -DENABLE_TESTS=true \ | |
-DENABLE_STRICT_COMPILATION=false | |
make conftests | |
make VERBOSE=1 -j2 | |
apt remove -y -qq libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev | |
build -DENABLE_GAME=false -DENABLE_SERVER=true \ | |
-DENABLE_CAMPAIGN_SERVER=true -DENABLE_TESTS=false \ | |
-DENABLE_STRICT_COMPILATION=false | |
make VERBOSE=1 -j2 | |
;; | |
esac | |
- name: Check path options | |
if: success() || steps.build.outcome == 'success' | |
run: | | |
./wesnoth --version | |
for opt in config data userconfig userdata | |
do | |
output=$(./wesnoth --nobanner --"$opt"-path) | |
if [ "$output" = "" ]; then \ | |
printf 'option --%s-path prints nothing to stdout!' "$opt" >&2; \ | |
exit 1; \ | |
fi | |
printf '%s-path: %s\n' "$opt" "$output" | |
done | |
- name: WML validation | |
if: success() || steps.build.outcome == 'success' | |
run: ./utils/CI/schema_validation.sh | |
- name: Run WML tests | |
if: success() || steps.build.outcome == 'success' | |
run: ./run_wml_tests -g -c -t 20 -bt 1000 | |
- name: Run play tests | |
if: success() || steps.build.outcome == 'success' | |
run: ./utils/CI/play_test_executor.sh | |
- name: Run MP tests | |
if: success() || steps.build.outcome == 'success' | |
run: ./utils/CI/mp_test_executor.sh | |
- name: Run unit tests | |
if: success() || steps.build.outcome == 'success' | |
run: ./run_boost_tests | |
steam-runtime: | |
runs-on: ubuntu-latest | |
steps: | |
- {uses: actions/checkout@v3, with: {submodules: "recursive"}} | |
- name: Steam Runtime | |
run: | | |
version=$(sed -n 's/#define VERSION "\(.*\)"/\1/p' src/wesconfig.h) | |
cd utils/dockerbuilds && ./make_steam_build | |
tar -cf "steambuild-$version.tar" steambuild | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Steam-Linux | |
path: utils/dockerbuilds/steambuild-*.tar | |
mingw: | |
runs-on: ubuntu-latest | |
steps: | |
- {uses: actions/checkout@v3, with: {submodules: "recursive"}} | |
- name: MinGW Crosscompile | |
run: | | |
version=$(sed -n 's/#define VERSION "\(.*\)"/\1/p' src/wesconfig.h) | |
git archive --format=tar HEAD > "wesnoth-$version.tar" | |
tar -rf "wesnoth-$version.tar" src/modules/ | |
bzip2 "wesnoth-$version.tar" | |
cd utils/dockerbuilds && ./make_mingw_build | |
mv mingwbuild/wesnoth*-win64.exe "wesnoth-$version-win64.exe" | |
- name: Upload Source | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Source | |
path: wesnoth-*.tar.bz2 | |
- name: Upload Windows-Installer | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Windows-Installer | |
path: utils/dockerbuilds/wesnoth-*-win64.exe | |
flatpak: | |
runs-on: ubuntu-latest | |
container: | |
image: wesnoth/wesnoth:flatpak-master | |
options: --tty --cap-add=ALL --privileged # docker create options | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- name: Flatpak | |
run: | | |
# write to an ignored filename so the build is not marked as modified | |
jq '.modules |= map(select(.name == "wesnoth").sources[0]={"type":"dir","path":"."}) | ."build-options".env.FLATPAK_BUILDER_N_JOBS="2"' \ | |
packaging/flatpak/org.wesnoth.Wesnoth.json > wesnoth-manifest.json | |
flatpak-builder --force-clean --default-branch=ci \ | |
--disable-rofiles-fuse wesnoth-app wesnoth-manifest.json | |
flatpak build-export export wesnoth-app ci | |
flatpak build-bundle export wesnoth.flatpak org.wesnoth.Wesnoth ci \ | |
--runtime-repo=https://flathub.org/repo/flathub.flatpakrepo | |
- name: Upload flatpak bundle | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Flatpak-Bundle | |
path: wesnoth.flatpak | |
translations: | |
runs-on: ubuntu-latest | |
container: | |
image: wesnoth/wesnoth:2204-master | |
env: | |
LANGUAGE: en_US.UTF-8 | |
LANG: en_US.UTF-8 | |
LC_ALL: en_US.UTF-8 | |
CLICOLOR_FORCE: 1 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- name: Translations | |
run: | | |
cmake -DENABLE_NLS=true -DENABLE_GAME=false -DENABLE_SERVER=false \ | |
-DENABLE_CAMPAIGN_SERVER=false -DENABLE_TESTS=false \ | |
-DENABLE_POT_UPDATE_TARGET=TRUE . | |
make update-po4a-man; echo "Ran make update-po4a-man" | |
make update-po4a-manual; echo "Ran make update-po4a-manual" | |
make pot-update; echo "Ran make pot-update" | |
make mo-update; echo "Ran make mo-update" | |
make clean | |
scons translations build=release --debug=time nls=true jobs=2; \ | |
echo "Ran scons translations" | |
scons pot-update; echo "Ran scons pot-update" | |
scons update-po4a; echo "Ran scons update-po4a" | |
scons manual | |
macos-intel: | |
strategy: | |
fail-fast: false | |
matrix: | |
cfg: [Debug, Release] | |
runs-on: macos-12 | |
env: | |
CFG: ${{matrix.cfg}} | |
DEVELOPER_DIR: /Applications/Xcode_13.1.app/Contents/Developer | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- name: Get dependencies | |
run: | | |
HOMEBREW_NO_AUTO_UPDATE=1 brew install scons | |
./projectfiles/Xcode/Fix_Xcode_Dependencies | |
- name: Build translations | |
run: scons translations build=release --debug=time nls=true jobs=2 | |
- name: Build wesnoth and unit tests | |
working-directory: projectfiles/Xcode | |
run: | | |
xcodebuild ARCHS=x86_64 -project "The Battle for Wesnoth.xcodeproj" \ | |
-target "The Battle for Wesnoth" -target "unit_tests" \ | |
-configuration "$CFG" | |
# xcodebuild or maybe clang do not appear to fail properly when input | |
# files cannot be found; double check executables were produced | |
[ -x "build/$CFG/The Battle for Wesnoth.app" ] || \ | |
{ printf 'Failed to build wesnoth executable!\n' >&2; exit 1; } | |
[ -x "build/$CFG/unit_tests" ] || \ | |
{ printf 'Failed to build unit test executable!\n' >&2; exit 1; } | |
- name: Create disk image | |
working-directory: projectfiles/Xcode | |
run: > | |
hdiutil create -volname "Wesnoth_$CFG" -fs 'HFS+' -srcfolder \ | |
"build/$CFG" -ov -format UDBZ "Wesnoth_${CFG}.dmg" | |
- name: Upload disk image | |
uses: actions/upload-artifact@v4 | |
with: | |
name: MacOS ${{ matrix.cfg }} disk image | |
path: projectfiles/Xcode/Wesnoth_${{ matrix.cfg }}.dmg | |
- name: Run WML tests | |
if: matrix.cfg == 'Release' | |
run: > | |
./run_wml_tests -g -c -t 30 -p \ | |
"projectfiles/Xcode/build/$CFG/The Battle for Wesnoth.app/Contents/MacOS/The Battle for Wesnoth" | |
- name: Run unit tests | |
run: > | |
./run_boost_tests --path=projectfiles/Xcode/build/"$CFG" \ | |
--executable=unit_tests | |
windows: | |
strategy: | |
fail-fast: false | |
matrix: | |
cfg: [Debug, Release] | |
env: | |
CFG: ${{matrix.cfg}} | |
VCPKG_FEATURE_FLAGS: dependencygraph | |
permissions: | |
contents: write # for dependency graph | |
defaults: | |
run: | |
shell: cmd | |
runs-on: windows-2019 | |
steps: | |
- {uses: actions/checkout@v3, with: {submodules: "recursive"}} | |
- name: Make version of the runner image (https://github.com/actions/runner-images/releases) accessible to expression | |
run: echo IMAGE_VERSION=%ImageVersion%>> %GITHUB_ENV% | |
- name: Cache object files | |
id: windows-cache | |
uses: actions/cache@v4 | |
with: | |
path: vcpkg_installed # vcpkg generates this dir next to vcpkg.json | |
# the final key part needs to be changed if anything in the build | |
# process changes that is not already included here | |
key: win-cache-master-${{ matrix.cfg }}-${{ env.IMAGE_VERSION }}-${{ hashFiles('vcpkg.json') }}-0001 | |
- name: Add msbuild to PATH | |
uses: microsoft/[email protected] | |
- name: Run cmake | |
run: > | |
cmake -DCMAKE_BUILD_TYPE=%CFG% -DENABLE_GAME=true -DENABLE_SERVER=true -DENABLE_CAMPAIGN_SERVER=true -DENABLE_TESTS=true -DENABLE_MYSQL=false -DENABLE_NLS=false -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_INSTALL_OPTIONS=--debug -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_GENERATOR_PLATFORM=x64 -G "Visual Studio 16 2019" . | |
- name: Build wesnoth, wesnothd, campaignd and unit tests | |
run: MSBuild.exe wesnoth.sln -p:Configuration=%CFG% | |
- name: Run WML unit tests | |
if: matrix.cfg == 'Release' | |
run: python run_wml_tests -v -g -c -t 20 -p %CFG%/wesnoth.exe | |
# run after all other jobs have completed to check overall build status | |
notification: | |
runs-on: ubuntu-latest | |
needs: [checks, ubuntu, steam-runtime, mingw, flatpak, translations, macos-intel, windows] | |
if: failure() && github.event_name == 'push' | |
steps: | |
- name: Discord Notification | |
uses: rjstone/discord-webhook-notify@v1 | |
with: | |
severity: error | |
webhookUrl: ${{ secrets.DISCORD_CI_WEBHOOK }} | |
description: |- | |
pusher: ${{ github.actor }} | |
commit: ${{ github.event.head_commit.message }} | |
commit url: ${{ github.event.head_commit.url }} | |
- name: Prepare message | |
if: github.event_name == 'push' | |
env: | |
MSG: ${{ github.event.head_commit.message }} | |
run: | | |
printf COMMIT_SUBJECT=%s "${MSG}" | head -n 1 >> "$GITHUB_ENV" | |
- name: IRC Notification | |
uses: rectalogic/notify-irc@v2 | |
with: | |
channel: ${{ vars.IRC_CHANNEL }} | |
server: ${{ vars.IRC_SERVER }} | |
nickname: ${{ vars.IRC_NICK }} # is also used for sasl username | |
sasl_password: ${{ secrets.IRC_SASL_PASSWORD }} | |
message: "${{github.workflow}} workflow run ${{github.run_number}} failed on \x0306${{github.ref_name}}\x0F: ${{env.COMMIT_SUBJECT}} by \x0315${{github.actor}}\x0F: \x0302${{github.event.head_commit.url}}\x0F" |