From 886f1f3b6eb99aa2d80e0eeb6d5deb6af22c6225 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 10 Nov 2024 23:51:53 +0100 Subject: [PATCH] Add (gitlab) CI --- .gitlab-ci.yml | 11 +++++++++++ .golangci.yml | 35 +++++++++++++++++++++++++++++++++++ Makefile | 3 +++ ci/run | 27 +++++++++++++++++++++++++++ go.mod | 2 +- 5 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 .gitlab-ci.yml create mode 100644 .golangci.yml create mode 100755 ci/run diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..897b9f6 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,11 @@ +golang: + image: golang:1.23-bookworm + script: + - ./ci/run + +golang-debian-stable: + image: golang:1.19-bookworm + script: + # Only check building as not all additonal checks work with the old golang + # version. + - go build diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..7a20a33 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,35 @@ +linters: + disable-all: true + enable: + # Enabled by default + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + # Additional checks + - bodyclose + - contextcheck + - copyloopvar + - durationcheck + - errname + - exhaustive + - exportloopref + - gofmt + - nilerr + - nolintlint + - predeclared + - rowserrcheck + - typecheck + - unconvert + - wastedassign + + issues: + # Don't hide potential important issues + exclude-use-default: false + +linters-settings: + exhaustive: + # "default" is good enough to be exhaustive + default-signifies-exhaustive: true diff --git a/Makefile b/Makefile index 77f4efe..fd6289a 100644 --- a/Makefile +++ b/Makefile @@ -3,4 +3,7 @@ all: go fmt go vet +clean: + go clean + .PHONY: all diff --git a/ci/run b/ci/run new file mode 100755 index 0000000..5ba8ec2 --- /dev/null +++ b/ci/run @@ -0,0 +1,27 @@ +#!/bin/sh + +# SPDX-License-Identifier: GPL-3.0-or-later +# Copyright (C) 2024 Simon Ruderich + +set -eu +set -x + + +# Go + +PATH=$HOME/go/bin:$PATH +export PATH + +make + +# Additional static checks only run in CI +go install golang.org/x/vuln/cmd/govulncheck@latest +govulncheck ./... +go install honnef.co/go/tools/cmd/staticcheck@v0.5.1 +staticcheck ./... +go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.0 +golangci-lint run + +test -z "$(git clean -nd)" # any untracked files left? +make clean +test -z "$(git clean -ndx)" # any unignored files left? diff --git a/go.mod b/go.mod index 58a34ef..2cba665 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module linux-network-namespace-labs -go 1.22 +go 1.19 -- 2.45.2