Skip to content

Commit 61daab6

Browse files
committed
Use matrix builds
1 parent 89a562b commit 61daab6

File tree

1 file changed

+41
-94
lines changed

1 file changed

+41
-94
lines changed

.github/workflows/ci.yml

Lines changed: 41 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,42 @@ on:
99
pull_request:
1010

1111
jobs:
12-
build-libbpf-docker-x86_64:
13-
name: Build libbpf in Docker (x86_64)
14-
runs-on: ubuntu-24.04
12+
build-libbpf:
13+
strategy:
14+
matrix:
15+
arch:
16+
- name: x86_64
17+
image: ubuntu-24.04
18+
- name: aarch64
19+
image: ubuntu-24.04-arm
20+
name: Build libbpf in Docker (${{ matrix.arch.name }})
21+
runs-on: ${{ matrix.arch.image }}
1522
steps:
1623
- uses: actions/checkout@v4
1724

1825
- name: Build libbpf
1926
run: |
2027
docker buildx build --progress plain --tag libbpf --target libbpf_builder .
2128
id=$(docker create libbpf)
22-
docker cp $id:/build/libbpf.tar.gz libbpf.x86_64.tar.gz
23-
24-
- name: Upload libbpf.tar.gz
25-
uses: actions/upload-artifact@v4
26-
with:
27-
name: libbpf.x86_64.tar.gz
28-
path: libbpf.x86_64.tar.gz
29-
if-no-files-found: error
30-
31-
build-libbpf-docker-aarch64:
32-
name: Build libbpf in Docker (aarch64)
33-
runs-on: ubuntu-24.04-arm
34-
steps:
35-
- uses: actions/checkout@v4
36-
37-
- name: Build libbpf
38-
run: |
39-
docker buildx build --progress plain --tag libbpf --target libbpf_builder --platform linux/arm64 .
40-
id=$(docker create libbpf)
41-
docker cp $id:/build/libbpf.tar.gz libbpf.aarch64.tar.gz
29+
docker cp $id:/build/libbpf.tar.gz libbpf.${{ matrix.arch.name }}.tar.gz
4230
4331
- name: Upload libbpf.tar.gz
4432
uses: actions/upload-artifact@v4
4533
with:
46-
name: libbpf.aarch64.tar.gz
47-
path: libbpf.aarch64.tar.gz
34+
name: libbpf.${{ matrix.arch.name }}.tar.gz
35+
path: libbpf.${{ matrix.arch.name }}.tar.gz
4836
if-no-files-found: error
4937

50-
build-ebpf-exporter-docker-x86_64:
51-
name: Build ebpf_exporter in Docker (x86_64, built-in libbpf)
52-
runs-on: ubuntu-24.04
38+
build-ebpf-exporter-docker:
39+
strategy:
40+
matrix:
41+
arch:
42+
- name: x86_64
43+
image: ubuntu-24.04
44+
- name: aarch64
45+
image: ubuntu-24.04-arm
46+
name: Build ebpf_exporter in Docker (${{ matrix.arch.name }}, built-in libbpf)
47+
runs-on: ${{ matrix.arch.image }}
5348
steps:
5449
- uses: actions/checkout@v4
5550
with:
@@ -60,90 +55,43 @@ jobs:
6055
docker buildx build --progress plain --tag ebpf_exporter .
6156
docker create --name ebpf_exporter ebpf_exporter
6257
63-
- name: Extract ebpf_exporter.x86_64
58+
- name: Extract ebpf_exporter.${{ matrix.arch.name }}
6459
run: |
6560
docker cp ebpf_exporter:/ebpf_exporter ebpf_exporter
6661
6762
- name: Upload ebpf_exporter
6863
uses: actions/upload-artifact@v4
6964
with:
70-
name: ebpf_exporter.x86_64
65+
name: ebpf_exporter.${{ matrix.arch.name }}
7166
path: ebpf_exporter
7267
if-no-files-found: error
7368

74-
- name: Extract examples.x86_64.tar.gz
69+
- name: Extract examples.${{ matrix.arch.name }}.tar.gz
7570
run: |
7671
docker cp ebpf_exporter:/examples ./
77-
tar -cvzf examples.x86_64.tar.gz -T <(find examples | grep -E "\.(yaml|bpf.o)$")
72+
tar -cvzf examples.${{ matrix.arch.name }}.tar.gz -T <(find examples | grep -E "\.(yaml|bpf.o)$")
7873
79-
- name: Upload examples.x86_64.tar.gz
74+
- name: Upload examples.${{ matrix.arch.name }}.tar.gz
8075
uses: actions/upload-artifact@v4
8176
with:
82-
name: examples.x86_64.tar.gz
83-
path: examples.x86_64.tar.gz
77+
name: examples.${{ matrix.arch.name }}.tar.gz
78+
path: examples.${{ matrix.arch.name }}.tar.gz
8479
if-no-files-found: error
8580

86-
- name: Extract ebpf_exporter_with_examples.x86_64.tar.gz
81+
- name: Extract ebpf_exporter_with_examples.${{ matrix.arch.name }}.tar.gz
8782
run: |
88-
tar -cvzf ebpf_exporter_with_examples.x86_64.tar.gz --transform "s,\(.*\),ebpf_exporter-$(git describe --tags)/\1," -T <(echo ebpf_exporter; find examples | grep -E "\.(yaml|bpf.o)$" | sort)
83+
tar -cvzf ebpf_exporter_with_examples.${{ matrix.arch.name }}.tar.gz --transform "s,\(.*\),ebpf_exporter-$(git describe --tags)/\1," -T <(echo ebpf_exporter; find examples | grep -E "\.(yaml|bpf.o)$" | sort)
8984
90-
- name: Upload ebpf_exporter_with_examples.x86_64.tar.gz
85+
- name: Upload ebpf_exporter_with_examples.${{ matrix.arch.name }}.tar.gz
9186
uses: actions/upload-artifact@v4
9287
with:
93-
name: ebpf_exporter_with_examples.x86_64.tar.gz
94-
path: ebpf_exporter_with_examples.x86_64.tar.gz
95-
if-no-files-found: error
96-
97-
build-ebpf-exporter-docker-aarch64:
98-
name: Build ebpf_exporter in Docker (aarch64, built-in libbpf)
99-
runs-on: ubuntu-24.04-arm
100-
steps:
101-
- uses: actions/checkout@v4
102-
with:
103-
fetch-depth: 0 # Fetch with tags to have the build version attached
104-
105-
- name: Build ebpf_exporter and examples
106-
run: |
107-
docker buildx build --progress plain --tag ebpf_exporter --platform linux/arm64 .
108-
docker create --name ebpf_exporter ebpf_exporter
109-
110-
- name: Extract ebpf_exporter.aarch64
111-
run: |
112-
docker cp ebpf_exporter:/ebpf_exporter ebpf_exporter
113-
114-
- name: Upload ebpf_exporter
115-
uses: actions/upload-artifact@v4
116-
with:
117-
name: ebpf_exporter.aarch64
118-
path: ebpf_exporter
119-
if-no-files-found: error
120-
121-
- name: Extract examples.aarch64.tar.gz
122-
run: |
123-
docker cp ebpf_exporter:/examples ./
124-
tar -cvzf examples.aarch64.tar.gz -T <(find examples | grep -E "\.(yaml|bpf.o)$")
125-
126-
- name: Upload examples.aarch64.tar.gz
127-
uses: actions/upload-artifact@v4
128-
with:
129-
name: examples.aarch64.tar.gz
130-
path: examples.aarch64.tar.gz
131-
if-no-files-found: error
132-
133-
- name: Extract ebpf_exporter_with_examples.aarch64.tar.gz
134-
run: |
135-
tar -cvzf ebpf_exporter_with_examples.aarch64.tar.gz --transform "s,\(.*\),ebpf_exporter-$(git describe --tags)/\1," -T <(echo ebpf_exporter; find examples | grep -E "\.(yaml|bpf.o)$" | sort)
136-
137-
- name: Upload ebpf_exporter_with_examples.aarch64.tar.gz
138-
uses: actions/upload-artifact@v4
139-
with:
140-
name: ebpf_exporter_with_examples.aarch64.tar.gz
141-
path: ebpf_exporter_with_examples.aarch64.tar.gz
88+
name: ebpf_exporter_with_examples.${{ matrix.arch.name }}.tar.gz
89+
path: ebpf_exporter_with_examples.${{ matrix.arch.name }}.tar.gz
14290
if-no-files-found: error
14391

14492
build-ebpf-exporter-static-x86_64-system-libbpf:
14593
name: Build ebpf_exporter (x86_64, statically linked, system libbpf)
146-
needs: build-libbpf-docker-x86_64
94+
needs: build-libbpf
14795
runs-on: ubuntu-24.04
14896
steps:
14997
- uses: actions/checkout@v4
@@ -202,7 +150,7 @@ jobs:
202150

203151
build-ebpf-exporter-dynamic-x86_64-system-libbpf:
204152
name: Build ebpf_exporter (x86_64, dynamically linked, system libbpf)
205-
needs: build-libbpf-docker-x86_64
153+
needs: build-libbpf
206154
runs-on: ubuntu-24.04
207155
steps:
208156
- uses: actions/checkout@v4
@@ -255,7 +203,7 @@ jobs:
255203

256204
test-ebpf-exporter-x86_64-system-libbpf:
257205
name: Test ebpf_exporter (x86_64, system libbpf)
258-
needs: build-libbpf-docker-x86_64
206+
needs: build-libbpf
259207
runs-on: ubuntu-24.04
260208
steps:
261209
- uses: actions/checkout@v4
@@ -348,7 +296,7 @@ jobs:
348296

349297
build-examples-x86_64-system-libbpf:
350298
name: Build examples (x86_64, system libbpf)
351-
needs: build-libbpf-docker-x86_64
299+
needs: build-libbpf
352300
runs-on: ubuntu-24.04
353301
steps:
354302
- uses: actions/checkout@v4
@@ -422,7 +370,7 @@ jobs:
422370
name: Check examples
423371
runs-on: ubuntu-24.04
424372
needs:
425-
- build-ebpf-exporter-docker-x86_64
373+
- build-ebpf-exporter-docker
426374
- build-tracing-demos-x86_64
427375
steps:
428376
- uses: actions/checkout@v4
@@ -579,8 +527,7 @@ jobs:
579527
name: Release archive
580528
runs-on: ubuntu-24.04
581529
needs:
582-
- build-ebpf-exporter-docker-aarch64
583-
- build-ebpf-exporter-docker-x86_64
530+
- build-ebpf-exporter-docker
584531
steps:
585532
- name: Download ebpf_exporter.aarch64
586533
uses: actions/download-artifact@v4

0 commit comments

Comments
 (0)