1name: CI
2on:
3  push:
4    branches:
5      - master
6      - 'release/**'
7  pull_request:
8    branches:
9      - master
10      - 'release/**'
11
12jobs:
13  #
14  # golangci-lint
15  #
16  linters:
17    name: Linters
18    runs-on: ${{ matrix.os }}
19    timeout-minutes: 10
20
21    strategy:
22      matrix:
23        os: [ubuntu-18.04, macos-10.15] # TODO: pass linters on 'windows-2019'
24
25    steps:
26      - name: Install Go
27        uses: actions/setup-go@v1
28        with:
29          go-version: '1.15.5'
30
31      - name: Set env
32        shell: bash
33        run: |
34          echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV
35          echo "${{ github.workspace }}/bin" >> $GITHUB_PATH
36
37      - name: Checkout
38        uses: actions/checkout@v2
39        with:
40          path: src/github.com/containerd/containerd
41
42      - name: Install dev tools
43        env:
44          GO111MODULE: off
45        shell: bash
46        run: script/setup/install-dev-tools
47        working-directory: src/github.com/containerd/containerd
48
49      - name: Make check
50        shell: bash
51        run: make check
52        working-directory: src/github.com/containerd/containerd
53
54  #
55  # Project checks
56  #
57  project:
58    name: Project Checks
59    runs-on: ubuntu-18.04
60    timeout-minutes: 5
61
62    steps:
63      - uses: actions/checkout@v2
64        with:
65          path: src/github.com/containerd/containerd
66          fetch-depth: 100
67
68      - uses: containerd/project-checks@v1
69        with:
70          working-directory: src/github.com/containerd/containerd
71
72  #
73  # Protobuf checks
74  #
75  protos:
76    name: Protobuf
77    runs-on: ubuntu-18.04
78    timeout-minutes: 5
79
80    steps:
81      - name: Set up Go
82        uses: actions/setup-go@v1
83        with:
84          go-version: '1.15.5'
85
86      - name: Set env
87        shell: bash
88        run: |
89          echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV
90          echo "${{ github.workspace }}/bin" >> $GITHUB_PATH
91
92      - name: Checkout
93        uses: actions/checkout@v2
94        with:
95          path: src/github.com/containerd/containerd
96
97      - name: Install protobuf
98        env:
99          GO111MODULE: off
100        working-directory: src/github.com/containerd/containerd
101        run: |
102          sudo env PATH=$PATH GOPATH=$GOPATH script/setup/install-protobuf
103          sudo chmod +x /usr/local/bin/protoc
104          sudo chmod og+rx /usr/local/include/google /usr/local/include/google/protobuf /usr/local/include/google/protobuf/compiler
105          sudo chmod -R og+r /usr/local/include/google/protobuf/
106          protoc --version
107
108      - name: Install dev tools
109        env:
110          GO111MODULE: off
111        run: script/setup/install-dev-tools
112        working-directory: src/github.com/containerd/containerd
113
114      - name: Make
115        env:
116          GO111MODULE: off
117        working-directory: src/github.com/containerd/containerd
118        run: |
119          export PATH=$PATH:$(go env GOPATH)/bin
120          make check-protos check-api-descriptors
121
122  man:
123    name: Manpages
124    runs-on: ubuntu-18.04
125    timeout-minutes: 5
126
127    steps:
128      - name: Install Go
129        uses: actions/setup-go@v1
130        with:
131          go-version: '1.15.5'
132
133      - name: Set env
134        shell: bash
135        run: |
136          echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV
137          echo "${{ github.workspace }}/bin" >> $GITHUB_PATH
138
139      - name: Checkout
140        uses: actions/checkout@v2
141        with:
142          path: src/github.com/containerd/containerd
143
144      - name: Install dependencies
145        run: GO111MODULE=on go get github.com/cpuguy83/go-md2man/v2@v2.0.0
146
147      - name: Make
148        run: make man
149        working-directory: src/github.com/containerd/containerd
150
151  #
152  # Build containerd binaries
153  #
154  binaries:
155    name: Binaries
156    runs-on: ${{ matrix.os }}
157    timeout-minutes: 10
158    needs: [project, linters, protos, man]
159
160    strategy:
161      matrix:
162        os: [ubuntu-18.04, macos-10.15, windows-2019]
163
164    steps:
165      - name: Install Go
166        uses: actions/setup-go@v1
167        with:
168          go-version: '1.15.5'
169
170      - name: Set env
171        shell: bash
172        run: |
173          echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV
174          echo "${{ github.workspace }}/bin" >> $GITHUB_PATH
175
176      - name: Checkout
177        uses: actions/checkout@v2
178        with:
179          path: src/github.com/containerd/containerd
180
181      - name: Make
182        run: |
183          make build
184          make binaries
185        working-directory: src/github.com/containerd/containerd
186
187  #
188  # Integration and CRI tests
189  #
190  integration-windows:
191    name: Windows Integration
192    runs-on: windows-2019
193    timeout-minutes: 30
194    needs: [project, linters, protos, man]
195
196    steps:
197      - name: Install Go
198        uses: actions/setup-go@v1
199        with:
200          go-version: '1.15.5'
201
202      - name: Set env
203        shell: bash
204        run: |
205          echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV
206          echo "${{ github.workspace }}/src/github.com/containerd/containerd/bin" >> $GITHUB_PATH
207
208      - name: Checkout containerd
209        uses: actions/checkout@v2
210        with:
211          path: src/github.com/containerd/containerd
212      - name: Checkout Microsoft/hcsshim
213        uses: actions/checkout@v2
214        with:
215          repository: Microsoft/hcsshim
216          path: src/github.com/Microsoft/hcsshim
217
218      - name: Install Build Deps
219        shell: bash
220        run: |
221          cd src/github.com/containerd/containerd
222          script/setup/install-dev-tools
223      - name: Binaries
224        shell: bash
225        run: |
226          set -o xtrace
227          export CGO_ENABLED=1
228          cd src/github.com/containerd/containerd
229          mingw32-make.exe binaries
230          bindir="$(pwd)"
231          SHIM_COMMIT=$(grep Microsoft/hcsshim vendor.conf | awk '{print $2}')
232          cd ../../Microsoft/hcsshim
233          git fetch --tags origin "${SHIM_COMMIT}"
234          git checkout "${SHIM_COMMIT}"
235          GO111MODULE=on go build -mod=vendor -o "${bindir}/containerd-shim-runhcs-v1.exe" ./cmd/containerd-shim-runhcs-v1
236
237      - name: Tests
238        shell: bash
239        env:
240          CGO_ENABLED: 1
241        run: |
242          cd src/github.com/containerd/containerd
243          mingw32-make.exe test root-test
244
245      - name: Integration 1
246        shell: bash
247        run: |
248          cd src/github.com/containerd/containerd
249          export CGO_ENABLED=1
250          mingw32-make.exe integration
251      # Run the integration suite a second time. See discussion in github.com/containerd/containerd/pull/175
252      - name: Integration 2
253        shell: bash
254        run: |
255          cd src/github.com/containerd/containerd
256          export TESTFLAGS_PARALLEL=1
257          export CGO_ENABLED=1
258          mingw32-make.exe integration
259
260  integration-linux:
261    name: Linux Integration
262    runs-on: ubuntu-18.04
263    timeout-minutes: 15
264    needs: [project, linters, protos, man]
265
266    strategy:
267      matrix:
268        runtime: [io.containerd.runtime.v1.linux, io.containerd.runc.v1, io.containerd.runc.v2]
269        runc: [runc, crun]
270        exclude:
271          - runtime: io.containerd.runc.v1
272            runc: crun
273          - runtime: io.containerd.runtime.v1.linux
274            runc: crun
275
276    steps:
277      - name: Install Go
278        uses: actions/setup-go@v1
279        with:
280          go-version: '1.15.5'
281
282      - name: Set env
283        shell: bash
284        run: |
285          echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV
286          echo "${{ github.workspace }}/bin" >> $GITHUB_PATH
287
288      - name: Checkout containerd
289        uses: actions/checkout@v2
290        with:
291          path: src/github.com/containerd/containerd
292
293      - name: Install containerd dependencies
294        env:
295          RUNC_FLAVOR: ${{ matrix.runc }}
296        run: |
297          sudo -E PATH=$PATH script/setup/install-seccomp
298          sudo -E PATH=$PATH script/setup/install-runc
299          sudo -E PATH=$PATH script/setup/install-cni
300          sudo -E PATH=$PATH script/setup/install-critools
301        working-directory: src/github.com/containerd/containerd
302
303      - name: Install criu
304        run: |
305          sudo apt-get install -y \
306            libprotobuf-dev \
307            libprotobuf-c-dev \
308            protobuf-c-compiler \
309            protobuf-compiler \
310            python-protobuf \
311            libnl-3-dev \
312            libnet-dev \
313            libcap-dev \
314            python-future
315          wget https://github.com/checkpoint-restore/criu/archive/v3.13.tar.gz -O criu.tar.gz
316          tar -zxf criu.tar.gz
317          cd criu-3.13
318          sudo make install-criu
319
320      - name: Install containerd
321        env:
322          CGO_ENABLED: 1
323        run: |
324          make binaries
325          sudo make install
326        working-directory: src/github.com/containerd/containerd
327
328      - name: Tests
329        env:
330          GOPROXY: direct
331          SKIPTESTS: github.com/containerd/containerd/snapshots/devmapper
332        run: |
333          make test
334          sudo -E PATH=$PATH GOPATH=$GOPATH GOPROXY=$GOPROXY make root-test
335        working-directory: src/github.com/containerd/containerd
336
337      - name: Integration 1
338        env:
339          GOPROXY: direct
340          TEST_RUNTIME: ${{ matrix.runtime }}
341          RUNC_FLAVOR: ${{ matrix.runc }}
342        run: |
343          sudo GOPATH=$GOPATH GOPROXY=$GOPROXY TEST_RUNTIME=$TEST_RUNTIME RUNC_FLAVOR=$RUNC_FLAVOR make integration EXTRA_TESTFLAGS=-no-criu TESTFLAGS_RACE=-race
344        working-directory: src/github.com/containerd/containerd
345
346      # Run the integration suite a second time. See discussion in github.com/containerd/containerd/pull/1759
347      - name: Integration 2
348        env:
349          GOPROXY: direct
350          TEST_RUNTIME: ${{ matrix.runtime }}
351          RUNC_FLAVOR: ${{ matrix.runc }}
352        run: |
353          sudo GOPATH=$GOPATH GOPROXY=$GOPROXY TEST_RUNTIME=$TEST_RUNTIME RUNC_FLAVOR=$RUNC_FLAVOR TESTFLAGS_PARALLEL=1 make integration EXTRA_TESTFLAGS=-no-criu
354        working-directory: src/github.com/containerd/containerd
355
356      - name: CRI test
357        env:
358          TEST_RUNTIME: ${{ matrix.runtime }}
359        run: |
360          BDIR="$(mktemp -d -p $PWD)"
361          mkdir -p ${BDIR}/{root,state}
362          cat > ${BDIR}/config.toml <<EOF
363            [plugins.cri.containerd.default_runtime]
364              runtime_type = "${TEST_RUNTIME}"
365          EOF
366          ls /etc/cni/net.d
367          sudo PATH=$PATH BDIR=$BDIR /usr/local/bin/containerd -a ${BDIR}/c.sock --config ${BDIR}/config.toml --root ${BDIR}/root --state ${BDIR}/state --log-level debug &> ${BDIR}/containerd-cri.log &
368          sudo PATH=$PATH BDIR=$BDIR /usr/local/bin/ctr -a ${BDIR}/c.sock version
369          sudo PATH=$PATH BDIR=$BDIR GOPATH=$GOPATH critest --runtime-endpoint=unix:///${BDIR}/c.sock --parallel=8
370          TEST_RC=$?
371          test $TEST_RC -ne 0 && cat ${BDIR}/containerd-cri.log
372          sudo pkill containerd
373          sudo BDIR=$BDIR rm -rf ${BDIR}
374          test $TEST_RC -eq 0 || /bin/false
375
376  cgroup2:
377    name: CGroupsV2 and SELinux Integration
378    # nested virtualization is only available on macOS hosts
379    runs-on: macos-10.15
380    timeout-minutes: 40
381    needs: [project, linters, protos, man]
382    strategy:
383      matrix:
384        # Currently crun is disabled to decrease CI flakiness.
385        # We can enable crun again when we get a better CI infra.
386        runc: [runc]
387    steps:
388      - name: Checkout containerd
389        uses: actions/checkout@v2
390
391      - name: Start vagrant
392        run: vagrant up
393
394      - name: Integration
395        env:
396          RUNC_FLAVOR: ${{ matrix.runc }}
397          # SELinux: replace Permissive with Enforcing after https://github.com/containers/container-selinux/pull/98
398          # is merged and the package becomes generally available.
399          SELINUX: Permissive
400        run: vagrant up --provision-with=selinux,install-runc,test-integration
401
402      - name: CRI test
403        env:
404          RUNC_FLAVOR: ${{ matrix.runc }}
405          # SELinux: replace Permissive with Enforcing after https://github.com/containers/container-selinux/pull/98
406          # is merged and the package becomes generally available.
407          SELINUX: Permissive
408        run: vagrant up --provision-with=selinux,install-runc,test-cri
409