]> ruderich.org/simon Gitweb - linux-network-namespace-labs/linux-network-namespace-labs.git/commitdiff
Add (gitlab) CI
authorSimon Ruderich <simon@ruderich.org>
Sun, 10 Nov 2024 22:51:53 +0000 (23:51 +0100)
committerSimon Ruderich <simon@ruderich.org>
Sun, 10 Nov 2024 22:51:53 +0000 (23:51 +0100)
.gitlab-ci.yml [new file with mode: 0644]
.golangci.yml [new file with mode: 0644]
Makefile
ci/run [new file with mode: 0755]
go.mod

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644 (file)
index 0000000..897b9f6
--- /dev/null
@@ -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 (file)
index 0000000..7a20a33
--- /dev/null
@@ -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
index 77f4efe58719d97c0f18ed9bd873905f81956612..fd6289a1d9cf34889a60b7741221f4979422a621 100644 (file)
--- 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 (executable)
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 58a34ef6c0d37b62ff802c1a625963102f968a9e..2cba6657de01f12726b3ac511cd68e64a7e42c90 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,3 @@
 module linux-network-namespace-labs
 
-go 1.22
+go 1.19