Skip to content

Commit a027e54

Browse files
authored
internal: add CI checks for major Linux distros and fix build errors (skyrim-multiplayer#2276)
1 parent ea08224 commit a027e54

File tree

17 files changed

+573
-40
lines changed

17 files changed

+573
-40
lines changed

.github/workflows/pr-ubuntu-docker.yml renamed to .github/workflows/pr-linux-variants.yml

Lines changed: 115 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
name: PR Ubuntu Docker
1+
# TODO(#2280): rename from PR to something else (also applies to Windows etc)
2+
# TODO(#2280): keep in line with deploy.yml
3+
name: PR Linux
24
on:
35
pull_request:
46
# any
@@ -10,20 +12,115 @@ env:
1012
BUILD_TYPE: RelWithDebInfo
1113

1214
jobs:
13-
pr-ubuntu-docker:
15+
pr-docker:
16+
strategy:
17+
matrix:
18+
base_system:
19+
# The usual container used for all builds within the CI and the one
20+
# we use as the base for server builds with preinstalled/cached deps
21+
- ubuntu-vcpkg-deps
22+
23+
# Distros that our contributors are likely to run
24+
- ubuntu-2204
25+
- ubuntu-2404
26+
- ubuntu-2410 # latest non-LTS
27+
- debian-12
28+
- archlinux
29+
30+
# TODO(#2280): add Fedora
31+
# TODO(#2280): test gcc build, test build w/o ninja
32+
1433
runs-on: ubuntu-latest
1534
steps:
1635
- name: Checkout
1736
uses: actions/checkout@v4
1837
with:
1938
submodules: recursive
2039

21-
- name: Get image to build upon
40+
- name: Debug - print env
41+
run: env
42+
43+
- name: Get/build image to use for building & testing
2244
run: |
23-
cat ${{github.workspace}}/misc/github_env_linux >> "$GITHUB_ENV"
45+
set -x # print executed commands
46+
47+
echo Some debug data
48+
id
49+
uname -a
50+
lsb_release -a
51+
52+
# cat ${{github.workspace}}/misc/github_env_linux >> "$GITHUB_ENV"
53+
54+
# get base image for this distro (or build configuration, in case with skymp-deps)
55+
base_image="`misc/deps_linux/${{ matrix.base_system }}.sh --get-image-uri`"
56+
57+
docker run \
58+
--name prepare_deps_container \
59+
-v "${{github.workspace}}:/src" \
60+
-w "/src" \
61+
-e "CI=$CI" \
62+
-e "CREATE_UID=`id -u`" \
63+
"$base_image" \
64+
'misc/deps_linux/${{ matrix.base_system }}.sh' '--ensure-deps-noninteractive'
65+
66+
docker commit prepare_deps_container localhost/buildimage
67+
68+
- name: Debug - check build tools
69+
uses: addnab/docker-run-action@v3
70+
with:
71+
image: localhost/buildimage
72+
options: |
73+
-v ${{github.workspace}}:/src
74+
-w /src
75+
-u skymp
76+
run: |
77+
print_info_unsafe() {
78+
echo .
79+
echo .
80+
echo "=== Checking $1 ==="
81+
out="`which $1`"
82+
ret="$?"
83+
if [ "$ret" != 0 -o -z "$out" ]; then
84+
echo "Which exited with $ret $out"
85+
return
86+
fi
87+
ls -lh "$out"
88+
echo "version call:"
89+
"$out" --version
90+
}
91+
92+
print_info() {
93+
print_info_unsafe "$@" || true
94+
}
95+
96+
print_info clang++
97+
print_info clang++-15
98+
print_info cmake
99+
print_info ninja
100+
print_info node
101+
print_info yarn
102+
print_info git
103+
print_info zip
104+
print_info unzip
105+
print_info curl
106+
107+
echo .
108+
echo .
109+
echo === misc ===
110+
echo "current dir is $PWD"
111+
echo /src:
112+
ls -lh /src
113+
114+
echo .
115+
echo .
116+
echo === env ===
117+
./build.sh --print-env
24118
25119
- name: Store SP types from commit
26120
run: |
121+
id
122+
ls -lh ${{github.workspace}}/skyrim-platform/src/platform_se/codegen/convert-files
123+
27124
commit=$(< ${{github.workspace}}/skyrim-platform/src/platform_se/codegen/convert-files/skyrimPlatform.ts)
28125
chmod 777 ${{github.workspace}}/skyrim-platform/src/platform_se/codegen/convert-files
29126
echo "$commit" > ${{github.workspace}}/skyrim-platform/src/platform_se/codegen/convert-files/temp.txt
@@ -58,7 +155,7 @@ jobs:
58155
- name: Prepare
59156
uses: addnab/docker-run-action@v3
60157
with:
61-
image: ${{ env.SKYMP_VCPKG_DEPS_IMAGE }}
158+
image: localhost/buildimage
62159
options: |
63160
-v ${{github.workspace}}:/src
64161
run: |
@@ -68,7 +165,7 @@ jobs:
68165
id: cmake_configure
69166
uses: addnab/docker-run-action@v3
70167
with:
71-
image: ${{ env.SKYMP_VCPKG_DEPS_IMAGE }}
168+
image: localhost/buildimage
72169
options: |
73170
-v ${{github.workspace}}:/src
74171
-u skymp
@@ -78,23 +175,25 @@ jobs:
78175
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
79176
-DUNIT_DATA_DIR="/src/skyrim_data_files"
80177
81-
- name: Upload vcpkg failure logs
82-
if: failure()
178+
- name: Upload vcpkg logs
179+
if: always()
83180
uses: actions/upload-artifact@v4
84181
with:
85-
name: install-x64-linux-dbg-out.log
86-
path: ${{github.workspace}}/vcpkg/buildtrees/rsm-bsa/install-x64-linux-dbg-out.log
182+
name: ${{matrix.base_system}}_vcpkg_logs
183+
path: |
184+
${{github.workspace}}/build/vcpkg-bootstrap.log
185+
${{github.workspace}}/vcpkg/buildtrees/**/*.log
87186
88187
- name: Upload compile_commands.json
89188
uses: actions/upload-artifact@v4
90189
with:
91-
name: compile_commands.json
190+
name: ${{matrix.base_system}}_compile_commands.json
92191
path: ${{github.workspace}}/build/compile_commands.json
93192

94193
- name: Build
95194
uses: addnab/docker-run-action@v3
96195
with:
97-
image: ${{ env.SKYMP_VCPKG_DEPS_IMAGE }}
196+
image: localhost/buildimage
98197
options: |
99198
-v ${{github.workspace}}:/src
100199
-u skymp
@@ -105,7 +204,7 @@ jobs:
105204
- name: Prepare dist.tar.gz
106205
uses: addnab/docker-run-action@v3
107206
with:
108-
image: ${{ env.SKYMP_VCPKG_DEPS_IMAGE }}
207+
image: localhost/buildimage
109208
options: |
110209
-v ${{github.workspace}}:/src
111210
-u skymp
@@ -116,7 +215,7 @@ jobs:
116215
- name: Upload dist.tar.gz
117216
uses: actions/upload-artifact@v4
118217
with:
119-
name: dist.tar.gz
218+
name: ${{matrix.base_system}}_dist.tar.gz
120219
path: ${{github.workspace}}/build/dist.tar.gz
121220

122221
- name: SP Types Check
@@ -148,7 +247,7 @@ jobs:
148247
echo "ConstEnumApi.cpp has changed after running const_enum_extractor. Please re-run it locally and commit changes"
149248
exit 1
150249
fi
151-
250+
152251
- name: SP Types Check failed - Here is what you can do
153252
if: ${{ failure() && steps.sp_types_check.outcome == 'failure' }}
154253
run: |
@@ -164,7 +263,7 @@ jobs:
164263
- name: Test
165264
uses: addnab/docker-run-action@v3
166265
with:
167-
image: ${{ env.SKYMP_VCPKG_DEPS_IMAGE }}
266+
image: localhost/buildimage
168267
options: |
169268
-v ${{github.workspace}}:/src
170269
-u skymp

build.sh

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,25 @@ fi
1515

1616
export VCPKG_DISABLE_METRICS=1
1717

18-
export CC=/usr/bin/clang-15
19-
export CPP=/usr/bin/clang-cpp-15
20-
export CXX=/usr/bin/clang++-15
21-
export LD=/usr/bin/ld.lld-15
18+
if which clang++ > /dev/null 2>&1; then
19+
export CC=/usr/bin/clang
20+
export CPP=/usr/bin/clang-cpp
21+
export CXX=/usr/bin/clang++
22+
else
23+
export CC=/usr/bin/clang-15
24+
export CPP=/usr/bin/clang-cpp-15
25+
export CXX=/usr/bin/clang++-15
26+
fi
2227

2328
export CMAKE_C_COMPILER="$CC"
2429
export CMAKE_CXX_COMPILER="$CXX"
25-
export CMAKE_MAKE_PROGRAM="ninja"
26-
27-
# Some build dependencies require some strange stuff.
28-
# Some other deps won't work if we can't call clang without exact version.
29-
# It's better to make compatibility aliases than breaking main system's root.
30-
export SKYMP_COMPAT_BIN="$PWD/build/skymp_compat/bin"
31-
export PATH="$SKYMP_COMPAT_BIN:$PATH"
30+
export CMAKE_MAKE_PROGRAM="/usr/bin/ninja"
3231

3332
if [ ! -d build ]; then
3433
mkdir -v build
3534
fi
3635

37-
if [ ! -d "$SKYMP_COMPAT_BIN" ]; then
38-
mkdir -pv "$SKYMP_COMPAT_BIN"
39-
ln -s "$CC" "$SKYMP_COMPAT_BIN/clang"
40-
ln -s "$CXX" "$SKYMP_COMPAT_BIN/clang++"
41-
42-
echo "Set up compatibility path for build."
43-
fi
44-
45-
# TODO reverse the order or use [[ ]] ?
36+
# TODO(#2280): reverse the order or use [[ ]] ?
4637
if [ "$1" = "--configure" ]; then
4738
shift && \
4839
cd build && \
@@ -52,18 +43,36 @@ elif [ "$1" = "--build" ]; then
5243
cd build && \
5344
exec cmake --build . "$@"
5445
elif [ "$1" = "--clean" ]; then
55-
eecho "NOTE: --clean was deprecated, please use --clean-cpp or --clean-node"
46+
eecho "NOTE: --clean was deprecated, please use one of the options listed in --help"
5647
eecho "Proceeding with cleaning cpp build data"
5748
exec rm -rf build/
5849
elif [ "$1" = "--clean-cpp" ]; then
5950
exec rm -rf build/
6051
elif [ "$1" = "--clean-node" ]; then
61-
echo not implemented yet, TODO delete node_modules dirs
52+
find -name node_modules -type d -prune -print0 | xargs -0 echo rm -rf
53+
echo -n Ctrl-C to abort, Return/Enter to proceed
54+
read
55+
find -name node_modules -type d -prune -print0 | xargs --verbose -0 rm -rf
56+
elif [ "$1" = "--clean-vcpkg" ]; then
57+
(cd vcpkg && git clean -xfd --dry-run)
58+
echo -n Ctrl-C to abort, Return/Enter to proceed
59+
read
60+
(cd vcpkg && git clean -xfd)
61+
elif [ "$1" = "--print-env" ]; then
62+
env
6263
else
6364
eecho "Usage:"
6465
eecho " ./build.sh --configure <cmake args...>"
66+
eecho " runs in build: cmake .. <some extra args> <your args>"
6567
eecho "OR"
6668
eecho " ./build.sh --build <cmake args...>"
69+
eecho " runs in build: cmake build . <your args>"
70+
eecho " you can add args like --target=unit"
71+
eecho "OR"
72+
eecho " ./build.sh --clean-<cpp|node|vcpkg>"
6773
eecho "OR"
68-
eecho " ./build.sh --clean-<cpp|node>"
74+
eecho " ./build.sh --print-env"
75+
if [ "$1" != "--help" ]; then
76+
exit 1
77+
fi
6978
fi

cmake/yarn.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function(yarn_execute_command)
3434

3535
if("${A_RESULT_VARIABLE}" STREQUAL "")
3636
if(NOT "${yarn_result}" STREQUAL "0")
37-
message(FATAL_ERROR "yarn ${A_COMMAND} exited with ${yarn_result}:\n${yarn_output}\n${yarn_error}")
37+
message(FATAL_ERROR "yarn ${A_COMMAND} (working dir ${A_WORKING_DIRECTORY}) exited with ${yarn_result}:\n${yarn_output}\n${yarn_error}")
3838
endif()
3939
else()
4040
set("${A_RESULT_VARIABLE}" "${yarn_result}" PARENT_SCOPE)

libespm/src/WRLD.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#include "libespm/WRLD.h"
2+
3+
#include <algorithm>
4+
25
#include "libespm/RecordHeaderAccess.h"
36

47
namespace espm {

misc/deps_linux/archlinux.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env bash
2+
3+
# Scroll down for the list of packages
4+
5+
set -e
6+
7+
if [[ "$1" == "--get-image-uri" ]]; then
8+
# This is the image that we'll use in our CI for testing build for this distro
9+
echo 'archlinux:base-devel'
10+
exit
11+
fi
12+
13+
if [[ "$1" == "--ensure-deps-noninteractive" ]]; then
14+
if [[ -z "$CI" ]]; then
15+
echo "This isn't CI environment! Are you sure you didn't want to use just --ensure-deps?"
16+
exit 1
17+
fi
18+
set -x
19+
PACMAN_ARGS="--noconfirm"
20+
pacman -Syu $PACMAN_ARGS sudo
21+
useradd -m skymp -u $CREATE_UID
22+
chown -R skymp:skymp /src
23+
24+
cat /etc/passwd
25+
26+
DO_ENSURE_DEPS=1
27+
fi
28+
29+
if [[ "$1" == "--ensure-deps" ]]; then
30+
DO_ENSURE_DEPS=1
31+
PACMAN_ARGS="--confirm"
32+
fi
33+
34+
if [[ -z "$DO_ENSURE_DEPS" ]]; then
35+
echo "idk what to do"
36+
exit 1
37+
fi
38+
39+
packages=''
40+
41+
addpackage() {
42+
packages+="$1 "
43+
}
44+
45+
# These are some basic packages that are essential for C++ build config that we're using
46+
addpackage base-devel
47+
addpackage cmake
48+
addpackage clang
49+
addpackage ninja # would likely build with the regular make, but I haven't tried
50+
# gdb is also recommended for debugging but isn't required
51+
52+
# These are needed for some parts of the client and server, as well as some build scripts
53+
addpackage nodejs # 23 as of 20241222
54+
# alternatively, nodejs-lts-iron for 20 or nodejs-lts-hydrogen for 18
55+
# I only found 20, not 22 - https://archlinux.org/packages/?sort=&q=nodejs&maintainer=&flagged=
56+
addpackage yarn
57+
58+
# Some packages that you likely already have, but we'll just make sure
59+
addpackage git
60+
addpackage zip
61+
addpackage unzip
62+
addpackage tar
63+
addpackage curl # required by vcpkg
64+
addpackage pkgconf # required by Catch2 (C++ testing framework)
65+
addpackage linux-headers # required by OpenSSL(?)
66+
67+
echo Will now run the installation command, please check it and confirm
68+
set -x # this will print the list that we're going to install
69+
sudo pacman -S --needed $PACMAN_ARGS $packages

0 commit comments

Comments
 (0)