-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (104 loc) · 3.5 KB
/
cmake-workflow.yml
File metadata and controls
123 lines (104 loc) · 3.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
name: CMake workflow
on:
push:
branches: ["main", "camera-2.0"]
pull_request:
branches: ["main", "camera-2.0"]
workflow_dispatch:
inputs:
target:
description: "Optional build target or instrument name (leave blank for default build)"
required: false
default: ""
type: string
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
BUILD_TYPE: Release
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve requested target
shell: bash
run: |
TARGET_NAME="${{ github.event.inputs.target }}"
echo "TARGET_NAME=${TARGET_NAME}" >> "$GITHUB_ENV"
if [[ -z "$TARGET_NAME" ]]; then
echo "Default build requested"
else
echo "Requested target: $TARGET_NAME"
fi
- name: Install dependencies
shell: bash
run: |
bash .github/workflows/install-deps.sh
- name: Build and install zmqpp from source
shell: bash
run: |
git clone --depth 1 https://github.com/zeromq/zmqpp.git /tmp/zmqpp
cmake -S /tmp/zmqpp -B /tmp/zmqpp/build
cmake --build /tmp/zmqpp/build -j"$(nproc)"
sudo cmake --install /tmp/zmqpp/build
sudo ldconfig
- name: Rewrite GitHub SSH URLs for submodules
shell: bash
run: |
git config --global url."https://github.com/".insteadOf "git@github.com:"
git submodule sync --recursive
- name: Update matching submodule
if: env.TARGET_NAME != '' && env.TARGET_NAME != 'emulator'
shell: bash
run: |
if [[ ! -f .gitmodules ]]; then
echo "No .gitmodules file found; skipping submodule update."
exit 0
fi
MATCH_PATH=$(git config -f .gitmodules --get-regexp '^submodule\..*\.path$' | awk -v target="$TARGET_NAME" '
$2 == target { print $2; exit }
$2 ~ "/" target "$" { print $2; exit }
')
if [[ -z "$MATCH_PATH" ]]; then
echo "No submodule path matched '$TARGET_NAME'; continuing without submodule update."
exit 0
fi
echo "Matched submodule path: $MATCH_PATH"
git submodule sync -- "$MATCH_PATH"
git submodule update --init --recursive --remote -- "$MATCH_PATH"
- name: Configure CMake
shell: bash
run: |
mkdir -p build
cd build
CMAKE_ARGS=(
-G Ninja
-DCMAKE_BUILD_TYPE=${BUILD_TYPE}
-DCONTROLLER=archon
)
if [[ -n "$TARGET_NAME" && "$TARGET_NAME" != "emulator" ]]; then
CMAKE_ARGS+=("-DINSTRUMENT=${TARGET_NAME}")
fi
cmake "${CMAKE_ARGS[@]}" ..
- name: Build default
if: env.TARGET_NAME == ''
shell: bash
run: |
cmake --build build -j"$(nproc)"
if cmake --build build --target run_unit_tests -j"$(nproc)"; then
./bin/run_unit_tests
else
echo "run_unit_tests target not available; skipping unit tests."
fi
- name: Build emulator target
if: env.TARGET_NAME == 'emulator'
shell: bash
run: |
cmake --build build --target emulator -j"$(nproc)"
- name: Build named target
if: env.TARGET_NAME != '' && env.TARGET_NAME != 'emulator'
shell: bash
run: |
cmake --build build -j"$(nproc)"