Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI
on:
# Enable manually triggering this workflow via the API or web UI
workflow_dispatch:
push:
branches:
- main
tags:
- v*
pull_request:

jobs:
checks:
uses: grafana/k6-ci/.github/workflows/all.yml@main
with:
skip-extension-testing: true
43 changes: 0 additions & 43 deletions .github/workflows/lint.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/sync-k6-deps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-go@v6
with:
go-version: "1.23.x"
go-version: "1.26.x"
cache: false
- name: Sync dependencies
run: |
Expand Down
44 changes: 0 additions & 44 deletions .github/workflows/test.yml

This file was deleted.

135 changes: 0 additions & 135 deletions .golangci.yml

This file was deleted.

20 changes: 15 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
work_dir = $(shell pwd)
golangci_version = $(shell head -n 1 .golangci.yml | tr -d '\# ')
GOLANGCI_CONFIG ?= .golangci.yml

all: build

Expand All @@ -12,11 +12,21 @@ format:
gofmt -w -s .
gofumpt -w .

# Running with -buildvcs=false works around the issue of `go list all` failing when git, which runs as root inside
# the container, refuses to operate on the disruptor source tree as it is not owned by the same user (root).
## linter-config: Checks if the linter config exists, if not, downloads it from the main k6 repository.
.PHONY: linter-config
linter-config:
test -s "${GOLANGCI_CONFIG}" || (echo "No linter config, downloading from main k6 repository..." && curl --silent --show-error --fail --no-location https://raw.githubusercontent.com/grafana/k6/master/.golangci.yml --output "${GOLANGCI_CONFIG}")

## check-linter-version: Checks if the linter version is the same as the one specified in the linter config.
.PHONY: check-linter-version
check-linter-version:
(golangci-lint version | grep "version $(shell head -n 1 .golangci.yml | tr -d '\# ')") || echo "Your installation of golangci-lint is different from the one that is specified in k6's linter config (there it's $(shell head -n 1 .golangci.yml | tr -d '\# ')). Results could be different in the CI."

## lint: Runs the linters.
.PHONY: lint
lint: format
docker run --rm -v $(work_dir):/src -w /src -e GOFLAGS=-buildvcs=false golangci/golangci-lint:$(golangci_version) golangci-lint run
lint: linter-config check-linter-version
echo "Running linters..."
golangci-lint run ./...

.PHONY: test
test:
Expand Down
10 changes: 5 additions & 5 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ func (a Artifact) PrintSummary() string {
func (a Artifact) toString(details bool, sep string) string {
buffer := &bytes.Buffer{}
if details {
buffer.WriteString(fmt.Sprintf("id: %s%s", a.ID, sep))
fmt.Fprintf(buffer, "id: %s%s", a.ID, sep)
}
buffer.WriteString(fmt.Sprintf("platform: %s%s", a.Platform, sep))
fmt.Fprintf(buffer, "platform: %s%s", a.Platform, sep)
for dep, version := range a.Dependencies {
buffer.WriteString(fmt.Sprintf("%s:%q%s", dep, version, sep))
fmt.Fprintf(buffer, "%s:%q%s", dep, version, sep)
}
buffer.WriteString(fmt.Sprintf("checksum: %s%s", a.Checksum, sep))
fmt.Fprintf(buffer, "checksum: %s%s", a.Checksum, sep)
if details {
buffer.WriteString(fmt.Sprintf("url: %s%s", a.URL, sep))
fmt.Fprintf(buffer, "url: %s%s", a.URL, sep)
}
return buffer.String()
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/k6build/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ func main() {
err := root.Execute()
if err != nil {
fmt.Printf("%s\n", err.Error())
os.Exit(1)
os.Exit(1) //nolint:forbidigo
}
}
8 changes: 4 additions & 4 deletions cmd/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ func New() *cobra.Command { //nolint:funlen
if err != nil {
return fmt.Errorf("malformed URL %w", err)
}
artifactBinary, err := os.Open(binaryURL.Path)
artifactBinary, err := os.Open(binaryURL.Path) //nolint:gosec,forbidigo
if err != nil {
return fmt.Errorf("opening output file %w", err)
}
defer func() {
_ = artifactBinary.Close()
}()

binary, err := os.OpenFile(output, os.O_WRONLY|os.O_CREATE, 0o755) //nolint:gosec
binary, err := os.OpenFile(output, os.O_WRONLY|os.O_CREATE, 0o755) //nolint:gosec,forbidigo
if err != nil {
return fmt.Errorf("opening output file %w", err)
}
Expand All @@ -127,9 +127,9 @@ func New() *cobra.Command { //nolint:funlen
_ = cmd.MarkFlagRequired("platform")
cmd.Flags().StringVarP(&config.Catalog, "catalog", "c", catalog.DefaultCatalogURL, "dependencies catalog")
cmd.Flags().StringVarP(&config.StoreDir, "store-dir", "f", "/tmp/k6build/store", "object store dir")
cmd.Flags().BoolVarP(&config.Opts.Verbose, "verbose", "v", false, "print build process output")
cmd.Flags().BoolVarP(&config.Verbose, "verbose", "v", false, "print build process output")
cmd.Flags().BoolVarP(&config.CopyGoEnv, "copy-go-env", "g", true, "copy go environment")
cmd.Flags().StringToStringVarP(&config.Opts.Env, "env", "e", nil, "build environment variables")
cmd.Flags().StringToStringVarP(&config.Env, "env", "e", nil, "build environment variables")
cmd.Flags().StringVarP(&output, "output", "o", "k6", "path to put the binary as an executable.")
cmd.Flags().BoolVarP(&quiet, "quiet", "q", false, "don't print artifact's details")
cmd.Flags().BoolVar(
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ func getLogger(logLevel string) (*slog.Logger, error) {

return slog.New(
slog.NewTextHandler(
os.Stderr,
os.Stderr, //nolint:forbidigo
&slog.HandlerOptions{
Level: ll,
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func New() *cobra.Command {

log := slog.New(
slog.NewTextHandler(
os.Stderr,
os.Stderr, //nolint:forbidigo
&slog.HandlerOptions{
Level: ll,
},
Expand Down
8 changes: 4 additions & 4 deletions internal/clireadme/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func printLong(buff *bytes.Buffer, cmd *cobra.Command, offset int) {

func printUseLine(buff *bytes.Buffer, cmd *cobra.Command) {
if cmd.Runnable() {
buff.WriteString(fmt.Sprintf("```\n%s\n```\n\n", cmd.UseLine()))
fmt.Fprintf(buff, "```\n%s\n```\n\n", cmd.UseLine())
}
}

Expand Down Expand Up @@ -100,7 +100,7 @@ func printExamples(buff *bytes.Buffer, cmd *cobra.Command, offset int) {
}

buff.WriteString(heading(offset, 2, "Examples"))
buff.WriteString(fmt.Sprintf("```\n%s\n```\n\n", cmd.Example))
fmt.Fprintf(buff, "```\n%s\n```\n\n", cmd.Example)
}

func printAdditionalHelpTopics(buff *bytes.Buffer, cmd *cobra.Command, offset int) {
Expand Down Expand Up @@ -140,7 +140,7 @@ func printSeeAlso(buf *bytes.Buffer, cmd *cobra.Command, offset int) {
parent := cmd.Parent()
pname := parent.CommandPath()
link := strings.ReplaceAll(pname, " ", "-")
buf.WriteString(fmt.Sprintf("* [%s](#%s)\t - %s\n", pname, link, parent.Short))
fmt.Fprintf(buf, "* [%s](#%s)\t - %s\n", pname, link, parent.Short)
}

firstChild := true
Expand All @@ -156,7 +156,7 @@ func printSeeAlso(buf *bytes.Buffer, cmd *cobra.Command, offset int) {

cname := cmd.CommandPath() + " " + child.Name()
link := strings.ReplaceAll(cname, " ", "-")
buf.WriteString(fmt.Sprintf("* [%s](#%s)\t - %s\n", cname, link, child.Short))
fmt.Fprintf(buf, "* [%s](#%s)\t - %s\n", cname, link, child.Short)
}

buf.WriteString("\n")
Expand Down
Loading
Loading