Skip to content

Commit 5a9d16d

Browse files
committed
ci: support multi-arch docker builds
Provide the base to our docker images and run with the QEMU docker support optionally.
1 parent 9f8802d commit 5a9d16d

File tree

7 files changed

+77
-28
lines changed

7 files changed

+77
-28
lines changed

.github/workflows/coverity.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
with:
2121
fetch-depth: 0
2222
- name: Download container
23-
run: ci/getcontainer.sh ci/docker/xenial
23+
run: ci/getcontainer.sh xenial
2424
env:
2525
DOCKER_REGISTRY: ${{ env.docker-registry }}
2626
GITHUB_TOKEN: ${{ secrets.github_token }}

.github/workflows/main.yml

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,46 @@ jobs:
2626
strategy:
2727
matrix:
2828
container:
29-
- xenial
30-
- bionic
31-
- focal
32-
- docurium
29+
- name: xenial
30+
- name: bionic
31+
- name: focal
32+
- name: docurium
33+
- name: bionic-x86
34+
dockerfile: bionic
35+
base: multiarch/ubuntu-core:x86-bionic
36+
qemu: true
37+
- name: bionic-arm32
38+
dockerfile: bionic
39+
base: multiarch/ubuntu-core:armhf-bionic
40+
qemu: true
41+
- name: bionic-arm64
42+
dockerfile: bionic
43+
base: multiarch/ubuntu-core:arm64-bionic
44+
qemu: true
3345
runs-on: ubuntu-latest
3446
steps:
3547
- name: Check out repository
3648
uses: actions/checkout@v2
3749
with:
3850
fetch-depth: 0
3951
if: github.event_name == 'push'
52+
- name: Setup QEMU
53+
run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
54+
if: matrix.container.qemu == true
4055
- name: Download existing container
41-
run: ci/getcontainer.sh ${{ env.docker-config-path }}/${{ matrix.container }}
56+
run: |
57+
"${{ github.workspace }}/ci/getcontainer.sh" "${{ matrix.container.name }}" "${{ matrix.container.dockerfile }}"
4258
env:
4359
DOCKER_REGISTRY: ${{ env.docker-registry }}
4460
GITHUB_TOKEN: ${{ secrets.github_token }}
61+
working-directory: ${{ env.docker-config-path }}
4562
if: github.event_name == 'push'
4663
- name: Build and publish image
4764
run: |
48-
docker build -t ${{ env.docker-registry-container-sha }} --build-arg BASE=${{ matrix.container.base }} -f ${{ matrix.container }} .
65+
if [ "${{ matrix.container.base }}" != "" ]; then
66+
BASE_ARG="--build-arg BASE=${{ matrix.container.base }}"
67+
fi
68+
docker build -t ${{ env.docker-registry-container-sha }} ${BASE_ARG} -f ${{ env.dockerfile }} .
4969
docker push ${{ env.docker-registry-container-sha }}
5070
working-directory: ${{ env.docker-config-path }}
5171
if: github.event_name == 'push' && env.docker-container-exists != 'true'
@@ -55,40 +75,45 @@ jobs:
5575
# or on the actual hosts (macOS, Windows).
5676
build:
5777
name: Build
58-
needs: [build_containers]
78+
needs: [ build_containers ]
5979
strategy:
6080
matrix:
6181
platform:
6282
- # Xenial, GCC, OpenSSL
63-
image: xenial
83+
container:
84+
name: xenial
6485
env:
6586
CC: gcc
6687
CMAKE_GENERATOR: Ninja
6788
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
6889
os: ubuntu-latest
6990
- # Xenial, GCC, mbedTLS
70-
image: xenial
91+
container:
92+
name: xenial
7193
env:
7294
CC: gcc
7395
CMAKE_GENERATOR: Ninja
7496
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
7597
os: ubuntu-latest
7698
- # Xenial, Clang, OpenSSL
77-
image: xenial
99+
container:
100+
name: xenial
78101
env:
79102
CC: clang
80103
CMAKE_GENERATOR: Ninja
81104
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
82105
os: ubuntu-latest
83106
- # Xenial, Clang, mbedTLS
84-
image: xenial
107+
container:
108+
name: xenial
85109
env:
86110
CC: clang
87111
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
88112
CMAKE_GENERATOR: Ninja
89113
os: ubuntu-latest
90114
- # Focal, Clang 10, mbedTLS, MemorySanitizer
91-
image: focal
115+
container:
116+
name: focal
92117
env:
93118
CC: clang-10
94119
CFLAGS: -fsanitize=memory -fsanitize-memory-track-origins=2 -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer
@@ -99,7 +124,8 @@ jobs:
99124
ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10
100125
os: ubuntu-latest
101126
- # Focal, Clang 10, OpenSSL, UndefinedBehaviorSanitizer
102-
image: focal
127+
container:
128+
name: focal
103129
env:
104130
CC: clang-10
105131
CFLAGS: -fsanitize=undefined,nullability -fno-sanitize-recover=undefined,nullability -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer
@@ -110,7 +136,8 @@ jobs:
110136
ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10
111137
os: ubuntu-latest
112138
- # Focal, Clang 10, OpenSSL, ThreadSanitizer
113-
image: focal
139+
container:
140+
name: focal
114141
env:
115142
CC: clang-10
116143
CFLAGS: -fsanitize=thread -fno-optimize-sibling-calls -fno-omit-frame-pointer
@@ -181,21 +208,26 @@ jobs:
181208
run: ci/setup-${{ matrix.platform.setup-script }}.sh
182209
shell: bash
183210
if: matrix.platform.setup-script != ''
211+
- name: Setup QEMU
212+
run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
213+
if: matrix.platform.container.qemu == true
184214
- name: Download container
185-
run: ci/getcontainer.sh ${{ env.docker-config-path }}/${{ matrix.platform.image }}
215+
run: |
216+
"${{ github.workspace }}/ci/getcontainer.sh" "${{ matrix.platform.container.name }}" "${{ matrix.platform.container.dockerfile }}"
186217
env:
187218
DOCKER_REGISTRY: ${{ env.docker-registry }}
188219
GITHUB_TOKEN: ${{ secrets.github_token }}
189-
if: matrix.platform.image != ''
220+
working-directory: ${{ env.docker-config-path }}
221+
if: matrix.platform.container.name != ''
190222
- name: Create container
191-
run: docker build -t ${{ env.docker-registry-container-sha }} -f ${{ matrix.platform.image }} .
223+
run: docker build -t ${{ env.docker-registry-container-sha }} -f ${{ env.dockerfile }} .
192224
working-directory: ${{ env.docker-config-path }}
193-
if: matrix.platform.image != '' && env.docker-container-exists != 'true'
225+
if: matrix.platform.container.name != '' && env.docker-container-exists != 'true'
194226
- name: Build and test
195227
run: |
196228
export GITTEST_NEGOTIATE_PASSWORD="${{ secrets.GITTEST_NEGOTIATE_PASSWORD }}"
197229
198-
if [ -n "${{ matrix.platform.image }}" ]; then
230+
if [ -n "${{ matrix.platform.container.name }}" ]; then
199231
docker run \
200232
--rm \
201233
-v "$(pwd):/home/libgit2/source" \
@@ -229,6 +261,13 @@ jobs:
229261
needs: [build_containers]
230262
runs-on: ubuntu-latest
231263
steps:
264+
- name: Setup defaults
265+
run: |
266+
if [ "${{ matrix.container.dockerfile }}" = "" ]; then
267+
echo "dockerfile=${{ matrix.container.dockerfile }}" >> $GITHUB_ENV
268+
else
269+
echo "dockerfile=${{ matrix.container.dockerfile }}" >> $GITHUB_ENV
270+
fi
232271
- name: Check out repository
233272
uses: actions/checkout@v2
234273
with:

ci/docker/bionic

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM ubuntu:bionic AS apt
1+
ARG BASE=ubuntu:bionic
2+
FROM ${BASE} AS apt
23
RUN apt-get update && \
34
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
45
clang \

ci/docker/docurium

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
FROM ubuntu:bionic
1+
ARG BASE=ubuntu:bionic
2+
FROM ${BASE}
23
RUN apt update && apt install -y cmake pkg-config ruby ruby-dev llvm libclang-dev libssl-dev python-pygments
34
RUN gem install docurium

ci/docker/focal

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM ubuntu:focal AS apt
1+
ARG BASE=ubuntu:focal
2+
FROM ${BASE} AS apt
23
RUN apt-get update && \
34
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
45
bzip2 \

ci/docker/xenial

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM ubuntu:xenial AS apt
1+
ARG BASE=ubuntu:xenial
2+
FROM ${BASE} AS apt
23
RUN apt-get update && \
34
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
45
bzip2 \

ci/getcontainer.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@
22

33
set -e
44

5-
DOCKERFILE_PATH=$1
5+
IMAGE_NAME=$1
6+
DOCKERFILE_PATH=$2
67

7-
if [ "${DOCKERFILE_PATH}" = "" ]; then
8-
echo "usage: $0 dockerfile"
8+
if [ "${IMAGE_NAME}" = "" ]; then
9+
echo "usage: $0 image_name [dockerfile]"
910
exit 1
1011
fi
1112

13+
if [ "${DOCKERFILE_PATH}" = "" ]; then
14+
DOCKERFILE_PATH="${IMAGE_NAME}"
15+
fi
16+
1217
if [ "${DOCKER_REGISTRY}" = "" ]; then
1318
echo "DOCKER_REGISTRY environment variable is unset."
1419
echo "Not running inside GitHub Actions or misconfigured?"
1520
exit 1
1621
fi
1722

18-
DOCKER_CONTAINER="${GITHUB_REPOSITORY}/$(basename ${DOCKERFILE_PATH})"
23+
DOCKER_CONTAINER="${GITHUB_REPOSITORY}/${IMAGE_NAME}"
1924
DOCKER_REGISTRY_CONTAINER="${DOCKER_REGISTRY}/${DOCKER_CONTAINER}"
2025

26+
echo "dockerfile=${DOCKERFILE_PATH}" >> $GITHUB_ENV
2127
echo "docker-container=${DOCKER_CONTAINER}" >> $GITHUB_ENV
2228
echo "docker-registry-container=${DOCKER_REGISTRY_CONTAINER}" >> $GITHUB_ENV
2329

0 commit comments

Comments
 (0)