Skip to content

Commit 64d1f2e

Browse files
authored
Merge pull request #158 from grafana/148-prepare-for-contributions
Prepare for contributions
2 parents 5bc55c8 + adf32b0 commit 64d1f2e

File tree

9 files changed

+491
-59
lines changed

9 files changed

+491
-59
lines changed

Diff for: .devcontainer/devcontainer.json

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "xk6",
3+
"image": "mcr.microsoft.com/devcontainers/base:1-bookworm",
4+
"customizations": {
5+
"vscode": {
6+
"settings": {
7+
"go.lintTool": "golangci-lint",
8+
"go.lintFlags": ["--fast"]
9+
},
10+
"extensions": [
11+
"EditorConfig.EditorConfig",
12+
"esbenp.prettier-vscode",
13+
"github.vscode-github-actions",
14+
"github.vscode-pull-request-github",
15+
"jetmartin.bats",
16+
"mads-hartmann.bash-ide-vscode",
17+
"foxundermoon.shell-format"
18+
]
19+
}
20+
},
21+
22+
"features": {
23+
"ghcr.io/devcontainers/features/github-cli:1": {},
24+
"ghcr.io/devcontainers/features/docker-in-docker:1": {},
25+
"ghcr.io/devcontainers/features/go:1": {
26+
"version": "1.23",
27+
"golangciLintVersion": "1.63.4"
28+
},
29+
"ghcr.io/guiyomh/features/goreleaser:0": { "version": "2.6.1" },
30+
"ghcr.io/guiyomh/features/gotestsum:0": { "version": "1.12.1" },
31+
"ghcr.io/szkiba/devcontainer-features/gosec:1": { "version": "2.22.2" },
32+
"ghcr.io/szkiba/devcontainer-features/govulncheck:1": { "version": "1.1.4" },
33+
"ghcr.io/szkiba/devcontainer-features/bats:1": { "version": "1.11.1" },
34+
"ghcr.io/szkiba/devcontainer-features/cdo:1": { "version": "0.1.2" },
35+
"ghcr.io/szkiba/devcontainer-features/mdcode:1": { "version": "0.2.0" }
36+
},
37+
38+
"remoteEnv": {
39+
"GH_TOKEN": "${localEnv:GH_TOKEN}",
40+
"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}"
41+
}
42+
}

Diff for: .github/release.bats

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/usr/bin/env bats
22

33
setup() {
4-
cd $BATS_TEST_DIRNAME
4+
BASEDIR="$(git rev-parse --show-toplevel)"
5+
cd $BASEDIR
56

6-
EXE="$(ls $(git rev-parse --show-toplevel)/dist/xk6_linux_$(dpkg --print-architecture)_v*/xk6)"
7+
EXE="$(ls ${BASEDIR}/dist/xk6_linux_$(dpkg --print-architecture)_v*/xk6)"
78
IMAGE=grafana/xk6:latest-$(dpkg --print-architecture)
89
IFS=', ' read -r -a K6_VERSIONS <<<"${K6_VERSIONS:-latest}"
910
K6_EXTENSION_MODULE=github.com/grafana/xk6-faker

Diff for: .github/validate.bats

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/usr/bin/env bats
22

33
setup() {
4-
cd $BATS_TEST_DIRNAME
4+
BASEDIR="$(git rev-parse --show-toplevel)"
5+
cd $BASEDIR
56

6-
EXE="$(ls $(git rev-parse --show-toplevel)/dist/xk6_linux_$(dpkg --print-architecture)_v*/xk6)"
7+
EXE="$(ls ${BASEDIR}/dist/xk6_linux_$(dpkg --print-architecture)_v*/xk6)"
78
IFS=', ' read -r -a K6_VERSIONS <<<"${K6_VERSIONS:-latest}"
89
K6_EXTENSION_MODULE=github.com/grafana/xk6-faker
910
K6_EXTENSION_VERSION="v0.4.3"

Diff for: .gitignore

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
.idea/
2-
buildenv_*/
3-
_gitignore/
4-
5-
# build artifacts
6-
**/xk6
7-
**/xk6.exe
8-
# but not the cmd/xk6 directory
9-
!**/xk6/
10-
# generated k6 binaries
1+
/xk6
2+
/xk6.exe
113
k6
4+
k6.exe
125

13-
# mac
14-
.DS_Store
6+
/coverage.txt
157

16-
# goreleaser artifacts
178
dist/

Diff for: Makefile

+88-40
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,88 @@
1-
MAKEFLAGS += --silent
2-
3-
all: clean format test build
4-
5-
## help: Prints a list of available build targets.
6-
help:
7-
echo "Usage: make <OPTIONS> ... <TARGETS>"
8-
echo ""
9-
echo "Available targets are:"
10-
echo ''
11-
sed -n 's/^##//p' ${PWD}/Makefile | column -t -s ':' | sed -e 's/^/ /'
12-
echo
13-
echo "Targets run by default are: `sed -n 's/^all: //p' ./Makefile | sed -e 's/ /, /g' | sed -e 's/\(.*\), /\1, and /'`"
14-
15-
## clean: Removes any previously created build artifacts.
16-
clean:
17-
rm -f ./xk6
18-
rm -f ./k6
19-
20-
## build: Builds the 'xk6' binary.
21-
build:
22-
go build -work ./cmd/xk6
23-
24-
## snapshot: Create snapshot build using goreleaser.
25-
snapshot:
26-
goreleaser build --clean --snapshot --single-target -o xk6
27-
28-
## format: Applies Go formatting to code.
29-
format:
30-
go fmt ./...
31-
32-
## test: Executes any unit tests.
33-
test:
34-
go test -cover -race ./...
35-
36-
## vendor: Pulls source for external dependencies.
37-
vendor:
38-
go mod vendor
39-
40-
.PHONY: build clean format help test vendor
1+
# File generated by cdo from docs/CONTRIBUTING.md; DO NOT EDIT.
2+
3+
SHELL=bash
4+
.SHELLFLAGS=-e -o pipefail -c
5+
6+
.PHONY: __help__
7+
__help__:
8+
@echo 'Usage: make [target]'
9+
@echo ''
10+
@echo 'Targets:'
11+
@echo ' all Clean build'
12+
@echo ' build Build custom k6 with extension'
13+
@echo ' clean Clean the working directory'
14+
@echo ' coverage View the test coverage report'
15+
@echo ' doc Update documentation'
16+
@echo ' format Format the go source codes'
17+
@echo ' it Run the integration tests'
18+
@echo ' lint Run the linter'
19+
@echo ' makefile Generate the Makefile'
20+
@echo ' test Run the tests'
21+
22+
# Clean build
23+
.PHONY: all
24+
all: clean format test build it doc
25+
26+
# Build custom k6 with extension
27+
.PHONY: build
28+
build:
29+
@(\
30+
goreleaser build --clean --snapshot --single-target;\
31+
)
32+
33+
# Clean the working directory
34+
.PHONY: clean
35+
clean:
36+
@(\
37+
rm -rf ./xk6 ./xk6.exe ./k6 ./k6.exe ./coverage.txt ./build ./dist;\
38+
)
39+
40+
# View the test coverage report
41+
.PHONY: coverage
42+
coverage: test
43+
@(\
44+
go tool cover -html=coverage.txt;\
45+
)
46+
47+
# Update documentation
48+
.PHONY: doc
49+
doc:
50+
@(\
51+
mdcode update docs/workflows/README.md;\
52+
)
53+
54+
# Format the go source codes
55+
.PHONY: format
56+
format:
57+
@(\
58+
go fmt ./...;\
59+
)
60+
61+
# Run the integration tests
62+
.PHONY: it
63+
it:
64+
@(\
65+
bats .github/validate.bats .github/release.bats;\
66+
)
67+
68+
# Run the linter
69+
.PHONY: lint
70+
lint:
71+
@(\
72+
golangci-lint run;\
73+
)
74+
75+
# Generate the Makefile
76+
.PHONY: makefile
77+
makefile:
78+
@(\
79+
cdo --makefile Makefile;\
80+
)
81+
82+
# Run the tests
83+
.PHONY: test
84+
test:
85+
@(\
86+
go test -count 1 -race -coverprofile=coverage.txt -timeout 2m ./...;\
87+
)
88+

Diff for: docs/CODE_OF_CONDUCT.md

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
2+
# Contributor Covenant Code of Conduct
3+
4+
## Our Pledge
5+
6+
We as members, contributors, and leaders pledge to make participation in our
7+
community a harassment-free experience for everyone, regardless of age, body
8+
size, visible or invisible disability, ethnicity, sex characteristics, gender
9+
identity and expression, level of experience, education, socio-economic status,
10+
nationality, personal appearance, race, caste, color, religion, or sexual
11+
identity and orientation.
12+
13+
We pledge to act and interact in ways that contribute to an open, welcoming,
14+
diverse, inclusive, and healthy community.
15+
16+
## Our Standards
17+
18+
Examples of behavior that contributes to a positive environment for our
19+
community include:
20+
21+
* Demonstrating empathy and kindness toward other people
22+
* Being respectful of differing opinions, viewpoints, and experiences
23+
* Giving and gracefully accepting constructive feedback
24+
* Accepting responsibility and apologizing to those affected by our mistakes,
25+
and learning from the experience
26+
* Focusing on what is best not just for us as individuals, but for the overall
27+
community
28+
29+
Examples of unacceptable behavior include:
30+
31+
* The use of sexualized language or imagery, and sexual attention or advances of
32+
any kind
33+
* Trolling, insulting or derogatory comments, and personal or political attacks
34+
* Public or private harassment
35+
* Publishing others' private information, such as a physical or email address,
36+
without their explicit permission
37+
* Other conduct which could reasonably be considered inappropriate in a
38+
professional setting
39+
40+
## Enforcement Responsibilities
41+
42+
Community leaders are responsible for clarifying and enforcing our standards of
43+
acceptable behavior and will take appropriate and fair corrective action in
44+
response to any behavior that they deem inappropriate, threatening, offensive,
45+
or harmful.
46+
47+
Community leaders have the right and responsibility to remove, edit, or reject
48+
comments, commits, code, wiki edits, issues, and other contributions that are
49+
not aligned to this Code of Conduct, and will communicate reasons for moderation
50+
decisions when appropriate.
51+
52+
## Scope
53+
54+
This Code of Conduct applies within all community spaces, and also applies when
55+
an individual is officially representing the community in public spaces.
56+
Examples of representing our community include using an official e-mail address,
57+
posting via an official social media account, or acting as an appointed
58+
representative at an online or offline event.
59+
60+
## Enforcement
61+
62+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
63+
reported to the community leaders responsible for enforcement at
64+
[INSERT CONTACT METHOD].
65+
All complaints will be reviewed and investigated promptly and fairly.
66+
67+
All community leaders are obligated to respect the privacy and security of the
68+
reporter of any incident.
69+
70+
## Enforcement Guidelines
71+
72+
Community leaders will follow these Community Impact Guidelines in determining
73+
the consequences for any action they deem in violation of this Code of Conduct:
74+
75+
### 1. Correction
76+
77+
**Community Impact**: Use of inappropriate language or other behavior deemed
78+
unprofessional or unwelcome in the community.
79+
80+
**Consequence**: A private, written warning from community leaders, providing
81+
clarity around the nature of the violation and an explanation of why the
82+
behavior was inappropriate. A public apology may be requested.
83+
84+
### 2. Warning
85+
86+
**Community Impact**: A violation through a single incident or series of
87+
actions.
88+
89+
**Consequence**: A warning with consequences for continued behavior. No
90+
interaction with the people involved, including unsolicited interaction with
91+
those enforcing the Code of Conduct, for a specified period of time. This
92+
includes avoiding interactions in community spaces as well as external channels
93+
like social media. Violating these terms may lead to a temporary or permanent
94+
ban.
95+
96+
### 3. Temporary Ban
97+
98+
**Community Impact**: A serious violation of community standards, including
99+
sustained inappropriate behavior.
100+
101+
**Consequence**: A temporary ban from any sort of interaction or public
102+
communication with the community for a specified period of time. No public or
103+
private interaction with the people involved, including unsolicited interaction
104+
with those enforcing the Code of Conduct, is allowed during this period.
105+
Violating these terms may lead to a permanent ban.
106+
107+
### 4. Permanent Ban
108+
109+
**Community Impact**: Demonstrating a pattern of violation of community
110+
standards, including sustained inappropriate behavior, harassment of an
111+
individual, or aggression toward or disparagement of classes of individuals.
112+
113+
**Consequence**: A permanent ban from any sort of public interaction within the
114+
community.
115+
116+
## Attribution
117+
118+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119+
version 2.1, available at
120+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
121+
122+
Community Impact Guidelines were inspired by
123+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
124+
125+
For answers to common questions about this code of conduct, see the FAQ at
126+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
127+
[https://www.contributor-covenant.org/translations][translations].
128+
129+
[homepage]: https://www.contributor-covenant.org
130+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
131+
[Mozilla CoC]: https://github.com/mozilla/diversity
132+
[FAQ]: https://www.contributor-covenant.org/faq
133+
[translations]: https://www.contributor-covenant.org/translations

0 commit comments

Comments
 (0)