forked from CorsixTH/CorsixTH
-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (152 loc) · 6.58 KB
/
Linux.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
---
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 bad whitespace.
python3 scripts/check_whitespace.py -e scanner.cpp -e parser.cpp
# 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