Skip to content

Latest commit

 

History

History
151 lines (98 loc) · 4.15 KB

CONTRIBUTING.md

File metadata and controls

151 lines (98 loc) · 4.15 KB

How to contribute to k6registry

Thank you for your interest in contributing to k6registry!

Before you begin, make sure to familiarize yourself with the Code of Conduct. If you've previously contributed to other open source project, you may recognize it as the classic Contributor Covenant.

Prerequisites

If you have a golang development environment installed, a go generate command must be issued after modifying the source files.

The other option is to install the cdo tool and perform the tasks described here. The cdo tool can most conveniently be installed using the eget tool.

eget szkiba/cdo

The cdo tool can then be used to perform the tasks described in the following sections.

Help about tasks:

cdo

tools - Install the required tools

Contributing will require the use of some tools, which can be installed most easily with a well-configured eget tool.

eget mikefarah/yq
eget atombender/go-jsonschema
eget szkiba/mdcode
eget golangci/golangci-lint
eget goreleaser/goreleaser

schema - Contribute to the JSON schema

The JSON schema of the registry can be found in the registry.schema.yaml file, after modification of which the schema in JSON format (registry.schema.json) and the golang data model (registry_gen.go) must be regenerated.

yq -o=json -P docs/registry.schema.yaml > docs/registry.schema.json
go-jsonschema -p k6registry --only-models -o registry_gen.go docs/registry.schema.yaml

example - Contribute to the example

The example registry can be found in example.yaml file, the documentation (registry.md, README.md) must be updated after modification.

mdcode update docs/registry.md
mdcode update README.md

readme - Update README.md

After changing the CLI tool or example registry, the documentation must be updated in README.md.

go run ./tools/gendoc README.md
mdcode update README.md

lint - Run the linter

The golangci-lint tool is used for static analysis of the source code. It is advisable to run it before committing the changes.

golangci-lint run

test - Run the tests

go test -count 1 -race -coverprofile=coverage.txt ./...

coverage - View the test coverage report

Requires : test

go tool cover -html=coverage.txt

build - Build the executable binary

This is the easiest way to create an executable binary (although the release process uses the goreleaser tool to create release versions).

go build -ldflags="-w -s" -o k6registry ./cmd/k6registry

snapshot - Creating an executable binary with a snapshot version

The goreleaser command-line tool is used during the release process. During development, it is advisable to create binaries with the same tool from time to time.

rm -f k6registry
goreleaser build --snapshot --clean --single-target -o k6registry

docker - Build docker image

Building a Docker image. Before building the image, it is advisable to perform a snapshot build using goreleaser. To build the image, it is advisable to use the same Docker.goreleaser file that goreleaser uses during release.

Requires : snapshot

docker build -t k6registry -f Dockerfile.goreleaser .

clean - Delete the build directory

rm -rf build

all - Update everything

The most robust thing is to update everything (both the schema and the example) after modifying the source.

Requires : schema, example, readme

legacy - Convert legacy registry

 go run ./cmd/k6registry . --legacy | yq '.[]|= pick(["module","description","official","cloud","imports","outputs","repo"])|sort_by(.module)' > ./docs/legacy.yaml