-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from grafana/paul/adding-ci
Add CI workflows and update to correct linter issues
- Loading branch information
Showing
4 changed files
with
247 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
name: CI | ||
on: | ||
# Enable manually triggering this workflow via the API or web UI | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- v* | ||
pull_request: | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Install Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.20.x | ||
- name: Retrieve golangci-lint version | ||
run: | | ||
echo "Version=$(head -n 1 "${GITHUB_WORKSPACE}/.golangci.yml" | tr -d '# ')" >> $GITHUB_OUTPUT | ||
id: version | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: ${{ steps.version.outputs.Version }} | ||
only-new-issues: true | ||
|
||
test-go-versions: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
go-version: [1.18.x, 1.19.x, 1.20.x, tip] | ||
platform: [ubuntu-latest, windows-latest] | ||
runs-on: ${{ matrix.platform }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Install Go ${{ matrix.go-version }} | ||
if: matrix.go-version != 'tip' | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Install Go stable | ||
if: matrix.go-version == 'tip' | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.x | ||
- name: Install Go tip | ||
shell: bash | ||
if: matrix.go-version == 'tip' | ||
run: | | ||
go install golang.org/dl/gotip@latest | ||
gotip download | ||
echo "GOROOT=$HOME/sdk/gotip" >> "$GITHUB_ENV" | ||
echo "GOPATH=$HOME/go" >> "$GITHUB_ENV" | ||
echo "$HOME/go/bin" >> "$GITHUB_PATH" | ||
echo "$HOME/sdk/gotip/bin" >> "$GITHUB_PATH" | ||
- name: Run tests | ||
run: | | ||
which go | ||
go version | ||
go test -race -timeout 800s ./... | ||
test-build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Install Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.20.x | ||
- name: Check build | ||
run: | | ||
go version | ||
pwd && ls -l | ||
go install go.k6.io/xk6/cmd/xk6@master | ||
MODULE_NAME=`go list -m` | ||
GOPRIVATE="go.k6.io/k6" xk6 build \ | ||
--output ./k6ext \ | ||
--with $MODULE_NAME="." | ||
./k6ext version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# v1.52.2 | ||
# Please don't remove the first line. It uses in CI to determine the golangci version | ||
run: | ||
deadline: 5m | ||
|
||
issues: | ||
# Maximum issues count per one linter. Set to 0 to disable. Default is 50. | ||
max-issues-per-linter: 0 | ||
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3. | ||
max-same-issues: 0 | ||
|
||
# We want to try and improve the comments in the k6 codebase, so individual | ||
# non-golint items from the default exclusion list will gradually be addded | ||
# to the exclude-rules below | ||
exclude-use-default: false | ||
|
||
exclude-rules: | ||
# Exclude duplicate code and function length and complexity checking in test | ||
# files (due to common repeats and long functions in test code) | ||
- path: _(test|gen)\.go | ||
linters: | ||
- cyclop | ||
- dupl | ||
- gocognit | ||
- funlen | ||
- lll | ||
- linters: | ||
- paralleltest # false positive: https://github.com/kunwardeep/paralleltest/issues/8. | ||
text: "does not use range value in test Run" | ||
- linters: | ||
- forbidigo | ||
text: 'use of `os\.(SyscallError|Signal|Interrupt)` forbidden' | ||
|
||
linters-settings: | ||
nolintlint: | ||
# Disable to ensure that nolint directives don't have a leading space. Default is true. | ||
allow-leading-space: false | ||
exhaustive: | ||
default-signifies-exhaustive: true | ||
govet: | ||
check-shadowing: true | ||
cyclop: | ||
max-complexity: 25 | ||
maligned: | ||
suggest-new: true | ||
dupl: | ||
threshold: 150 | ||
goconst: | ||
min-len: 10 | ||
min-occurrences: 4 | ||
funlen: | ||
lines: 80 | ||
statements: 60 | ||
forbidigo: | ||
forbid: | ||
- '^(fmt\\.Print(|f|ln)|print|println)$' | ||
# Forbid everything in os, except os.Signal and os.SyscalError | ||
- '^os\.(.*)$(# Using anything except Signal and SyscallError from the os package is forbidden )?' | ||
# Forbid everything in syscall except the uppercase constants | ||
- '^syscall\.[^A-Z_]+$(# Using anything except constants from the syscall package is forbidden )?' | ||
- '^logrus\.Logger$' | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- asasalint | ||
- asciicheck | ||
- bidichk | ||
- bodyclose | ||
- contextcheck | ||
- cyclop | ||
- depguard | ||
- dogsled | ||
- dupl | ||
- durationcheck | ||
- errcheck | ||
- errchkjson | ||
- errname | ||
- errorlint | ||
- exhaustive | ||
- exportloopref | ||
- forbidigo | ||
- forcetypeassert | ||
- funlen | ||
- gocheckcompilerdirectives | ||
- gochecknoglobals | ||
- gocognit | ||
- goconst | ||
- gocritic | ||
- gofmt | ||
- gofumpt | ||
- goimports | ||
- gomoddirectives | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- importas | ||
- ineffassign | ||
- lll | ||
- makezero | ||
- misspell | ||
- nakedret | ||
- nestif | ||
- nilerr | ||
- nilnil | ||
- noctx | ||
- nolintlint | ||
- nosprintfhostport | ||
- paralleltest | ||
- prealloc | ||
- predeclared | ||
- promlinter | ||
- revive | ||
- reassign | ||
- rowserrcheck | ||
- sqlclosecheck | ||
- staticcheck | ||
- stylecheck | ||
- tenv | ||
- tparallel | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- usestdlibvars | ||
- wastedassign | ||
- whitespace | ||
fast: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
// Package xk6ssh registers the xk6-ssh javascript extension | ||
package xk6ssh | ||
|
||
import "go.k6.io/k6/js/modules" | ||
import ( | ||
"github.com/spf13/afero" | ||
"go.k6.io/k6/js/modules" | ||
) | ||
|
||
func init() { | ||
modules.Register("k6/x/ssh", &K6SSH{}) | ||
modules.Register("k6/x/ssh", &K6SSH{fs: afero.NewOsFs()}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters