Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Makefile's ci-like-lint target #3401

Merged
merged 2 commits into from
Oct 17, 2023
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
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ and code of conduct https://github.com/grafana/k6/blob/master/CODE_OF_CONDUCT.md

- [ ] I have performed a self-review of my code.
- [ ] I have added tests for my changes.
- [ ] I have run linter locally (`make ci-like-lint`) and all checks pass.
- [ ] I have run linter locally (`make lint`) and all checks pass.
- [ ] I have run tests locally (`make tests`) and all tests pass.
- [ ] I have commented on my code, particularly in hard-to-understand areas.
<!-- - [ ] Any other relevant item -->
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# v1.54.1
# v1.54.2
# Please don't remove the first line. It uses in CI to determine the golangci version
run:
deadline: 5m
Expand Down
6 changes: 0 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ We make use of the [golangci-lint](https://github.com/golangci/golangci-lint) to
make lint
```

You can also run the linter inside the docker container, which will benefit from the version of the linter being the same as it will be in CI.

```bash
make ci-like-lint
```

#### Running the test suite

To exercise the entire test suite, please run the following command
Expand Down
48 changes: 33 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,45 @@
MAKEFLAGS += --silent
GOLANGCI_LINT_VERSION = $(shell head -n 1 .golangci.yml | tr -d '\# ')
TMPDIR ?= /tmp

all: build
all: clean format test build

build :
## build: Builds the 'k6' binary.
build:
go build

format :
## format: Applies Go formatting to code.
format:
find . -name '*.go' -exec gofmt -s -w {} +

ci-like-lint :
@docker run --rm -t -v $(shell pwd):/app \
-v $(TMPDIR)/golangci-cache-$(GOLANGCI_LINT_VERSION):/golangci-cache \
--env "GOLANGCI_LINT_CACHE=/golangci-cache" \
-w /app golangci/golangci-lint:$(GOLANGCI_LINT_VERSION) \
make lint
## check-linter-version: Checks if the linter version is the same as the one specified in the linter config.
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 :
## lint: Runs the linters.
lint: check-linter-version
echo "Running linters..."
golangci-lint run --out-format=tab --new-from-rev master ./...

tests :
## tests: Executes any unit tests.
tests:
go test -race -timeout 210s ./...

check : ci-like-lint tests

.PHONY: build format ci-like-lint lint tests check
## check: Runs the linters and tests.
check: lint tests

## help: Prints a list of available build targets.
help:
echo "Usage: make <OPTIONS> ... <TARGETS>"
echo ""
echo "Available targets are:"
echo ''
sed -n 's/^##//p' ${PWD}/Makefile | column -t -s ':' | sed -e 's/^/ /'
echo
echo "Targets run by default are: `sed -n 's/^all: //p' ./Makefile | sed -e 's/ /, /g' | sed -e 's/\(.*\), /\1, and /'`"

## clean: Removes any previously created build artifacts.
clean:
@echo "cleaning"
rm -f ./k6

.PHONY: build format lint tests check check-linter-version help