Skip to content

Merge pull request #2646 from lewri/068_0_final #70

Merge pull request #2646 from lewri/068_0_final

Merge pull request #2646 from lewri/068_0_final #70

Workflow file for this run

---
name: Linux and Tests
on:
push:
branches-ignore:
- 'gh-pages'
pull_request:
jobs:
Linux:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- static_analysis: 0
docs: 0
cmake: 1
lua: LuaJIT
luac: luac5.1
animview: ' and AnimView'
animviewreqs: 'and AnimView requirements'
packages: libluajit-5.1-dev luajit libwxgtk3.0-gtk3-dev
cmakejit: '-DBUILD_ANIMVIEW=ON -DWITH_LUAJIT=ON -DLUA_LIBRARY=/usr/lib/x86_64-linux-gnu/libluajit-5.1.so'
- static_analysis: 0
docs: 0
lua: Lua 5.1
luac: luac5.1
packages: liblua5.1-dev lua5.1
- static_analysis: 1
docs: 1
lua: Lua 5.4
luac: luac5.4
packages: liblua5.4-dev lua5.4
catch2: '-DENABLE_UNIT_TESTS=ON'
name: Linux and Tests on ${{ matrix.lua }}
steps:
- uses: actions/checkout@v4 # Keeps the git OAuth token after checkout
- name: Install ${{ matrix.lua }} ${{ matrix.animviewreqs }}
run: |
sudo apt-get update
sudo apt-get install ${{ matrix.packages }} luarocks
# Required for LDocGen
sudo luarocks install lpeg
# Required for lua lint check
sudo luarocks install luacheck
# Required for lua unit tests
sudo luarocks install busted
- name: Install CorsixTH requirements
run: |
sudo apt-get install libsdl2-dev libsdl2-mixer-dev \
libavcodec-dev libavformat-dev libavutil-dev libswresample-dev \
libswscale-dev libcurl4-openssl-dev
- name: Install static analysis requirements
if: matrix.static_analysis
run: |
sudo apt-get install doxygen yamllint clang-format-11 clang-tidy-11
sudo pip3 install -I codespell==2.2 cmakelint==1.4
# Build Catch2
git clone --quiet https://github.com/catchorg/Catch2 \
--branch v3.4.0 --depth=1 ../Catch2
mkdir ../Catch2/build
cd ../Catch2/build
cmake .. -B.
sudo make install
sudo luarocks --lua-version 5.4 install luafilesystem
- name: Install CMake 3.14
if: matrix.cmake
run: |
# Install CMake version 3.14, the oldest CorsixTH-supported version, which does not support Lua 5.4
curl -L https://github.com/Kitware/CMake/releases/download/v3.14.6/cmake-3.14.6-Linux-x86_64.sh -o cmake.sh
sudo bash cmake.sh --prefix=/usr/local/ --exclude-subdir --skip-license
cmake --version
- name: Create CorsixTH${{ matrix.animview }} makefiles with ${{ matrix.lua }}
run: |
cmake . -G"Unix Makefiles" -Bbuild --debug-output -LA \
-DWITH_AUDIO=ON -DWITH_MOVIES=ON ${{ matrix.catch2 }} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON ${{ matrix.cmakejit }}
- name: Build CorsixTH${{ matrix.animview }} with ${{ matrix.lua }}
run: |
cmake --build build/ -- VERBOSE=1
sudo cmake --build build/ -- install
- name: Run ${{ matrix.lua }} tests
run: |
# Validate lua files
find CorsixTH -name '*.lua' -print0 | xargs -0 -I{} ${{ matrix.luac }} -p {}
# Run lua lint check
luacheck --quiet --codes --ranges CorsixTH
# Run lua unit tests
busted --verbose --directory=CorsixTH/Luatest
- name: Run simple code tests
if: matrix.static_analysis
run: |
# Check if there are trailing whitespaces.
python3 scripts/check_trailing_whitespaces.py
# Check for incorrectly encoded files.
python3 scripts/check_language_files_not_BOM.py
# Check if there are lua classes with invalid/improper declarations.
python3 scripts/check_lua_classes.py
# Check for tabs (should be spaces)
! grep -IrnP '\t' CorsixTH/Lua
# Run CPP Tests
cd build/CorsixTH
ctest --extra-verbose --build-config Release --output-on-failure
cd ../..
# Build and package LevelEdit
ant -buildfile LevelEdit/build.xml dist
# Run codespell (temporarily not a failure, Nov 2023)
codespell --enable-colors --quiet-level 2 --skip="languages,corsix-th.6,*.dat" \
-L sav,unexpect,persistance,defin,uint,inout,currenty,blong,falsy,manuel \
AnimView CorsixTH CorsixTH/Lua/languages/english.lua LevelEdit libs || true
# Cmake file linter
cmakelint --filter=-linelength AnimView/CMakeLists.txt CMakeLists.txt CorsixTH/CMakeLists.txt \
CorsixTH/CppTest/CMakeLists.txt CorsixTH/Src/CMakeLists.txt CorsixTH/SrcUnshared/CMakeLists.txt \
libs/CMakeLists.txt libs/rnc/CMakeLists.txt \
CMake/GenerateDoc.cmake CMake/PrecompiledDeps.cmake
# Validate these build files
yamllint --config-data "rules: {line-length: disable}" .github/workflows/*.yml
shellcheck --shell sh scripts/macos_luarocks
# Check the windows config file is up to date
eval "$(luarocks --lua-version 5.4 path)"
lua5.4 scripts/generate_windows_config.lua
git diff --exit-code
- name: Run clang code tests
if: matrix.static_analysis
run: |
# Check cpp format
clang-format-11 -i CorsixTH/Src/*.cpp CorsixTH/Src/*.h AnimView/*.cpp \
AnimView/*.h libs/rnc/*.cpp libs/rnc/*.h CorsixTH/SrcUnshared/main.cpp
git diff
# Clang-tidy linter
clang-tidy-11 -p build --warnings-as-errors=\* \
CorsixTH/Src/*.c CorsixTH/Src/*.cpp libs/rnc/*.cpp CorsixTH/SrcUnshared/main.cpp
git diff --quiet # exit if clang-format made any changes
- name: Generate documentation
if: matrix.docs
run: |
cmake --build build/ --target doc
- name: Upload documentation
if: github.ref == 'refs/heads/master' && github.repository == 'CorsixTH/CorsixTH' && matrix.docs
run: |
git config user.email "[email protected]"
git config user.name "Docs Bot"
git fetch origin gh-pages
git checkout --force gh-pages
rsync --recursive build/doc/ .
git add animview/ corsixth_engine/ corsixth_lua/ index.html leveledit/
if ! git diff --cached --exit-code; then
git commit --message "Documentation from $(git rev-parse --short master) [no CI]"
git push origin gh-pages
else
echo "No change to documentation."
fi