Skip to content

Commit 8fbbd9c

Browse files
committed
golangci: try to set up golangci
The ebpf libraries are not helping at all. Fix #28
1 parent bb99b44 commit 8fbbd9c

File tree

2 files changed

+189
-1
lines changed

2 files changed

+189
-1
lines changed

.github/workflows/tests.yaml

+30-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,35 @@ jobs:
4747
name: unit-test
4848
path: /tmp/unit/
4949

50+
linting:
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # ratchet:actions/checkout@v3
54+
55+
- name: Set up Go
56+
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # ratchet:actions/setup-go@v4
57+
with:
58+
go-version: '1.21'
59+
60+
- name: Install Dependencies
61+
run: |
62+
sudo apt update
63+
sudo apt install -y clang
64+
sudo apt install -y libbpf-dev
65+
sudo apt install -y libseccomp-dev
66+
67+
- name: Build coverage-instrumented binary
68+
run: |
69+
make build-static-libbpfgo
70+
make build-bpf
71+
72+
- name: Golangci-lint
73+
uses: golangci/[email protected]
74+
continue-on-error: true
75+
with:
76+
# TODO: find a way to pass this the same way we pass it to go test
77+
args: --issues-exit-code 0 internal/analyzer internal/archiver internal/elfreader internal/embeddable internal/executor internal/metadata internal/privileged internal/seccomputils internal/writer
78+
5079
integration-test:
5180

5281
runs-on: ubuntu-latest
@@ -76,7 +105,7 @@ jobs:
76105
mkdir -p /tmp/integration
77106
# we have to run integration tests one-by-one
78107
# otherwhise they will run in parallel.
79-
# since harpoon apply network forwards, these could
108+
# since harpoon apply network forwards, these could
80109
# interact with each other and make the test fail.
81110
go test \
82111
-exec sudo \

.golangci.yml

+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
---
2+
# golangci-lint configuration file made by @ccoVeille
3+
# Source: https://github.com/ccoVeille/golangci-lint-config-examples/
4+
# Author: @ccoVeille
5+
# License: MIT
6+
#
7+
issues:
8+
# Maximum issues count per one linter.
9+
# Set to 0 to disable the limit (Default: 50)
10+
max-issues-per-linter: 0
11+
# Maximum count of issues with the same text.
12+
# Set to 0 to disable the limit (Default: 3)
13+
max-same-issues: 0
14+
15+
linters:
16+
# some linters are enabled by default
17+
# https://golangci-lint.run/usage/linters/
18+
#
19+
# enable some extra linters
20+
enable:
21+
# Errcheck is a program for checking for unchecked errors in Go code.
22+
- errcheck
23+
24+
# Linter for Go source code that specializes in simplifying code.
25+
- gosimple
26+
27+
# Vet examines Go source code and reports suspicious constructs.
28+
- govet
29+
30+
# Detects when assignments to existing variables are not used.
31+
- ineffassign
32+
33+
# It's a set of rules from staticcheck. See https://staticcheck.io/
34+
- staticcheck
35+
36+
# Fast, configurable, extensible, flexible, and beautiful linter for Go.
37+
# Drop-in replacement of golint.
38+
- revive
39+
40+
# check imports order and makes it always deterministic.
41+
- gci
42+
43+
# make sure to use t.Helper() when needed
44+
- thelper
45+
46+
# mirror suggests rewrites to avoid unnecessary []byte/string conversion
47+
- mirror
48+
49+
# detect the possibility to use variables/constants from the Go standard library.
50+
- usestdlibvars
51+
52+
# Detects common programming mistakes.
53+
- errorlint
54+
55+
# Finds commonly misspelled English words.
56+
- misspell
57+
58+
# Checks for duplicate words in the source code.
59+
- dupword
60+
61+
# Errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced
62+
- errorlint
63+
64+
linters-settings:
65+
gci: # define the section orders for imports
66+
sections:
67+
# Standard section: captures all standard packages.
68+
- standard
69+
# Default section: catchall that is not standard or custom
70+
- default
71+
# linters that related to local tool, so they should be separated
72+
- localmodule
73+
74+
revive:
75+
rules:
76+
# these are the default revive rules
77+
# you can remove the whole "rules" node if you want
78+
# BUT
79+
# ! /!\ they all need to be present when you want to add more rules than the default ones
80+
# otherwise, you won't have the default rules, but only the ones you define in the "rules" node
81+
82+
# Blank import should be only in a main or test package, or have a comment justifying it.
83+
- name: blank-imports
84+
85+
# context.Context() should be the first parameter of a function when provided as argument.
86+
- name: context-as-argument
87+
arguments:
88+
- allowTypesBefore: "*testing.T"
89+
90+
# Basic types should not be used as a key in `context.WithValue`
91+
- name: context-keys-type
92+
93+
# Importing with `.` makes the programs much harder to understand
94+
- name: dot-imports
95+
96+
# Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring.
97+
- name: empty-block
98+
99+
# for better readability, variables of type `error` must be named with the prefix `err`.
100+
- name: error-naming
101+
102+
# for better readability, the errors should be last in the list of returned values by a function.
103+
- name: error-return
104+
105+
# for better readability, error messages should not be capitalized or end with punctuation or a newline.
106+
- name: error-strings
107+
108+
# report when replacing `errors.New(fmt.Sprintf())` with `fmt.Errorf()` is possible
109+
- name: errorf
110+
111+
# incrementing an integer variable by 1 is recommended to be done using the `++` operator
112+
- name: increment-decrement
113+
114+
# highlights redundant else-blocks that can be eliminated from the code
115+
- name: indent-error-flow
116+
117+
# This rule suggests a shorter way of writing ranges that do not use the second value.
118+
- name: range
119+
120+
# receiver names in a method should reflect the struct name (p for Person, for example)
121+
- name: receiver-naming
122+
123+
# redefining built in names (true, false, append, make) can lead to bugs very difficult to detect.
124+
- name: redefines-builtin-id
125+
126+
# redundant else-blocks that can be eliminated from the code.
127+
- name: superfluous-else
128+
129+
# prevent confusing name for variables when using `time` package
130+
- name: time-naming
131+
132+
# warns when an exported function or method returns a value of an un-exported type.
133+
- name: unexported-return
134+
135+
# spots and proposes to remove unreachable code. also helps to spot errors
136+
- name: unreachable-code
137+
138+
# Functions or methods with unused parameters can be a symptom of an unfinished refactoring or a bug.
139+
- name: unused-parameter
140+
141+
# report when a variable declaration can be simplified
142+
- name: var-declaration
143+
144+
# warns when initialism, variable or package naming conventions are not followed.
145+
- name: var-naming
146+
147+
- name: comment-spacings
148+
149+
- name: unhandled-error
150+
151+
dupword:
152+
# Keywords used to ignore detection.
153+
# Default: []
154+
ignore:
155+
# - "blah" # this will accept "blah blah …" as a valid duplicate word
156+
157+
misspell:
158+
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
159+
locale: US

0 commit comments

Comments
 (0)