Skip to content

Commit 311e326

Browse files
committed
Add CI job to cross compile all the things
This makes sure we can compile on all the platforms and prevent things like integer overflows. Signed-off-by: Brian Goff <[email protected]>
1 parent 10a498c commit 311e326

1 file changed

Lines changed: 82 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 82 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,88 @@ jobs:
123123
- run: make man
124124
working-directory: src/github.com/containerd/containerd
125125

126+
# Make sure binaries compile with other platforms
127+
crossbuild:
128+
name: Crossbuild Binaries
129+
needs: [project, linters, protos, man]
130+
runs-on: ubuntu-18.04
131+
timeout-minutes: 10
132+
strategy:
133+
fail-fast: false
134+
matrix:
135+
include:
136+
- goos: linux
137+
goarch: arm64
138+
- goos: linux
139+
goarch: arm
140+
goarm: "7"
141+
- goos: linux
142+
goarch: arm
143+
goarm: "5"
144+
- goos: freebsd
145+
goarch: amd64
146+
- goos: freebsd
147+
goarch: arm64
148+
- goos: windows
149+
goarch: arm
150+
goarm: "7"
151+
152+
steps:
153+
- uses: actions/setup-go@v2
154+
with:
155+
go-version: '1.16.2'
156+
- name: Set env
157+
shell: bash
158+
run: |
159+
echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV
160+
echo "${{ github.workspace }}/bin" >> $GITHUB_PATH
161+
- uses: actions/checkout@v2
162+
with:
163+
path: src/github.com/containerd/containerd
164+
- run: |
165+
set -e -x
166+
167+
packages=""
168+
platform="${{matrix.goos}}/${{matrix.goarch}}"
169+
if [ -n "${{matrix.goarm}}" ]; then
170+
platform+="/v${{matrix.goarm}}"
171+
fi
172+
173+
case "${platform}" in
174+
linux/arm/v5)
175+
packages+=" crossbuild-essential-armel"
176+
echo "CGO_ENABLED=1" >> $GITHUB_ENV
177+
echo "CC=arm-linux-gnueabi-gcc" >> $GITHUB_ENV
178+
;;
179+
linux/arm/v7)
180+
packages+=" crossbuild-essential-armhf"
181+
echo "CGO_ENABLED=1" >> $GITHUB_ENV
182+
echo "CC=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
183+
;;
184+
linux/arm64)
185+
packages+=" crossbuild-essential-arm64"
186+
echo "CGO_ENABLED=1" >> $GITHUB_ENV
187+
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
188+
;;
189+
windows/arm/v7)
190+
echo "CGO_ENABLED=0" >> $GITHUB_ENV
191+
;;
192+
esac
193+
194+
if [ -n "${packages}" ]; then
195+
sudo apt-get update && sudo apt-get install -y ${packages}
196+
fi
197+
name: install deps
198+
- name: Build
199+
working-directory: src/github.com/containerd/containerd
200+
env:
201+
GOOS: ${{matrix.goos}}
202+
GOARCH: ${{matrix.goarch}}
203+
GOARM: ${{matrix.goarm}}
204+
run: |
205+
make build
206+
make binaries
207+
126208
#
127209
# Build containerd binaries
128210
#
@@ -157,13 +239,6 @@ jobs:
157239
make binaries
158240
working-directory: src/github.com/containerd/containerd
159241

160-
- name: Cross-compile
161-
if: startsWith(matrix.os, 'ubuntu')
162-
run : |
163-
GOOS=freebsd make build
164-
GOOS=freebsd make binaries
165-
working-directory: src/github.com/containerd/containerd
166-
167242
#
168243
# Integration and CRI tests
169244
#

0 commit comments

Comments
 (0)