Repository navigation
278 lines (269 loc) · 11.5 KB
/
Copy pathci.yml
File metadata and controls
278 lines (269 loc) · 11.5 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
name: CI
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
concurrency:
group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
LINUXCNC_REPOSITORY: LinuxCNC/linuxcnc
LINUXCNC_CACHE_VERSION: v5
jobs:
patch-stack:
name: LinuxCNC patch stack tooling
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Test patch stack tooling
run: ./linuxcnc-patches/test-stack.sh
native-format:
name: Native format
runs-on: ubuntu-24.04
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install clang-format 21
run: |
python3 -m venv "${RUNNER_TEMP}/clang-format"
"${RUNNER_TEMP}/clang-format/bin/python" -m pip install \
--disable-pip-version-check \
--only-binary=:all: \
clang-format==21.1.8
- name: Check native formatting
run: ./scripts/native-format.sh check
env:
CLANG_FORMAT: ${{ runner.temp }}/clang-format/bin/clang-format
prepare-linuxcnc:
name: Prepare LinuxCNC
runs-on: ubuntu-24.04
outputs:
cache-key: ${{ steps.linuxcnc-baseline.outputs.cache-key }}
revision: ${{ steps.linuxcnc-baseline.outputs.revision }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Read LinuxCNC base revision and cache key
id: linuxcnc-baseline
shell: bash
run: |
revision="$(< linuxcnc-patches/base-revision)"
cache_key="linuxcnc-${RUNNER_OS}-${RUNNER_ARCH}-${revision}-${LINUXCNC_CACHE_VERSION}-${{ hashFiles('linuxcnc-patches/base-revision', 'linuxcnc-patches/*.patch', 'linuxcnc-patches/apply.sh') }}"
echo "revision=${revision}" >> "${GITHUB_OUTPUT}"
echo "cache-key=${cache_key}" >> "${GITHUB_OUTPUT}"
- name: Restore LinuxCNC build
id: linuxcnc-cache
uses: actions/cache/restore@v4
with:
path: .cache/linuxcnc/${{ steps.linuxcnc-baseline.outputs.revision }}/linuxcnc
key: ${{ steps.linuxcnc-baseline.outputs.cache-key }}
- name: Validate cached LinuxCNC build
if: steps.linuxcnc-cache.outputs.cache-hit == 'true'
shell: bash
env:
LINUXCNC_DIR: ${{ github.workspace }}/.cache/linuxcnc/${{ steps.linuxcnc-baseline.outputs.revision }}/linuxcnc
run: |
test -x "${LINUXCNC_DIR}/scripts/linuxcnc"
test -e "${LINUXCNC_DIR}/lib/liblinuxcncini.so"
- name: Check out LinuxCNC
if: steps.linuxcnc-cache.outputs.cache-hit != 'true'
shell: bash
env:
LINUXCNC_DIR: ${{ github.workspace }}/.cache/linuxcnc/${{ steps.linuxcnc-baseline.outputs.revision }}/linuxcnc
LINUXCNC_REF: ${{ steps.linuxcnc-baseline.outputs.revision }}
run: |
set -euo pipefail
mkdir -p "$(dirname "${LINUXCNC_DIR}")"
git init "${LINUXCNC_DIR}"
git -C "${LINUXCNC_DIR}" remote add origin "https://github.com/${LINUXCNC_REPOSITORY}.git"
git -C "${LINUXCNC_DIR}" fetch --depth=1 origin "${LINUXCNC_REF}"
git -C "${LINUXCNC_DIR}" checkout --detach FETCH_HEAD
- name: Apply LinuxCNC patches
if: steps.linuxcnc-cache.outputs.cache-hit != 'true'
shell: bash
env:
LINUXCNC_DIR: ${{ github.workspace }}/.cache/linuxcnc/${{ steps.linuxcnc-baseline.outputs.revision }}/linuxcnc
LINUXCNC_REF: ${{ steps.linuxcnc-baseline.outputs.revision }}
run: |
set -euo pipefail
"${GITHUB_WORKSPACE}/linuxcnc-patches/apply.sh" --detach "${LINUXCNC_DIR}"
patch_count="$(find "${GITHUB_WORKSPACE}/linuxcnc-patches" -maxdepth 1 -name '*.patch' | wc -l)"
commit_count="$(git -C "${LINUXCNC_DIR}" rev-list --count "${LINUXCNC_REF}..HEAD")"
test "${commit_count}" -eq "${patch_count}"
test -z "$(git -C "${LINUXCNC_DIR}" status --porcelain --untracked-files=all)"
- name: Install LinuxCNC build dependencies
if: steps.linuxcnc-cache.outputs.cache-hit != 'true'
shell: bash
env:
LINUXCNC_DIR: ${{ github.workspace }}/.cache/linuxcnc/${{ steps.linuxcnc-baseline.outputs.revision }}/linuxcnc
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y build-essential dpkg-dev
cd "${LINUXCNC_DIR}"
export DEB_BUILD_PROFILES="pkg.linuxcnc.headless nodoc"
./debian/configure no-docs
if ! sudo env DEB_BUILD_PROFILES="${DEB_BUILD_PROFILES}" apt-get -P "pkg.linuxcnc.headless,nodoc" build-dep -y --no-install-recommends .; then
dpkg-checkbuilddeps || true
exit 1
fi
- name: Build LinuxCNC
if: steps.linuxcnc-cache.outputs.cache-hit != 'true'
shell: bash
env:
LINUXCNC_DIR: ${{ github.workspace }}/.cache/linuxcnc/${{ steps.linuxcnc-baseline.outputs.revision }}/linuxcnc
run: |
set -euo pipefail
cd "${LINUXCNC_DIR}/src"
./autogen.sh
./configure --with-realtime=uspace \
--enable-headless \
--disable-build-documentation \
--disable-build-manpages
make -j"$(nproc)"
- name: Save LinuxCNC build
if: steps.linuxcnc-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: .cache/linuxcnc/${{ steps.linuxcnc-baseline.outputs.revision }}/linuxcnc
key: ${{ steps.linuxcnc-baseline.outputs.cache-key }}
native-build-test:
name: Native build and test
needs: prepare-linuxcnc
runs-on: ubuntu-24.04
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install native dependencies
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential ccache cmake libarchive-dev libboost-dev \
libboost-python-dev libedit2 libfmt9 libgrpc++-dev libgrpc-dev \
libmodbus5 libprotobuf-dev libssl-dev libtirpc3t64 libudev1 \
libusb-1.0-0 procps protobuf-compiler protobuf-compiler-grpc psmisc \
python3-cryptography python3-dev
- name: Restore LinuxCNC build
uses: actions/cache/restore@v4
with:
path: .cache/linuxcnc/${{ needs.prepare-linuxcnc.outputs.revision }}/linuxcnc
key: ${{ needs.prepare-linuxcnc.outputs.cache-key }}
fail-on-cache-miss: true
- name: Restore native compiler cache
uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: native-ccache-${{ runner.os }}-${{ runner.arch }}-${{ needs.prepare-linuxcnc.outputs.revision }}-${{ github.sha }}
restore-keys: |
native-ccache-${{ runner.os }}-${{ runner.arch }}-${{ needs.prepare-linuxcnc.outputs.revision }}-
- name: Set LinuxCNC runtime permissions
env:
LINUXCNC_DIR: ${{ github.workspace }}/.cache/linuxcnc/${{ needs.prepare-linuxcnc.outputs.revision }}/linuxcnc
run: sudo make -C "${LINUXCNC_DIR}/src" setuid
- name: Configure native LinuxCNC daemon
env:
LINUXCNC_DIR: ${{ github.workspace }}/.cache/linuxcnc/${{ needs.prepare-linuxcnc.outputs.revision }}/linuxcnc
run: |
cmake -S . -B build/native-grpc-linuxcnc \
-DLINUXCNC_ROOT="${LINUXCNC_DIR}" \
-DLINUXCNC_GRPC_BUILD_WIRE=ON \
-DLINUXCNC_GRPC_BUILD_TESTS=ON \
-DLINUXCNC_GRPC_BUILD_LISTENER_TESTS=ON \
-DLINUXCNC_BUILD_TRANSPORT=ON \
-DLINUXCNC_GRPC_ENABLE_NML=ON \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_BUILD_TYPE=Debug
- name: Build native LinuxCNC daemon
run: cmake --build build/native-grpc-linuxcnc --parallel "$(nproc)"
- name: Test native LinuxCNC daemon
shell: bash
env:
LINUXCNC_DIR: ${{ github.workspace }}/.cache/linuxcnc/${{ needs.prepare-linuxcnc.outputs.revision }}/linuxcnc
run: |
set -euo pipefail
set +u
source "${LINUXCNC_DIR}/scripts/rip-environment"
set -u
export LINUXCNC_INCLUDE="${LINUXCNC_DIR}/include"
export LINUXCNC_LIB="${LINUXCNC_DIR}/lib"
ctest --test-dir build/native-grpc-linuxcnc --output-on-failure
- name: Report compiler cache statistics
if: always()
run: ccache --show-stats
native-lint:
name: Native lint
needs: prepare-linuxcnc
runs-on: ubuntu-24.04
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install LLVM apt repository
run: |
set -euo pipefail
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key \
| sudo tee /etc/apt/keyrings/apt.llvm.org.asc >/dev/null
echo 'deb [signed-by=/etc/apt/keyrings/apt.llvm.org.asc] https://apt.llvm.org/noble/ llvm-toolchain-noble-21 main' \
| sudo tee /etc/apt/sources.list.d/llvm-21.list >/dev/null
- name: Install native and Clang dependencies
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential clang-tidy-21 clang-tools-21 cmake \
libarchive-dev libboost-dev libgrpc++-dev libgrpc-dev \
libprotobuf-dev libssl-dev protobuf-compiler protobuf-compiler-grpc \
python3-dev
- name: Restore LinuxCNC build
uses: actions/cache/restore@v4
with:
path: .cache/linuxcnc/${{ needs.prepare-linuxcnc.outputs.revision }}/linuxcnc
key: ${{ needs.prepare-linuxcnc.outputs.cache-key }}
fail-on-cache-miss: true
- name: Configure native LinuxCNC daemon
env:
LINUXCNC_DIR: ${{ github.workspace }}/.cache/linuxcnc/${{ needs.prepare-linuxcnc.outputs.revision }}/linuxcnc
run: |
cmake -S . -B build/native-grpc-linuxcnc \
-DLINUXCNC_ROOT="${LINUXCNC_DIR}" \
-DLINUXCNC_GRPC_BUILD_WIRE=ON \
-DLINUXCNC_GRPC_BUILD_TESTS=ON \
-DLINUXCNC_GRPC_BUILD_LISTENER_TESTS=ON \
-DLINUXCNC_BUILD_TRANSPORT=ON \
-DLINUXCNC_GRPC_ENABLE_NML=ON \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_BUILD_TYPE=Debug
- name: Generate native protobuf headers
run: cmake --build build/native-grpc-linuxcnc --target linuxcnc-grpc-proto --parallel "$(nproc)"
- name: Lint native LinuxCNC sources
run: ./scripts/native-lint.sh build/native-grpc-linuxcnc
env:
CLANG_TIDY: clang-tidy-21
RUN_CLANG_TIDY: run-clang-tidy-21
container:
name: linuxcnc-simulator container
if: github.event_name == 'pull_request'
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build test image
uses: docker/build-push-action@v7
with:
context: .
target: test
load: true
tags: linuxcnc-simulator:test
build-args: BUILD_JOBS=4
cache-from: type=gha,scope=linuxcnc-simulator-amd64
cache-to: type=gha,mode=max,scope=linuxcnc-simulator-amd64
- name: Run full-stack container acceptance test
run: ./docker/acceptance-test.sh linuxcnc-simulator:test