forked from AhmedAredah/CargoNetSim
-
Notifications
You must be signed in to change notification settings - Fork 0
227 lines (199 loc) · 7.76 KB
/
Copy pathci.yml
File metadata and controls
227 lines (199 loc) · 7.76 KB
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# TODO:
# - Keep Container available to GitHub Actions through CONTAINER_REPO_TOKEN,
# or move it to a vendored, submodule, GitHub Packages, or self-hosted runner
# setup before making build-linux mandatory.
# - Keep KDReports pinned to a release tag and make build-linux required only
# after dependency bootstrap is stable in CI.
# - Make clang-format blocking after the existing source tree has been
# formatted once.
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
permissions:
contents: read
env:
BUILD_TYPE: Release
CONTAINER_REF: v0.2.0
KDREPORTS_REF: kdreports-2.3.0
jobs:
lint:
name: Lint
runs-on: ubuntu-24.04
steps:
- name: Check out CargoNetSim
uses: actions/checkout@v4
- name: Install lint dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: cmake clang-format
version: 1.0
- name: Check root CMake file
run: cmake -E cat CMakeLists.txt > /dev/null
- name: Write markdownlint configuration
run: |
cat > .markdownlint-cli2.jsonc <<'JSON'
{
"config": {
"MD012": false,
"MD013": false,
"MD022": false,
"MD032": false,
"MD033": false,
"MD034": false,
"MD041": false
}
}
JSON
- name: Lint Markdown
uses: DavidAnson/markdownlint-cli2-action@v23.1.0
with:
config: .markdownlint-cli2.jsonc
globs: "*.md"
- name: Check clang-format
if: ${{ hashFiles('.clang-format') != '' }}
shell: bash
run: |
shopt -s globstar nullglob
files=(src/**/*.cpp src/**/*.h)
if (( ${#files[@]} == 0 )); then
echo "No C++ source files found."
exit 0
fi
if clang-format --dry-run --Werror "${files[@]}"; then
echo "clang-format completed successfully."
else
echo "::warning::clang-format found existing source formatting drift. This advisory check can become blocking after the source tree is formatted once."
fi
build-linux:
name: Build Linux
runs-on: ubuntu-24.04
continue-on-error: true
env:
DEPS_PREFIX: ${{ github.workspace }}/deps/install
CMAKE_BUILD_PARALLEL_LEVEL: 2
CMAKE_CXX_COMPILER_LAUNCHER: ccache
steps:
- name: Check out CargoNetSim
uses: actions/checkout@v4
- name: Check Container token
env:
CONTAINER_REPO_TOKEN: ${{ secrets.CONTAINER_REPO_TOKEN }}
run: |
if [ -z "${CONTAINER_REPO_TOKEN}" ]; then
echo "::error::CONTAINER_REPO_TOKEN is required to check out the private Container dependency."
exit 1
fi
- name: Check out Container
uses: actions/checkout@v4
with:
repository: AhmedAredah/container
token: ${{ secrets.CONTAINER_REPO_TOKEN }}
ref: ${{ env.CONTAINER_REF }}
path: deps/container
- name: Check out KDReports
uses: actions/checkout@v4
with:
repository: KDAB/KDReports
ref: ${{ env.KDREPORTS_REF }}
path: deps/kdreports
- name: Install build dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: cmake qt6-base-dev qt6-tools-dev libyaml-cpp-dev librabbitmq-dev build-essential ninja-build ccache
version: 1.0
- name: Prepare RabbitMQ-C include compatibility
run: |
mkdir -p "${DEPS_PREFIX}/include/rabbitmq-c"
for header in /usr/include/amqp*.h; do
ln -sf "${header}" "${DEPS_PREFIX}/include/rabbitmq-c/$(basename "${header}")"
done
ln -sf /usr/include/amqp_tcp_socket.h "${DEPS_PREFIX}/include/rabbitmq-c/tcp_socket.h"
- name: Cache CMake build and compiler output
uses: actions/cache@v4
with:
path: |
~/.ccache
build
key: ${{ runner.os }}-cmake-${{ hashFiles('CMakeLists.txt', 'cmake/**') }}
restore-keys: |
${{ runner.os }}-cmake-
- name: Configure Container
run: |
cmake -S deps/container -B deps/build/container -G Ninja \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
-DCMAKE_INSTALL_PREFIX="${DEPS_PREFIX}" \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_PYTHON_BINDINGS=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_DOCS=OFF \
-DCMAKE_CXX_COMPILER_LAUNCHER="${CMAKE_CXX_COMPILER_LAUNCHER}"
- name: Install Container
run: cmake --build deps/build/container --target install
- name: Configure KDReports
run: |
cmake -S deps/kdreports -B deps/build/kdreports -G Ninja \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
-DCMAKE_INSTALL_PREFIX="${DEPS_PREFIX}" \
-DKDReports_QT6=ON \
-DKDReports_TESTS=OFF \
-DKDReports_EXAMPLES=OFF \
-DKDReports_DOCS=OFF \
-DKDReports_PYTHON_BINDINGS=OFF \
-DCMAKE_CXX_COMPILER_LAUNCHER="${CMAKE_CXX_COMPILER_LAUNCHER}"
- name: Install KDReports
run: cmake --build deps/build/kdreports --target install
- name: Patch KDReports Qt6 package config
run: |
config_file="${DEPS_PREFIX}/lib/cmake/KDReports-qt6/KDReports-qt6Config.cmake"
sed -i \
-e 's/find_dependency(QtCore /find_dependency(Qt6Core /' \
-e 's/find_dependency(QtWidgets /find_dependency(Qt6Widgets /' \
-e 's/find_dependency(QtPrintSupport /find_dependency(Qt6PrintSupport /' \
-e 's/find_dependency(QtXml /find_dependency(Qt6Xml /' \
"${config_file}"
- name: Configure CargoNetSim
id: configure-cargonet
run: |
if cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
-DCMAKE_PREFIX_PATH="${DEPS_PREFIX};/usr" \
-DCONTAINER_CMAKE_DIR="${DEPS_PREFIX}/lib/cmake/Container" \
-DKDREPORTS_DIR="${DEPS_PREFIX}/lib/cmake/KDReports-qt6" \
-DRABBITMQ_CMAKE_DIR="/usr/lib/x86_64-linux-gnu/cmake/rabbitmq-c" \
-DYAMLCPP_CMAKE_DIR="/usr/lib/x86_64-linux-gnu/cmake/yaml-cpp" \
-DCARGONET_BUILD_TESTS=OFF \
-DCARGONET_BUILD_INSTALLER=OFF \
-DCARGONET_BUILD_RABBITMQ_CONFIG=OFF \
-DCMAKE_CXX_COMPILER_LAUNCHER="${CMAKE_CXX_COMPILER_LAUNCHER}"; then
echo "configured=true" >> "${GITHUB_OUTPUT}"
else
echo "configured=false" >> "${GITHUB_OUTPUT}"
echo "::warning::CargoNetSim configure failed. build-linux is advisory until dependency bootstrap is stable in CI."
fi
- name: Build CargoNetSim
id: build-cargonet
if: ${{ steps.configure-cargonet.outputs.configured == 'true' }}
run: |
if cmake --build build; then
echo "built=true" >> "${GITHUB_OUTPUT}"
else
echo "built=false" >> "${GITHUB_OUTPUT}"
echo "::warning::CargoNetSim build failed. build-linux is advisory until dependency bootstrap and source build compatibility are stable in CI."
fi
- name: Report advisory build result
if: ${{ always() }}
run: |
if [ "${{ steps.configure-cargonet.outputs.configured }}" != "true" ]; then
echo "CargoNetSim configure did not complete; see the advisory warning above."
exit 0
fi
if [ "${{ steps.build-cargonet.outputs.built }}" != "true" ]; then
echo "CargoNetSim build did not complete; see the advisory warning above."
exit 0
fi
echo "CargoNetSim configure and build completed successfully."