Skip to content

Commit

Permalink
Merge pull request #39 from grafana/38-refactoring-k6x-based-on-the-n…
Browse files Browse the repository at this point in the history
…ew-libraries

refactoring k6x based on the new libraries
  • Loading branch information
szkiba authored Jul 2, 2024
2 parents de18225 + 5c7351c commit 8b2786f
Show file tree
Hide file tree
Showing 136 changed files with 865 additions and 7,219 deletions.
File renamed without changes.
114 changes: 89 additions & 25 deletions CONTRIBUTING.md → .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Thank you for your interest in contributing to k6x!

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 community forums](https://community.grafana.com/c/grafana-k6/extensions/).
If you want to chat with the team or the community, you can [join our community forums](https://community.grafana.com/c/grafana-k6/).

## Filing issues

Expand All @@ -16,7 +16,7 @@ That said, "how do I..."-type questions are often more suited for community foru

## Contributing code

If you'd like to contribute code to k6x, this is the basic procedure. Make sure to follow the [style guide](#style-guide) described below.
If you'd like to contribute code to k6x, this is the basic procedure. Make sure to follow the [code style](#code-style) 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 **before** you get started on the implementation.

Expand All @@ -28,59 +28,123 @@ If you'd like to contribute code to k6x, this is the basic procedure. Make sure

4. We will discuss implementation details until everyone is happy, then a maintainer will merge it.

### 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.

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:

```bash
golangci-lint run
```

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

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.

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
```

### 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.

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.


### Development setup

To get a basic development environment for Go and k6x 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/szkiba/k6x/blob/master/go.mod) for minimum required version) installed and working properly.

We recommend using the Git command-line interface to download the source code for the k6x:

* Open a terminal and run `git clone https://github.com/szkiba/k6x.git`. This command downloads xk6-dashboard's sources to a new `k6x` directory in your current directory.
* Open a terminal and run `git clone https://github.com/grafana/k6x.git`. This command downloads k6x's sources to a new `k6x` directory in your current directory.
* Open the `k6x` directory in your favorite code editor.

For alternative ways of cloning the k6x 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
### Tasks

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/szkiba/k6x/blob/master/.golangci.yml#L1). To run it locally run:
This section contains a description of the tasks performed during development. Commands must be issued in the `k6x` base directory. If you have the [xc](https://github.com/joerdav/xc) command-line tool, individual tasks can be executed simply by using the `xc task-name` command in the `k6x` base directory.

```bash
go run mage.go lint
#### readme

Update documentation in README.md.

```
go run ./tools/gendoc README.md
```

#### Running the test suite
#### lint

Run the static analyzer.

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/k6x/blob/master/.golangci.yml#L1).

```
golangci-lint run
```

#### test

Run the tests.

To exercise the entire test suite, please run the following command

```bash
go run mage.go test

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

#### Code style
#### coverage

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.
View the test coverage report.

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:
```
go tool cover -html=build/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).

```bash
go run mage.go lint
```
go build -ldflags="-w -s" -o k6x .
```

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).
#### snapshot

#### Commit format
Creating an executable binary with a snapshot version.

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.
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.

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:
```
goreleaser build --snapshot --clean --single-target -o k6x
```

```text
Added this really rad feature
#### docker

Closes #420
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 grafana/k6x -f Dockerfile.goreleaser .
```

#### Language and text formatting
#### clean

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.
Delete the build directory.

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.
```
rm -rf build
```
15 changes: 3 additions & 12 deletions .github/ISSUE_TEMPLATE/bug.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# SPDX-FileCopyrightText: 2023 Iván SZKIBA
#
# SPDX-License-Identifier: AGPL-3.0-only

name: Bug report
description: Use this template for reporting bugs. Please search existing issues first.
labels: [bug]
Expand All @@ -13,15 +9,10 @@ body:
required: true
- type: markdown
attributes:
value: '## Environment'
value: "## Environment"
- type: input
attributes:
label: k6 version
validations:
required: true
- type: input
attributes:
label: xk6-dashboard version
label: k6x version
validations:
required: true
- type: input
Expand All @@ -35,7 +26,7 @@ body:
label: Docker version and image (if applicable)
- type: markdown
attributes:
value: '## Detailed issue description'
value: "## Detailed issue description"
- type: textarea
attributes:
label: Steps to reproduce the problem
Expand Down
9 changes: 0 additions & 9 deletions .github/ISSUE_TEMPLATE/config.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .github/ISSUE_TEMPLATE/enhancement.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# SPDX-FileCopyrightText: 2023 Iván SZKIBA
#
# SPDX-License-Identifier: AGPL-3.0-only

name: Enhancement
description: Use this template for suggesting enhancements to existing features.
labels: [enhancement]
Expand Down
4 changes: 0 additions & 4 deletions .github/ISSUE_TEMPLATE/feature.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# SPDX-FileCopyrightText: 2023 Iván SZKIBA
#
# SPDX-License-Identifier: AGPL-3.0-only

name: Feature Request
description: Use this template for suggesting new features.
labels: [feature]
Expand Down
8 changes: 4 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
## Checklist

<!--
If you haven't read the contributing guidelines https://github.com/szkiba/k6x/blob/master/CONTRIBUTING.md
and code of conduct https://github.com/szkiba/k6x/blob/master/CODE_OF_CONDUCT.md yet, please do so
If you haven't read the contributing guidelines https://github.com/grafana/k6x/blob/master/.github/CONTRIBUTING.md
and code of conduct https://github.com/grafana/k6x/blob/master/.github/CODE_OF_CONDUCT.md yet, please do so
-->

- [ ] I have performed a self-review of my code.
- [ ] I have added tests for my changes.
- [ ] I have run linter locally (`go run mage.go lint`) and all checks pass.
- [ ] I have run tests locally (`go run mage.go test`) and all tests pass.
- [ ] I have run linter locally (`golangci-lint run`) and all checks pass.
- [ ] I have run tests locally (`go test ./...`) and all tests pass.
- [ ] I have commented on my code, particularly in hard-to-understand areas.
<!-- - [ ] Any other relevant item -->

Expand Down
4 changes: 0 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md.license

This file was deleted.

4 changes: 0 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# SPDX-FileCopyrightText: 2023 Iván SZKIBA
#
# SPDX-License-Identifier: AGPL-3.0-only

version: 2
updates:
- package-ecosystem: "github-actions"
Expand Down
19 changes: 6 additions & 13 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# SPDX-FileCopyrightText: 2023 Iván SZKIBA
#
# SPDX-License-Identifier: AGPL-3.0-only

name: lint

on:
pull_request:
workflow_dispatch:
push:
paths-ignore:
- 'docs/**'
- "docs/**"
- README.md
- 'releases/**'
- "releases/**"

permissions:
contents: read
Expand All @@ -22,18 +19,14 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: REUSE linter
uses: fsfe/reuse-action@v3
with:
args: lint
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.22.2"
cache: false
- name: Go linter
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
version: v1.57
args: --timeout=30m
install-mode: binary
49 changes: 0 additions & 49 deletions .github/workflows/marp.yml

This file was deleted.

Loading

0 comments on commit 8b2786f

Please sign in to comment.