-
Notifications
You must be signed in to change notification settings - Fork 32
340 lines (295 loc) · 11 KB
/
Copy pathbuild_cross.yml
File metadata and controls
340 lines (295 loc) · 11 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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
---
name: Cross Compilation
on:
workflow_dispatch:
pull_request:
branches:
- develop
push:
branches:
- develop
jobs:
pkvisor:
name: pktvisor
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
conan_arch: x86_64
toolchain: https://github.com/netboxlabs/pktvisor/releases/download/toolchains/x86_64-linux-musl-cross.tgz
cc: x86_64-linux-musl-gcc
cxx: x86_64-linux-musl-g++
ldflags: "-static"
# - arch: armv7lh # ARMv7 little-endian hard-float
# conan_arch: armv7hf
# toolchain: https://github.com/netboxlabs/pktvisor/releases/download/toolchains/armv7l-linux-musleabihf-cross.tgz
# cc: armv7l-linux-musleabihf-gcc
# cxx: armv7l-linux-musleabihf-g++
- arch: aarch64
conan_arch: armv8
toolchain: https://github.com/netboxlabs/pktvisor/releases/download/toolchains/aarch64-linux-musl-cross.tgz
cc: aarch64-linux-musl-gcc
cxx: aarch64-linux-musl-g++
ldflags: "-static"
env:
CC: gcc
CXX: g++
steps:
- name: Install sccache from cache
id: cache-sccache
uses: actions/cache@v5
with:
path: bin/sccache
key: sccache-v0.2.15
- name: Install sccache
if: steps.cache-sccache.outputs.cache-hit != 'true'
run: |
mkdir -p bin
curl -L https://github.com/mozilla/sccache/releases/download/v0.2.15/sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz | \
tar -C bin -xz --strip-components=1 sccache-v0.2.15-x86_64-unknown-linux-musl/sccache
chmod +x bin/sccache
- name: Install compiler toolchain from cache
id: cache-toolchain
uses: actions/cache@v5
with:
path: toolchain
key: toolchain-test-${{matrix.toolchain}}
- name: Install compiler toolchain
if: steps.cache-toolchain.outputs.cache-hit != 'true'
run: |
mkdir -p toolchain
curl -L "${{matrix.toolchain}}" | tar -C toolchain -xz --strip-components=1
- name: Install Conan
run: pip install --no-cache-dir conan --force-reinstall
- name: Restore sccache
uses: actions/cache@v5
with:
path: ~/.cache/sccache
key: sccache-${{matrix.arch}}-${{github.head_ref||github.event.ref}}-${{github.run_id}}
restore-keys: |
sccache-${{matrix.arch}}-${{github.head_ref||github.event.ref}}-
sccache-${{matrix.arch}}-${{github.base_ref||github.event.repository.default_branch}}-
- name: Checkout sources
uses: actions/checkout@v6
with:
path: src
- name: Create Conan configuration
working-directory: ${{github.workspace}}/src
run: |
mkdir build/
conan config list
python3 -c 'import yaml; p = "build/settings.yml"; d = yaml.safe_load(open(p)); d["compiler"]["gcc"]["libc"] = ["glibc", "musl"]; yaml.safe_dump(d, open(p, "w"))'
conan profile detect
echo "compiler.libc=glibc" >> $(conan profile path default)
- name: Create Conan host profile
working-directory: ${{github.workspace}}/src
run: |
cat > "$(conan config home)/profiles/host" << "EOF"
[settings]
os=Linux
arch=${{matrix.conan_arch}}
compiler=gcc
compiler.version=11
compiler.cppstd=17
compiler.libcxx=libstdc++11
compiler.libc=musl
build_type=Release
[buildenv]
CC=${{github.workspace}}/toolchain/bin/${{matrix.cc}}
CXX=${{github.workspace}}/toolchain/bin/${{matrix.cxx}}
LDFLAGS=${{matrix.ldflags}}
EOF
- name: Setup Conan Cache
uses: actions/cache@v5
with:
path: ${{github.workspace}}/src/build/p/
key: conan-${{ runner.os }}-${{matrix.arch}}-${{ hashFiles('**/conanfile.py') }}
restore-keys: conan-${{ runner.os }}-${{matrix.arch}}-
- name: Install dependencies
working-directory: ${{github.workspace}}/src
run: |
conan install . -pr:b=default -pr:h="host" --build=missing
- name: Configure
working-directory: ${{github.workspace}}/src/build
run: |
export CC CXX
export LDFLAGS=-static
source Release/generators/conanbuild.sh
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake \
-DCONAN_HOST_PROFILE="host" \
-DCONAN_INSTALL_ARGS=--build=never \
-DCRASHPAD_NOT_SUPPORTED=true \
-DCMAKE_C_COMPILER_LAUNCHER="${{github.workspace}}/bin/sccache" -DCMAKE_CXX_COMPILER_LAUNCHER="${{github.workspace}}/bin/sccache" \
-DCMAKE_CXX_STANDARD_LIBRARIES=-latomic
- name: Build
working-directory: ${{github.workspace}}/src/build
run: make -j4 VERBOSE=1
- name: Print sccache stats
run: |
"${{github.workspace}}/bin/sccache" -s
- name: Upload pktvisord
uses: actions/upload-artifact@v7
with:
name: pktvisord-linux-${{matrix.arch}}-static
path: ${{github.workspace}}/src/build/bin/pktvisord
retention-days: 7
- name: Upload pktvisor-reader
uses: actions/upload-artifact@v7
with:
name: pktvisor-reader-linux-${{matrix.arch}}-static
path: ${{github.workspace}}/src/build/bin/pktvisor-reader
retention-days: 7
pkvisor-cli:
name: pktvisor-cli
runs-on: ubuntu-latest
strategy:
matrix:
os: [ linux, macos ]
arch: [ x86_64, armv7lh, aarch64 ]
exclude:
- os: macos
arch: armv7lh
steps:
- name: Checkout sources
uses: actions/checkout@v6
- name: Configure CMake to generate VERSION
shell: bash
run: VERSION_ONLY=1 cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake
- name: Rename folder and copy version
shell: bash
run: |
mv src pktvisor-src
cp -rpf golang/pkg/client/version.go .
- name: Build pktvisor-cli macos
if: ${{matrix.os}} == macos
uses: ./.github/actions/build-go
with:
context: "."
file: "./Dockerfile"
goos: "darwin"
- name: Build pktvisor-cli linux armv7lh
if: ${{matrix.arch}} == armv7lh
uses: ./.github/actions/build-go
with:
context: "."
file: "./Dockerfile"
goos: "linux"
goarch: "arm"
- name: Build pktvisor-cli linux aarch64
if: ${{matrix.arch}} == aarch64
uses: ./.github/actions/build-go
with:
context: "."
file: "./Dockerfile"
goos: "linux"
goarch: "arm64"
- name: Upload pktvisor-cli
uses: actions/upload-artifact@v7
with:
name: pktvisor-cli-${{matrix.os}}-${{matrix.arch}}
path: pktvisor-cli
retention-days: 7
package-alpine:
name: alpine-${{matrix.arch}}
needs: pkvisor
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
docker_platform: linux/amd64
goarch: amd64
- arch: aarch64
docker_platform: linux/arm64
goarch: arm64
steps:
- uses: actions/checkout@v6
- name: Download pktvisord
uses: actions/download-artifact@v8
with:
name: pktvisord-linux-${{matrix.arch}}-static
path: ./
- name: Download pktvisor-reader
uses: actions/download-artifact@v8
with:
name: pktvisor-reader-linux-${{matrix.arch}}-static
path: ./
- name: Configure CMake to generate version.go
shell: bash
run: VERSION_ONLY=1 cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/conan_provider.cmake
- name: Stage pktvisor sources for go build
run: |
mv src pktvisor-src
cp -rpf golang/pkg/client/version.go .
- name: Build pktvisor-cli
uses: ./.github/actions/build-go
with:
context: "."
file: "./Dockerfile"
goos: "linux"
goarch: "${{matrix.goarch}}"
- name: Stage IANA CSV
run: cp pktvisor-src/tests/fixtures/pktvisor-port-service-names.csv ./custom-iana.csv
- name: Login to Docker Hub
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 #v4.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a #v4.0.0
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd #v4.0.0
- name: Build + push pktvisor-alpine
id: docker_build
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f #v7.1.0
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./docker/Dockerfile.alpine
platforms: ${{matrix.docker_platform}}
outputs: type=image,"name=netboxlabs/pktvisor",push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.docker_build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v7
with:
name: digests-alpine-${{matrix.arch}}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge-alpine:
needs: package-alpine
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
steps:
- name: Download digests
uses: actions/download-artifact@v8
with:
path: /tmp/digests
pattern: digests-alpine-*
merge-multiple: true
- name: Login to Docker Hub
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 #v4.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd #v4.0.0
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create \
-t netboxlabs/pktvisor:develop-alpine \
$(printf 'netboxlabs/pktvisor@sha256:%s ' *)
- name: Inspect image
run: docker buildx imagetools inspect netboxlabs/pktvisor:develop-alpine