-
Notifications
You must be signed in to change notification settings - Fork 0
230 lines (189 loc) · 7.14 KB
/
Copy pathbuild_linux.yml
File metadata and controls
230 lines (189 loc) · 7.14 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
# Dieser Workflow
# - Baut die Tests für x86_64 führt sie aus
# - Erstellt SBOM wird und prüft sie auf Schwachstellen in den Abhängigkeiten
# Dazu werden zunächst die Abhängigkeiten gebaut und gecached.
#
# Vorbedingung:
# - Die Conan-Lockdatei (conan_linux.lock) muss existieren.
name: Build and Test for Linux
on:
push:
branches: [ "main", "v1*", "v2*", "v3*" ]
pull_request:
branches: [ "main", "v1*", "v2*", "v3*" ]
jobs:
# Bereitet die Abhängigkeiten für Linux x86_64 vor.
# Dies ist ein separater Job, da dies sehr lange dauern (30-60 Min, falls alles gebaut werden muss) kann und das Ergebnis gecached werden soll, auch wenn das Bauen später fehlschlägt.
build_dependencies_pc:
runs-on: CPR_Ubuntu2404
timeout-minutes: 90
steps:
- uses: actions/checkout@v7
- uses: CommonplaceRobotics/Action_Build_Conan_Dependencies/Linux_x86_64@v1
with:
lockfile: 'conan_linux.lock'
cache_key: conan-${{ runner.os }}-x86_64-${{ hashFiles('**/conan_linux.lock', '**/conanfile.py') }}
# Bereitet die Abhängigkeiten für RPi vor.
# Separater Job mit selber Begründung wie oben.
build_dependencies_rpi:
runs-on: CPR_Ubuntu2404
timeout-minutes: 90
steps:
- uses: actions/checkout@v7
- uses: CommonplaceRobotics/Action_Build_Conan_Dependencies/Linux_armv8_32@v1
with:
lockfile: 'conan_linux.lock'
cache_key: conan-${{ runner.os }}-armv8_32-${{ hashFiles('**/conan_linux.lock', '**/conanfile.py') }}
# Build and run tests for Linux x86_64
test:
#runs-on: ubuntu-latest
runs-on: CPR_Ubuntu2404
timeout-minutes: 15
needs: build_dependencies_pc
steps:
- uses: actions/checkout@v7
- name: Restore cached dependencies
id: cache
uses: actions/cache/restore@v5
with:
path: |
~/.conan2
out
key: conan-${{ runner.os }}-x86_64-${{ hashFiles('conan_linux.lock', 'conanfile.py') }}
fail-on-cache-miss: true
- name: Install Conan
uses: conan-io/setup-conan@v1
- name: Configure CMake
run: |
rm -f CMakePresets.json
echo "{\"version\": 4,\"include\":[\"out/conan/Linux/x86_64/Release/generators/CMakePresets.json\"]}" >> CMakePresets.json
cmake --preset conan-linux-x86_64-release
- name: Build Tests (x86_64)
run: |
cd out/build/Linux/x86_64/Release
cmake --build . --target iRCApp_Tests
- name: Run Tests
run: |
cd out/build/Linux/x86_64/Release
./iRCApp_Tests
- name: Rename Library
run: mv out/build/Linux/x86_64/Release/libiRCApp.a out/build/Linux/x86_64/Release/libiRCApp_x86_64.a
- name: Export Library
uses: actions/upload-artifact@v7
with:
name: libiRCApp_x86_64.a
path: out/build/Linux/x86_64/Release/libiRCApp_x86_64.a
archive: false
# Build for RPi
build_rpi:
#runs-on: ubuntu-latest
runs-on: CPR_Ubuntu2404
timeout-minutes: 15
needs: build_dependencies_rpi
steps:
- uses: actions/checkout@v7
- name: Restore cached dependencies
id: cache
uses: actions/cache/restore@v5
with:
path: |
~/.conan2
out
key: conan-${{ runner.os }}-armv8_32-${{ hashFiles('conan_linux.lock', 'conanfile.py') }}
fail-on-cache-miss: true
- name: Install RPi Cross-Compiler
uses: CommonplaceRobotics/Action_Build_Conan_Dependencies/Install_Toolchain_armv8_32@v1
- name: Install Conan
uses: conan-io/setup-conan@v1
- name: Configure CMake
run: |
rm -f CMakePresets.json
echo "{\"version\": 4,\"include\":[\"out/conan/Linux/armv8_32/Release/generators/CMakePresets.json\"]}" >> CMakePresets.json
cmake --preset conan-linux-armv8_32-release
- name: Build Library (armv8_32)
run: |
cd out/build/Linux/armv8_32/Release
cmake --build . --target iRCApp
- name: Rename Library
run: mv out/build/Linux/armv8_32/Release/libiRCApp.a out/build/Linux/armv8_32/Release/libiRCApp_armv8_32.a
- name: Export Library
uses: actions/upload-artifact@v7
with:
name: libiRCApp_armv8_32.a
path: out/build/Linux/armv8_32/Release/libiRCApp_armv8_32.a
archive: false
# Creates the SBOM and checks its compliance
sbom:
runs-on: ubuntu-latest
timeout-minutes: 15
needs: build_rpi
steps:
- uses: actions/checkout@v7
- name: Restore cached dependencies
id: cache
uses: actions/cache/restore@v5
with:
path: |
~/.conan2
out
key: conan-${{ runner.os }}-armv8_32-${{ hashFiles('conan_linux.lock', 'conanfile.py') }}
fail-on-cache-miss: true
# This is needed so CMake can run, we won't compile anything here
- name: Install RPi Cross-Compiler
uses: CommonplaceRobotics/Action_Build_Conan_Dependencies/Install_Toolchain_armv8_32@v1
# This generates sbomify.json with lifecycle info
- name: Configure CMake
run: |
rm -f CMakePresets.json
echo "{\"version\": 4,\"include\":[\"out/conan/Linux/armv8_32/Release/generators/CMakePresets.json\"]}" >> CMakePresets.json
cmake --preset conan-linux-armv8_32-release
mv out/build/Linux/armv8_32/Release/sbomify.json .
# We need the library to calculate its hash
- name: Import Library
uses: actions/download-artifact@v8
with:
name: libiRCApp_armv8_32.a
path: out/build/Linux/armv8_32/Release
- name: Rename Library
run: mv out/build/Linux/armv8_32/Release/libiRCApp_armv8_32.a out/build/Linux/armv8_32/Release/libiRCApp.a
# Liest die Core-Version aus CMakeLists.txt
- name: Get software version
run: |
VER=`grep -E -o "VERSION[[:blank:]]+[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+" CMakeLists.txt | sed "s/[^0-9.]*//g"`
echo "Software version '$VER' detected"
echo "SW_VERSION=$VER" >> $GITHUB_ENV
- name: Create incomplete SBOM
uses: CommonplaceRobotics/SW_Create_Conan_SBOM@v1
with:
lockfile: conan_linux.lock
sbom: sbom_temp1.cdx.json
- name: Enrich and Augment SBOM
uses: sbomify/sbomify-action@master
env:
SBOM_FILE: sbom_temp1.cdx.json
OUTPUT_FILE: sbom_temp2.cdx.json
COMPONENT_NAME: AppAPI_CPP
COMPONENT_VERSION: ${{ env.SW_VERSION }}
# Produkt- und Firmeninfo werden aus sbomify.json geladen
AUGMENT: true
# Metadaten aus Paket-Registry hinzufügen
ENRICH: true
# Metadaten aus additional_packages_rpi.txt hinzufügen
ADDITIONAL_PACKAGES_FILE: additional_packages_rpi.txt
UPLOAD: false
- name: Final SBOM enrichment
uses: CommonplaceRobotics/Action_SBOM_Enrichment@v4
with:
database: .github/workflows/sbom_enrichment_db.json
sbom: sbom_temp2.cdx.json
sbom_out: sbom_rpi.cdx.json
cmake_build_dir: out/build/Linux/armv8_32/Release
- name: Export SBOM
uses: actions/upload-artifact@v7
with:
path: sbom_rpi.cdx.json
archive: false
- name: Validate SBOM with company policies
uses: CommonplaceRobotics/SW_Validate_SBOM@v1
with:
sbom: sbom_rpi.cdx.json