mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
347c371bf4
Treat warning as errors only in the CI. We can enforce it in the source code (like setting CFLAGS in libcontainer/nsenter/nsenter.go), but that can force other downstream to patch the code if thei C compiler produces warnings. For that reason, we do it only on the CI. Todays CGO warnings are quite hidden in the CI (only shown for the compilation step, that is collapsed) and CI is green anyways. With this patch, CI fails if a warning is introduced. Signed-off-by: Rodrigo Campos <rodrigo@kinvolk.io>
183 lines
5.0 KiB
YAML
183 lines
5.0 KiB
YAML
name: validate
|
|
on:
|
|
push:
|
|
tags:
|
|
- v*
|
|
branches:
|
|
- master
|
|
- release-*
|
|
pull_request:
|
|
|
|
jobs:
|
|
|
|
lint:
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: install deps
|
|
run: |
|
|
sudo apt -q update
|
|
sudo apt -q install libseccomp-dev
|
|
- uses: golangci/golangci-lint-action@v2
|
|
with:
|
|
# must be specified without patch version
|
|
version: v1.40
|
|
|
|
compile-buildtags:
|
|
runs-on: ubuntu-20.04
|
|
env:
|
|
# Don't ignore C warnings. Note that the output of "go env CGO_CFLAGS" by default is "-g -O2", so we keep them.
|
|
CGO_CFLAGS: -g -O2 -Werror
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: compile with no build tags
|
|
run: make BUILDTAGS=""
|
|
|
|
codespell:
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: install deps
|
|
# Version of codespell bundled with Ubuntu is way old, so use pip.
|
|
run: pip install codespell
|
|
- name: run codespell
|
|
run: codespell
|
|
|
|
shfmt:
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: vars
|
|
run: |
|
|
echo "VERSION=3.2.4" >> $GITHUB_ENV
|
|
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
|
- name: cache go mod and $GOCACHE
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: |
|
|
~/go/pkg/mod
|
|
~/.cache/go-build
|
|
key: ${{ runner.os }}-shfmt-${{ env.VERSION }}
|
|
restore-keys: ${{ runner.os }}-shfmt-
|
|
- name: install shfmt
|
|
run: |
|
|
command -v shfmt || \
|
|
(cd ~ && GO111MODULE=on time go get mvdan.cc/sh/v3/cmd/shfmt@v$VERSION)
|
|
- name: shfmt
|
|
run: make shfmt
|
|
|
|
shellcheck:
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: vars
|
|
run: |
|
|
echo 'VERSION=v0.7.2' >> $GITHUB_ENV
|
|
echo 'BASEURL=https://github.com/koalaman/shellcheck/releases/download' >> $GITHUB_ENV
|
|
echo 'SHA256SUM=12ee2e0b90a3d1e9cae24ac9b2838be66b48573cb2c8e8f3c566b959df6f050c' >> $GITHUB_ENV
|
|
echo ~/bin >> $GITHUB_PATH
|
|
- name: install shellcheck
|
|
run: |
|
|
mkdir ~/bin
|
|
curl -sSfL --retry 5 $BASEURL/$VERSION/shellcheck-$VERSION.linux.x86_64.tar.xz |
|
|
tar xfJ - -C ~/bin --strip 1 shellcheck-$VERSION/shellcheck
|
|
sha256sum ~/bin/shellcheck | grep -q $SHA256SUM
|
|
# make sure to remove the old version
|
|
sudo rm -f /usr/bin/shellcheck
|
|
- uses: lumaxis/shellcheck-problem-matchers@v1
|
|
- name: shellcheck
|
|
run: |
|
|
make shellcheck
|
|
|
|
deps:
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: cache go mod and $GOCACHE
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: |
|
|
~/go/pkg/mod
|
|
~/.cache/go-build
|
|
key: ${{ runner.os }}-go.sum-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: ${{ runner.os }}-go.sum-
|
|
- name: verify deps
|
|
run: make verify-dependencies
|
|
|
|
|
|
commit:
|
|
runs-on: ubuntu-20.04
|
|
# Only check commits on pull requests.
|
|
if: github.event_name == 'pull_request'
|
|
steps:
|
|
- name: get pr commits
|
|
id: 'get-pr-commits'
|
|
uses: tim-actions/get-pr-commits@v1.1.0
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: check subject line length
|
|
uses: tim-actions/commit-message-checker-with-regex@v0.3.1
|
|
with:
|
|
commits: ${{ steps.get-pr-commits.outputs.commits }}
|
|
pattern: '^.{0,72}(\n.*)*$'
|
|
error: 'Subject too long (max 72)'
|
|
|
|
|
|
cross:
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
# We have to run this under Docker as Ubuntu (host) does not support all
|
|
# the architectures we want to compile test against, and Dockerfile uses
|
|
# Debian (which does).
|
|
#
|
|
# XXX: as currently this is the only job that is using Docker, we are
|
|
# building and using the runcimage locally. In case more jobs running
|
|
# under Docker will emerge, it will be good to have a separate make
|
|
# runcimage job and share its result (the docker image) with whoever
|
|
# needs it.
|
|
- uses: satackey/action-docker-layer-caching@v0.0.11
|
|
continue-on-error: true
|
|
- name: build docker image
|
|
run: make runcimage
|
|
- name: cross
|
|
run: make cross
|
|
|
|
|
|
cfmt:
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
- name: install deps
|
|
run: |
|
|
sudo apt -qq update
|
|
sudo apt -qq install indent
|
|
- name: cfmt
|
|
run: |
|
|
make cfmt
|
|
git diff --exit-code
|
|
|
|
|
|
release:
|
|
runs-on: ubuntu-20.04
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
- name: install deps
|
|
run: |
|
|
sudo apt -qq update
|
|
sudo apt -qq install gperf
|
|
- name: make release
|
|
run: make release
|
|
- name: upload artifacts
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: release-${{ github.run_id }}
|
|
path: release/*
|