From 347c371bf45bea11e89effcb29b99486462a3376 Mon Sep 17 00:00:00 2001 From: Rodrigo Campos Date: Wed, 18 Aug 2021 17:51:15 +0200 Subject: [PATCH] CI: Mark CGO warnings as errors 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 --- .github/workflows/test.yml | 4 ++++ .github/workflows/validate.yml | 3 +++ 2 files changed, 7 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 591a18701d5..2646c449708 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,10 @@ on: - release-* pull_request: +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 + jobs: test: runs-on: ubuntu-20.04 diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 8ad6be73eb6..78bfe07187d 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -25,6 +25,9 @@ jobs: 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