Skip to content

Commit 6da4a5b

Browse files
authored
Refactor CI workflow for spaceether project
1 parent efd1169 commit 6da4a5b

File tree

1 file changed

+14
-109
lines changed

1 file changed

+14
-109
lines changed
Lines changed: 14 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,38 @@
1-
name: spaceether-ci
1+
name: CI
22

33
on:
44
push:
55
pull_request:
66

7-
concurrency:
8-
group: spaceether-${{ github.ref }}
9-
cancel-in-progress: true
10-
117
jobs:
128
build-and-test:
139
runs-on: ubuntu-latest
1410
strategy:
15-
fail-fast: false
1611
matrix:
17-
compiler: [gcc, clang]
18-
sanitize: [OFF, ON]
19-
20-
env:
21-
BUILD_DIR: build-${{ matrix.compiler }}-${{ matrix.sanitize }}
12+
build_type: [Release, Debug]
2213

2314
steps:
2415
- name: Checkout
2516
uses: actions/checkout@v4
2617

27-
- name: Ensure no committed build cache (defense-in-depth)
28-
run: |
29-
if [ -d build ]; then
30-
echo "::warning::Removing stale committed 'build/' directory."
31-
git rm -r --cached build || true
32-
rm -rf build
33-
fi
34-
35-
- name: Install deps
18+
- name: Install dependencies
3619
run: |
3720
sudo apt-get update
38-
sudo apt-get install -y build-essential cmake clang clang-tidy ccache python3
39-
40-
- name: Select compiler
41-
run: |
42-
if [ "${{ matrix.compiler }}" = "clang" ]; then
43-
echo "CC=clang" >> $GITHUB_ENV
44-
echo "CXX=clang++" >> $GITHUB_ENV
45-
else
46-
echo "CC=gcc" >> $GITHUB_ENV
47-
echo "CXX=g++" >> $GITHUB_ENV
48-
fi
21+
sudo apt-get install -y cmake g++ ninja-build
4922
50-
- name: Enable ccache
23+
- name: Configure
5124
run: |
52-
echo "CMAKE_C_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
53-
echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache" >> $GITHUB_ENV
54-
- name: ccache cache
55-
uses: actions/cache@v4
56-
with:
57-
path: ~/.cache/ccache
58-
key: ccache-${{ matrix.compiler }}-${{ matrix.sanitize }}-${{ github.ref }}-${{ github.sha }}
59-
restore-keys: |
60-
ccache-${{ matrix.compiler }}-${{ matrix.sanitize }}-${{ github.ref }}-
61-
ccache-${{ matrix.compiler }}-${{ matrix.sanitize }}-
62-
ccache-
63-
64-
- name: Configure (fresh build dir)
65-
run: |
66-
cmake -E rm -rf "$BUILD_DIR"
67-
cmake -S . -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSPACEE_SANITIZE=${{ matrix.sanitize }} -DSPACEE_BUILD_RS=OFF -DSPACEE_ENABLE_AUTH=OFF -DCMAKE_C_FLAGS="-Wall -Wextra -Wpedantic -Werror" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Werror" -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
25+
cmake -S . -B build \
26+
-G Ninja \
27+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
28+
-DSPACEE_BUILD_TESTS=ON \
29+
-DSPACEE_BUILD_TOOLS=OFF \
30+
-DSPACEE_ENABLE_AUTH=ON
6831
6932
- name: Build
70-
run: cmake --build "$BUILD_DIR" -j
71-
72-
- name: CTest
73-
run: ctest --test-dir "$BUILD_DIR" --output-on-failure
74-
75-
- name: Clang-Tidy (report only)
76-
continue-on-error: true
7733
run: |
78-
if [ -f "$BUILD_DIR/compile_commands.json" ]; then
79-
mapfile -t FILES < <(git ls-files | grep -E '\.(c|cc|cpp|cxx|h|hpp)$')
80-
if [ "${#FILES[@]}" -gt 0 ]; then
81-
echo "Running clang-tidy on ${#FILES[@]} files..."
82-
clang-tidy -p "$BUILD_DIR" "${FILES[@]}" || true
83-
fi
84-
else
85-
echo "No compile_commands.json; skipping clang-tidy."
86-
fi
87-
88-
- name: Upload test logs (always)
89-
if: always()
90-
uses: actions/upload-artifact@v4
91-
with:
92-
name: ctest-logs-${{ matrix.compiler }}-${{ matrix.sanitize }}
93-
path: |
94-
${{ env.BUILD_DIR }}/Testing/Temporary/LastTest.log
95-
if-no-files-found: ignore
34+
cmake --build build --parallel 2
9635
97-
ros2-demo:
98-
needs: build-and-test
99-
runs-on: ubuntu-latest
100-
container: osrf/ros:humble-desktop
101-
steps:
102-
- name: Checkout
103-
uses: actions/checkout@v4
104-
105-
- name: Preflight
106-
id: preflight
36+
- name: Test
10737
run: |
108-
if [ ! -f tools/run_ros2_demo.sh ]; then
109-
echo "missing_script=true" >> $GITHUB_OUTPUT
110-
fi
111-
112-
- name: Install build tools
113-
if: steps.preflight.outputs.missing_script != 'true'
114-
run: |
115-
apt-get update
116-
apt-get install -y build-essential cmake coreutils grep
117-
118-
- name: Run demo (loopback)
119-
if: steps.preflight.outputs.missing_script != 'true'
120-
env:
121-
SPACEE_TEST_UNICAST: "1"
122-
run: |
123-
chmod +x tools/run_ros2_demo.sh
124-
cmake -E rm -rf build
125-
bash tools/run_ros2_demo.sh
126-
127-
- name: Upload echo log (always)
128-
if: always()
129-
uses: actions/upload-artifact@v4
130-
with:
131-
name: spaceether_echo_log
132-
path: /tmp/spaceether_echo.log
133-
if-no-files-found: ignore
38+
ctest --test-dir build --output-on-failure

0 commit comments

Comments
 (0)