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
18 changes: 18 additions & 0 deletions .github/workflows/all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI
on:
# Enable manually triggering this workflow via the API or web UI
workflow_dispatch:
push:
branches:
- main
- master
tags:
- v*
pull_request:

permissions:
contents: read

jobs:
checks:
uses: grafana/k6-ci/.github/workflows/all.yml@143ec80c1678ae96a54b82389ea862d4748c27e1 # v0.3.0
26 changes: 0 additions & 26 deletions .github/workflows/validate.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ xk6
xk6.exe
/build
coverage.txt
# Generated by `make lint` (k6-ci golangci config)
.golangci-base.yml
.golangci.yml
29 changes: 28 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
SHELL=bash
.SHELLFLAGS=-e -o pipefail -c

# k6-ci golangci-lint config. `make lint` downloads .golangci.yml from
# grafana/k6-ci at the ref pinned in $(WORKFLOW) and applies the optional
# $(LINT_PATCH). See grafana/k6-ci/README.md.
WORKFLOW ?= .github/workflows/all.yml
K6_CI_REF := $(shell grep -oE 'grafana/k6-ci/[^@[:space:]]+@[A-Za-z0-9._/-]+' $(WORKFLOW) | head -n1 | cut -d@ -f2)
LINT_BASE ?= .golangci-base.yml
LINT_FINAL ?= .golangci.yml
LINT_PATCH ?= .golangci.patch

.PHONY: __help__
__help__:
@echo 'Usage: make [target]'
Expand Down Expand Up @@ -47,10 +56,28 @@ format:
.PHONY: lint
lint:
@(\
golangci-lint run ./...;\
curl -fsSL https://raw.githubusercontent.com/grafana/k6-ci/$(K6_CI_REF)/.golangci.yml -o $(LINT_BASE);\
cp $(LINT_BASE) $(LINT_FINAL);\
if [ -f $(LINT_PATCH) ]; then echo "Applying $(LINT_PATCH)"; git apply $(LINT_PATCH); fi;\
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$$(head -n1 $(LINT_BASE) | tr -d '# ') run --config=$(LINT_FINAL) ./...;\
xk6 lint;\
)

# Regenerate $(LINT_PATCH) from the locally edited $(LINT_FINAL)
.PHONY: update-lint-patch
update-lint-patch:
@(\
if [ ! -f $(LINT_FINAL) ]; then echo "Run 'make lint' first to materialize $(LINT_FINAL), edit it, then re-run."; exit 1; fi;\
diff -u --label a/.golangci.yml --label b/.golangci.yml $(LINT_BASE) $(LINT_FINAL) > $(LINT_PATCH) || true;\
)

# Remove the downloaded/assembled lint config
.PHONY: clean-lint
clean-lint:
@(\
rm -f $(LINT_BASE) $(LINT_FINAL);\
)

# Generate the Makefile
.PHONY: makefile
makefile:
Expand Down
8 changes: 5 additions & 3 deletions cmd_greet.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package example

import (
"fmt"

"github.com/spf13/cobra"
"go.k6.io/k6/v2/cmd/state"
)
Expand All @@ -22,9 +24,9 @@ Customize the greeting by specifying a name with the --name flag.

name := cmd.Flags().StringP("name", "n", "User", "Name of the person to greet")

cmd.RunE = func(cmd *cobra.Command, args []string) error {
println("Hello, " + *name + "! Happy subcommanding with k6!")
return nil
cmd.RunE = func(cmd *cobra.Command, _ []string) error {
_, err := fmt.Fprintln(cmd.OutOrStdout(), "Hello, "+*name+"! Happy subcommanding with k6!")
return err
}

return cmd
Expand Down
Loading