From e264ff25ba4b885c0bd36871ed5ec326cfe1c00c Mon Sep 17 00:00:00 2001 From: Oleg Bespalov Date: Fri, 11 Mar 2022 17:35:53 +0100 Subject: [PATCH 1/5] chore: update CONTRIBUTING.md --- CONTRIBUTING.md | 43 ++++++++++++++++++++++++++++++------------- Makefile | 6 +++--- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 01f213358dd..55d01f813aa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,16 +23,16 @@ Contributing code If you'd like to contribute code to k6, this is the basic procedure. Make sure to follow the [style guide](#style-guide) described below. -1. Find an issue you'd like to fix. If there is none already, or you'd like to add a feature, please open one and we can talk about how to do it. Out of respect for your time, please start a discussion regarding any bigger contributions either in a GitHub Issue, in the community forums or in the `#contributors` channel of the k6 slack **before** you get started on the implementation. +1. Find an issue you'd like to fix. If there is none already, or you'd like to add a feature, please open one, and we can talk about how to do it. Out of respect for your time, please start a discussion regarding any bigger contributions either in a GitHub Issue, in the community forums or in the `#contributors` channel of the k6 slack **before** you get started on the implementation. - Remember, there's more to software development than code; if it's not properly planned, stuff gets messy real fast. + Remember, there's more to software development than code; if it's not properly planned, stuff gets messy real fast. 2. Create a fork and open a feature branch - `feature/my-cool-feature` is the classic way to name these, but it really doesn't matter. 3. Create a pull request! -4. Sign the [Contributor License Agreement](https://cla-assistant.io/loadimpact/k6) (the process is integrated with the pull request flow through cla-assistant.io) +4. Sign the [Contributor License Agreement](https://cla-assistant.io/grafana/k6) (the process is integrated with the pull request flow through cla-assistant.io). 5. We will discuss implementation details until everyone is happy, then a maintainer will merge it. @@ -42,14 +42,17 @@ Development setup To get a basic development environment for Go and k6 up and running, first make sure you have **[Git](https://git-scm.com/downloads)** and **[Go](https://golang.org/doc/install)** (1.10 or newer) installed and working properly. Once that's done, you can get the k6 source into your Go workspace (`$GOPATH/src`) by running: + ```bash go get go.k6.io/k6 ``` + This will also build a `k6` binary and put it in `$GOPATH/bin`. **Building from source**: Standing in the repo root (`$GOPATH/src/go.k6.io/k6`) you can build a k6 binary from source by running: + ```bash cd $GOPATH/src/go.k6.io/k6 go build @@ -58,15 +61,25 @@ go build **Running the linter**: We make use of the [golangci-lint](https://github.com/golangci/golangci-lint) tool to lint the code in CI. To run it locally, first install it: + ```bash go get -u github.com/golangci/golangci-lint/cmd/golangci-lint ``` + then run: + +```bash +make lint ``` -golangci-lint run --out-format=tab --new-from-rev master ./... + +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 ``` -If you've added new dependencies you might also want to check and make sure all dependencies exists in `vendor/` folder by running: +If you've added new dependencies (and just in case [we have a policy about it](Dependencies.md)) you might also want to check and make sure all dependencies exists in `vendor/` folder by running: + ```bash go get -u github.com/FiloSottile/vendorcheck vendorcheck ./... @@ -75,21 +88,25 @@ vendorcheck ./... **Running the test suite**: To exercise the entire test suite: + ```bash -go test -race ./... +make test ``` To run the tests of a specific package: + ```bash go test -race go.k6.io/k6/core ``` To run just a specific test case use `-run` and pass in a regex that matches the name of the test: + ```bash go test -race ./... -run ^TestEngineRun$ ``` Combining the two above we can run a specific test case in a specific package: + ```bash go test -race go.k6.io/k6/core -run ^TestEngineRun$ ``` @@ -105,8 +122,8 @@ As you'd expect, please adhere to good ol' `gofmt` (there are plugins for most e Continuous integration will catch all of this if you don't, and it's fine to just fix linter complaints with another commit, but you can also run the linter yourself: -``` -golangci-lint run --out-format=tab --new-from-rev master ./... +```bash +make check ``` Comments in the source should wrap at 100 characters, but there's no maximum length or need to be brief here - please include anything one might need to know in order to understand the code, that you could reasonably expect any reader to not already know (you probably don't need to explain what a goroutine is). @@ -117,7 +134,7 @@ We don't have any explicit rules about commit message formatting, but try to wri If your commit closes an issue, please [close it with your commit message](https://help.github.com/articles/closing-issues-via-commit-messages/), for example: -``` +```text Added this really rad feature Closes #420 @@ -125,11 +142,11 @@ Closes #420 **Language and text formatting** -Any human-readable text you add must be non-gendered, and should be fairly concise without devolving into grammatical horrors, dropped words and shorthands. This isn't Twitter, you don't have a character cap, but don't write a novel where a single sentence would suffice. +Any human-readable text you add must be non-gendered and should be fairly concise without devolving into grammatical horrors, dropped words, and shorthands. This isn't Twitter, you don't have a character cap, but don't write a novel where a single sentence would suffice. -If you're writing a longer block of text to a terminal, wrap it at 80 characters - this ensures it will display properly at the de facto default terminal size of 80x25. As an example, this is the help text of the `scale` subcommand: +If you're writing a longer block of text to a terminal, wrap it at 80 characters - this ensures it will display properly at the de facto default terminal size of 80x25. As an example, this is the help text of the `scale` sub-command: -``` +```text Scale will change the number of active VUs of a running test. It is an error to scale a test beyond vus-max; this is because instantiating @@ -142,6 +159,6 @@ If you're writing a longer block of text to a terminal, wrap it at 80 characters **License** -If you make a new source file, you must copy the license preamble from an existing file to the top of it. We can't merge a PR with unlicensed source files. We also can't merge PRs unless all authors have signed the [Contributor License Agreement](https://cla-assistant.io/loadimpact/k6). +If you make a new source file, you must copy the license preamble from an existing file to the top of it. We can't merge a PR with unlicensed source files. We also can't merge PRs unless all authors have signed the [Contributor License Agreement](https://cla-assistant.io/grafana/k6). This doesn't apply to documentation or sample code; only files that make up the application itself. diff --git a/Makefile b/Makefile index be11de32187..23bbc6ab67a 100644 --- a/Makefile +++ b/Makefile @@ -19,12 +19,12 @@ ci-like-lint : lint : golangci-lint run --out-format=tab --new-from-rev master ./... -tests : +test : go test -race -timeout 210s ./... -check : ci-like-lint tests +check : ci-like-lint test container: docker build --rm --pull --no-cache -t grafana/k6 . -.PHONY: build format ci-like-lint lint tests check container +.PHONY: build format ci-like-lint lint test check container From 65b3fd84172ed01eb77692be17a23013c573eb2f Mon Sep 17 00:00:00 2001 From: Oleg Bespalov Date: Sat, 12 Mar 2022 09:45:27 +0100 Subject: [PATCH 2/5] chore: apply code review changes --- CONTRIBUTING.md | 11 ++++------- Makefile | 12 ++++++------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 55d01f813aa..1e40d58c974 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -78,13 +78,6 @@ You can also run the linter inside the docker container, which will benefit from make ci-like-lint ``` -If you've added new dependencies (and just in case [we have a policy about it](Dependencies.md)) you might also want to check and make sure all dependencies exists in `vendor/` folder by running: - -```bash -go get -u github.com/FiloSottile/vendorcheck -vendorcheck ./... -``` - **Running the test suite**: To exercise the entire test suite: @@ -111,6 +104,10 @@ Combining the two above we can run a specific test case in a specific package: go test -race go.k6.io/k6/core -run ^TestEngineRun$ ``` +**Dependencies**: + +Actual policy about managing k6's dependencies you can find in the [Dependencies.md](Dependencies.md). + Style guide ----------- diff --git a/Makefile b/Makefile index 23bbc6ab67a..ab5d29652f9 100644 --- a/Makefile +++ b/Makefile @@ -3,26 +3,26 @@ TMPDIR ?= /tmp all: build -build : +build: go build -format : +format: find . -name '*.go' -exec gofmt -s -w {} + -ci-like-lint : +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 -lint : +lint: golangci-lint run --out-format=tab --new-from-rev master ./... -test : +test: go test -race -timeout 210s ./... -check : ci-like-lint test +check: ci-like-lint test container: docker build --rm --pull --no-cache -t grafana/k6 . From 874abb2b31a907a9f34b67c2194ded8bcd35da70 Mon Sep 17 00:00:00 2001 From: Oleg Bespalov Date: Wed, 13 Apr 2022 17:22:17 +0200 Subject: [PATCH 3/5] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mihail Stoykov Co-authored-by: Théo Crevon --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1e40d58c974..d4548ca3402 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -39,7 +39,7 @@ If you'd like to contribute code to k6, this is the basic procedure. Make sure t Development setup ----------------- -To get a basic development environment for Go and k6 up and running, first make sure you have **[Git](https://git-scm.com/downloads)** and **[Go](https://golang.org/doc/install)** (1.10 or newer) installed and working properly. +To get a basic development environment for Go and k6 up and running, first make sure you have **[Git](https://git-scm.com/downloads)** and **[Go](https://golang.org/doc/install)** (1.17 or newer) installed and working properly. Once that's done, you can get the k6 source into your Go workspace (`$GOPATH/src`) by running: @@ -106,7 +106,7 @@ go test -race go.k6.io/k6/core -run ^TestEngineRun$ **Dependencies**: -Actual policy about managing k6's dependencies you can find in the [Dependencies.md](Dependencies.md). +Consult [Dependencies.md](Dependencies.md) to find out more about how we manage k6's dependencies, and our policy regarding dependencies management and update. Style guide ----------- From 8692f56bede3d0a2947cefbf5ba097e87e218394 Mon Sep 17 00:00:00 2001 From: Oleg Bespalov Date: Wed, 13 Apr 2022 17:54:28 +0200 Subject: [PATCH 4/5] chore: apply suggestions --- CONTRIBUTING.md | 85 ++++++++++++------------------------------------- Makefile | 14 ++++---- 2 files changed, 28 insertions(+), 71 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d4548ca3402..4af7e1c134a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,4 @@ -Contributing to k6 -================== +# Contributing to k6 Thank you for your interest in contributing to k6! @@ -7,23 +6,22 @@ Thank you for your interest in contributing to k6! Before you begin, make sure to familiarize yourself with the [Code of Conduct](CODE_OF_CONDUCT.md). If you've previously contributed to other open source project, you may recognize it as the classic [Contributor Covenant](https://contributor-covenant.org/). -If you want to chat with the team or the community, you can [join our Slack team](https://k6.io/slack/). +If you want to chat with the team or the community, you can [join our community forums](https://community.k6.io/). -Filing issues +## Filing issues ------------- Don't be afraid to file issues! Nobody can fix a bug we don't know exists, or add a feature we didn't think of. The worst that can happen is that someone closes it and points you in the right direction. -That said, "how do I..."-type questions are often more suited for Slack. +That said, "how do I..."-type questions are often more suited for community forums. -Contributing code ------------------ +## Contributing code If you'd like to contribute code to k6, this is the basic procedure. Make sure to follow the [style guide](#style-guide) described below. -1. Find an issue you'd like to fix. If there is none already, or you'd like to add a feature, please open one, and we can talk about how to do it. Out of respect for your time, please start a discussion regarding any bigger contributions either in a GitHub Issue, in the community forums or in the `#contributors` channel of the k6 slack **before** you get started on the implementation. +1. Find an issue you'd like to fix. If there is none already, or you'd like to add a feature, please open one, and we can talk about how to do it. Out of respect for your time, please start a discussion regarding any bigger contributions either in a GitHub Issue, in the community forums **before** you get started on the implementation. Remember, there's more to software development than code; if it's not properly planned, stuff gets messy real fast. @@ -36,37 +34,20 @@ If you'd like to contribute code to k6, this is the basic procedure. Make sure t 5. We will discuss implementation details until everyone is happy, then a maintainer will merge it. -Development setup ------------------ +### Development setup -To get a basic development environment for Go and k6 up and running, first make sure you have **[Git](https://git-scm.com/downloads)** and **[Go](https://golang.org/doc/install)** (1.17 or newer) installed and working properly. +To get a basic development environment for Go and k6 up and running, first make sure you have **[Git](https://git-scm.com/downloads)** and **[Go](https://golang.org/doc/install)** (see our [go.mod](https://github.com/grafana/k6/blob/master/go.mod#L3) for minimum required version) installed and working properly. -Once that's done, you can get the k6 source into your Go workspace (`$GOPATH/src`) by running: +We recommend using the Git command-line interface to download the source code for the k6: -```bash -go get go.k6.io/k6 -``` - -This will also build a `k6` binary and put it in `$GOPATH/bin`. - -**Building from source**: +* Open a terminal and run `git clone https://github.com/grafana/k6.git`. This command downloads k6's sources to a new `k6` directory in your current directory. +* Open the `k6` directory in your favorite code editor. -Standing in the repo root (`$GOPATH/src/go.k6.io/k6`) you can build a k6 binary from source by running: - -```bash -cd $GOPATH/src/go.k6.io/k6 -go build -``` +For alternative ways of cloning the k6 repository, please refer to [GitHub's cloning a repository](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) documentation. -**Running the linter**: +#### Running the linter -We make use of the [golangci-lint](https://github.com/golangci/golangci-lint) tool to lint the code in CI. To run it locally, first install it: - -```bash -go get -u github.com/golangci/golangci-lint/cmd/golangci-lint -``` - -then run: +We make use of the [golangci-lint](https://github.com/golangci/golangci-lint) tool to lint the code in CI. To run it locally, first [install it](https://golangci-lint.run/usage/install/#local-installation), then run: ```bash make lint @@ -78,42 +59,19 @@ You can also run the linter inside the docker container, which will benefit from make ci-like-lint ``` -**Running the test suite**: +#### Running the test suite -To exercise the entire test suite: +To exercise the entire test suite, please run the following command ```bash make test ``` -To run the tests of a specific package: - -```bash -go test -race go.k6.io/k6/core -``` - -To run just a specific test case use `-run` and pass in a regex that matches the name of the test: - -```bash -go test -race ./... -run ^TestEngineRun$ -``` - -Combining the two above we can run a specific test case in a specific package: - -```bash -go test -race go.k6.io/k6/core -run ^TestEngineRun$ -``` - -**Dependencies**: +#### Dependencies Consult [Dependencies.md](Dependencies.md) to find out more about how we manage k6's dependencies, and our policy regarding dependencies management and update. -Style guide ------------ - -In order to keep the project manageable, consistency is very important. Most of this is enforced automatically by various bots. - -**Code style** +#### Code style As you'd expect, please adhere to good ol' `gofmt` (there are plugins for most editors that can autocorrect this), but also `gofmt -s` (code simplification), and don't leave unused functions laying around. @@ -125,7 +83,7 @@ make check Comments in the source should wrap at 100 characters, but there's no maximum length or need to be brief here - please include anything one might need to know in order to understand the code, that you could reasonably expect any reader to not already know (you probably don't need to explain what a goroutine is). -**Commit format** +#### Commit format We don't have any explicit rules about commit message formatting, but try to write something that could be included as-is in a changelog. @@ -137,7 +95,7 @@ Added this really rad feature Closes #420 ``` -**Language and text formatting** +#### Language and text formatting Any human-readable text you add must be non-gendered and should be fairly concise without devolving into grammatical horrors, dropped words, and shorthands. This isn't Twitter, you don't have a character cap, but don't write a novel where a single sentence would suffice. @@ -153,8 +111,7 @@ If you're writing a longer block of text to a terminal, wrap it at 80 characters Endpoint: /v1/status ``` - -**License** +### License If you make a new source file, you must copy the license preamble from an existing file to the top of it. We can't merge a PR with unlicensed source files. We also can't merge PRs unless all authors have signed the [Contributor License Agreement](https://cla-assistant.io/grafana/k6). diff --git a/Makefile b/Makefile index ab5d29652f9..be11de32187 100644 --- a/Makefile +++ b/Makefile @@ -3,28 +3,28 @@ TMPDIR ?= /tmp all: build -build: +build : go build -format: +format : find . -name '*.go' -exec gofmt -s -w {} + -ci-like-lint: +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 -lint: +lint : golangci-lint run --out-format=tab --new-from-rev master ./... -test: +tests : go test -race -timeout 210s ./... -check: ci-like-lint test +check : ci-like-lint tests container: docker build --rm --pull --no-cache -t grafana/k6 . -.PHONY: build format ci-like-lint lint test check container +.PHONY: build format ci-like-lint lint tests check container From 412ec92d1fd145f8fb29bb03c861334bef4939ca Mon Sep 17 00:00:00 2001 From: Oleg Bespalov Date: Thu, 14 Apr 2022 09:36:23 +0200 Subject: [PATCH 5/5] chore: apply code review suggestions --- CONTRIBUTING.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4af7e1c134a..42a964d9534 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,7 +9,6 @@ Before you begin, make sure to familiarize yourself with the [Code of Conduct](C If you want to chat with the team or the community, you can [join our community forums](https://community.k6.io/). ## Filing issues -------------- Don't be afraid to file issues! Nobody can fix a bug we don't know exists, or add a feature we didn't think of. @@ -23,7 +22,6 @@ If you'd like to contribute code to k6, this is the basic procedure. Make sure t 1. Find an issue you'd like to fix. If there is none already, or you'd like to add a feature, please open one, and we can talk about how to do it. Out of respect for your time, please start a discussion regarding any bigger contributions either in a GitHub Issue, in the community forums **before** you get started on the implementation. - Remember, there's more to software development than code; if it's not properly planned, stuff gets messy real fast. 2. Create a fork and open a feature branch - `feature/my-cool-feature` is the classic way to name these, but it really doesn't matter. @@ -47,7 +45,7 @@ For alternative ways of cloning the k6 repository, please refer to [GitHub's clo #### Running the linter -We make use of the [golangci-lint](https://github.com/golangci/golangci-lint) tool to lint the code in CI. To run it locally, first [install it](https://golangci-lint.run/usage/install/#local-installation), then run: +We make use of the [golangci-lint](https://github.com/golangci/golangci-lint) tool to lint the code in CI. The actual version you can find in our [`.golangci.yml`](https://github.com/grafana/k6/blob/master/.golangci.yml#L1). To run it locally, first [install it](https://golangci-lint.run/usage/install/#local-installation), then run: ```bash make lint @@ -110,9 +108,3 @@ If you're writing a longer block of text to a terminal, wrap it at 80 characters Endpoint: /v1/status ``` - -### License - -If you make a new source file, you must copy the license preamble from an existing file to the top of it. We can't merge a PR with unlicensed source files. We also can't merge PRs unless all authors have signed the [Contributor License Agreement](https://cla-assistant.io/grafana/k6). - -This doesn't apply to documentation or sample code; only files that make up the application itself.