Skip to content

Commit 3d188fb

Browse files
authored
Merge pull request #22 from grafana/paul/adding-ci
Paul/adding ci
2 parents 0e044a3 + fc0e44f commit 3d188fb

File tree

12 files changed

+271
-118
lines changed

12 files changed

+271
-118
lines changed

.github/workflows/all.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: CI
2+
on:
3+
# Enable manually triggering this workflow via the API or web UI
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
tags:
9+
- v*
10+
pull_request:
11+
12+
defaults:
13+
run:
14+
shell: bash
15+
16+
jobs:
17+
18+
lint:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v3
23+
with:
24+
fetch-depth: 0
25+
- name: Install Go
26+
uses: actions/setup-go@v3
27+
with:
28+
go-version: 1.20.x
29+
- name: Retrieve golangci-lint version
30+
run: |
31+
echo "Version=$(head -n 1 "${GITHUB_WORKSPACE}/.golangci.yml" | tr -d '# ')" >> $GITHUB_OUTPUT
32+
id: version
33+
- name: golangci-lint
34+
uses: golangci/golangci-lint-action@v3
35+
with:
36+
version: ${{ steps.version.outputs.Version }}
37+
only-new-issues: true
38+
39+
test-go-versions:
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
go-version: [1.18.x, 1.19.x, 1.20.x, tip]
44+
platform: [ubuntu-latest, windows-latest]
45+
runs-on: ${{ matrix.platform }}
46+
steps:
47+
- name: Checkout code
48+
uses: actions/checkout@v3
49+
- name: Install Go ${{ matrix.go-version }}
50+
if: matrix.go-version != 'tip'
51+
uses: actions/setup-go@v3
52+
with:
53+
go-version: ${{ matrix.go-version }}
54+
- name: Install Go stable
55+
if: matrix.go-version == 'tip'
56+
uses: actions/setup-go@v3
57+
with:
58+
go-version: 1.x
59+
- name: Install Go tip
60+
shell: bash
61+
if: matrix.go-version == 'tip'
62+
run: |
63+
go install golang.org/dl/gotip@latest
64+
gotip download
65+
echo "GOROOT=$HOME/sdk/gotip" >> "$GITHUB_ENV"
66+
echo "GOPATH=$HOME/go" >> "$GITHUB_ENV"
67+
echo "$HOME/go/bin" >> "$GITHUB_PATH"
68+
echo "$HOME/sdk/gotip/bin" >> "$GITHUB_PATH"
69+
- name: Run tests
70+
run: |
71+
which go
72+
go version
73+
go test -race -timeout 800s ./...
74+
75+
test-build:
76+
runs-on: ubuntu-latest
77+
steps:
78+
- name: Checkout code
79+
uses: actions/checkout@v3
80+
- name: Install Go
81+
uses: actions/setup-go@v3
82+
with:
83+
go-version: 1.20.x
84+
- name: Check build
85+
run: |
86+
go version
87+
pwd && ls -l
88+
89+
go install go.k6.io/xk6/cmd/xk6@master
90+
MODULE_NAME=`go list -m`
91+
92+
GOPRIVATE="go.k6.io/k6" xk6 build \
93+
--output ./k6ext \
94+
--with $MODULE_NAME="."
95+
./k6ext version

.golangci.yml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# v1.52.2
2+
# Please don't remove the first line. It uses in CI to determine the golangci version
3+
run:
4+
deadline: 5m
5+
6+
issues:
7+
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
8+
max-issues-per-linter: 0
9+
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
10+
max-same-issues: 0
11+
12+
# We want to try and improve the comments in the k6 codebase, so individual
13+
# non-golint items from the default exclusion list will gradually be addded
14+
# to the exclude-rules below
15+
exclude-use-default: false
16+
17+
exclude-rules:
18+
# Exclude duplicate code and function length and complexity checking in test
19+
# files (due to common repeats and long functions in test code)
20+
- path: _(test|gen)\.go
21+
linters:
22+
- cyclop
23+
- dupl
24+
- gocognit
25+
- funlen
26+
- lll
27+
- linters:
28+
- paralleltest # false positive: https://github.com/kunwardeep/paralleltest/issues/8.
29+
text: "does not use range value in test Run"
30+
- linters:
31+
- forbidigo
32+
text: 'use of `os\.(SyscallError|Signal|Interrupt)` forbidden'
33+
34+
linters-settings:
35+
nolintlint:
36+
# Disable to ensure that nolint directives don't have a leading space. Default is true.
37+
allow-leading-space: false
38+
exhaustive:
39+
default-signifies-exhaustive: true
40+
govet:
41+
check-shadowing: true
42+
cyclop:
43+
max-complexity: 25
44+
maligned:
45+
suggest-new: true
46+
dupl:
47+
threshold: 150
48+
goconst:
49+
min-len: 10
50+
min-occurrences: 4
51+
funlen:
52+
lines: 80
53+
statements: 60
54+
forbidigo:
55+
forbid:
56+
- '^(fmt\\.Print(|f|ln)|print|println)$'
57+
# Forbid everything in os, except os.Signal and os.SyscalError
58+
- '^os\.(.*)$(# Using anything except Signal and SyscallError from the os package is forbidden )?'
59+
# Forbid everything in syscall except the uppercase constants
60+
- '^syscall\.[^A-Z_]+$(# Using anything except constants from the syscall package is forbidden )?'
61+
- '^logrus\.Logger$'
62+
63+
linters:
64+
disable-all: true
65+
enable:
66+
- asasalint
67+
- asciicheck
68+
- bidichk
69+
- bodyclose
70+
- contextcheck
71+
- cyclop
72+
- depguard
73+
- dogsled
74+
- dupl
75+
- durationcheck
76+
- errcheck
77+
- errchkjson
78+
- errname
79+
- errorlint
80+
- exhaustive
81+
- exportloopref
82+
- forbidigo
83+
- forcetypeassert
84+
- funlen
85+
- gocheckcompilerdirectives
86+
- gochecknoglobals
87+
- gocognit
88+
- goconst
89+
- gocritic
90+
- gofmt
91+
- gofumpt
92+
- goimports
93+
- gomoddirectives
94+
- goprintffuncname
95+
- gosec
96+
- gosimple
97+
- govet
98+
- importas
99+
- ineffassign
100+
- lll
101+
- makezero
102+
- misspell
103+
- nakedret
104+
- nestif
105+
- nilerr
106+
- nilnil
107+
- noctx
108+
- nolintlint
109+
- nosprintfhostport
110+
- paralleltest
111+
- prealloc
112+
- predeclared
113+
- promlinter
114+
- revive
115+
- reassign
116+
- rowserrcheck
117+
- sqlclosecheck
118+
- staticcheck
119+
- stylecheck
120+
- tenv
121+
- tparallel
122+
- typecheck
123+
- unconvert
124+
- unparam
125+
- unused
126+
- usestdlibvars
127+
- wastedassign
128+
- whitespace
129+
fast: false

go.mod

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ go 1.19
55
require (
66
github.com/Shopify/sarama v1.38.1
77
github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c
8-
github.com/kelseyhightower/envconfig v1.4.0
98
github.com/kubernetes/helm v2.17.0+incompatible
9+
github.com/mstoykov/envconfig v1.4.1-0.20220114105314-765c6d8c76f1
1010
github.com/sirupsen/logrus v1.9.0
1111
github.com/stretchr/testify v1.8.2
1212
github.com/xdg/scram v1.0.5
@@ -22,7 +22,6 @@ require (
2222
github.com/fatih/color v1.15.0 // indirect
2323
github.com/ghodss/yaml v1.0.0 // indirect
2424
github.com/golang/snappy v0.0.4 // indirect
25-
github.com/google/go-cmp v0.5.5 // indirect
2625
github.com/hashicorp/errwrap v1.1.0 // indirect
2726
github.com/hashicorp/go-multierror v1.1.1 // indirect
2827
github.com/hashicorp/go-uuid v1.0.3 // indirect
@@ -38,10 +37,10 @@ require (
3837
github.com/mattn/go-isatty v0.0.18 // indirect
3938
github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd // indirect
4039
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
41-
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
4240
github.com/pierrec/lz4/v4 v4.1.17 // indirect
4341
github.com/pmezard/go-difflib v1.0.0 // indirect
4442
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
43+
github.com/rogpeppe/go-internal v1.10.0 // indirect
4544
github.com/spf13/afero v1.9.5 // indirect
4645
github.com/xdg/stringprep v1.0.3 // indirect
4746
golang.org/x/crypto v0.7.0 // indirect

0 commit comments

Comments
 (0)