Skip to content

Commit 110e02e

Browse files
committed
Adds contributing guide
1 parent e868565 commit 110e02e

File tree

2 files changed

+94
-3
lines changed

2 files changed

+94
-3
lines changed

docs/internal/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/internal/contributing/README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Contributing
2+
3+
Welcome! We're excited that you're interested in contributing. Below are some basic guidelines.
4+
5+
## Workflow
6+
7+
Grafana Phlare follows a standard GitHub pull request workflow. If you're unfamiliar with this workflow, read the very helpful [Understanding the GitHub flow](https://guides.github.com/introduction/flow/) guide from GitHub.
8+
9+
You are welcome to create draft PRs at any stage of readiness - this
10+
can be helpful to ask for assistance or to develop an idea. But before
11+
a piece of work is finished it should:
12+
13+
- Be organised into one or more commits, each of which has a commit message that describes all changes made in that commit ('why' more than 'what' - we can read the diffs to see the code that changed).
14+
- Each commit should build towards the whole - don't leave in back-tracks and mistakes that you later corrected.
15+
- Have unit for new functionality or tests that would have caught the bug being fixed.
16+
- If you have made any changes to flags, configs and/or protobuf definitions, run `make generate` and commit the changed files.
17+
18+
## Requirement
19+
20+
To be able to run make targets you'll need to install:
21+
22+
- [Go](https://go.dev/doc/install) (> 1.18)
23+
- [Docker](https://docs.docker.com/engine/install/)
24+
25+
All other required tools will be automatically downloaded `$(pwd)/.tmp/bin`.
26+
27+
> If you need a new CLI, we recommend you follow the same pattern and downloads requirement from the makefile.
28+
29+
## Formatting
30+
31+
Grafana Phlare uses [`golang-ci-lint`](https://github.com/golangci/golangci-lint) tool to format the Go files, and sort imports.
32+
We use goimports with `-local github.com/grafana/phlare` parameter, to put Grafana Mimir internal imports into a separate group. We try to keep imports sorted into three groups: imports from standard library, imports of 3rd party packages and internal Grafana Phlare imports. Goimports will fix the order, but will keep existing newlines between imports in the groups. We try to avoid extra newlines like that.
33+
34+
Use `make lint` to ensure formatting is correct.
35+
36+
## Building Grafana Phlare
37+
38+
To build:
39+
40+
```
41+
make go/bin
42+
```
43+
44+
To run the unit tests suite:
45+
46+
```
47+
make go/test
48+
```
49+
50+
To build the docker image uses:
51+
52+
```
53+
make docker-image/phlare/build
54+
```
55+
56+
This target uses the `go/bin` target to first build binaries to include in the image.
57+
make sure to pass the correct `GOOS` and `GOARCH` env variables.
58+
59+
For example for `linux/amd64`:
60+
61+
```
62+
GOOS=linux GOARCH=amd64 make docker-image/phlare/build
63+
```
64+
65+
### Dependency management
66+
67+
We uses [Go modules](https://golang.org/cmd/go/#hdr-Modules__module_versions__and_more) to manage dependencies on external packages.
68+
However we don't commit the `vendor/` folder.
69+
70+
To add or update a new dependency, use the `go get` command:
71+
72+
```bash
73+
# Pick the latest tagged release.
74+
go get example.com/some/module/pkg
75+
76+
# Pick a specific version.
77+
go get example.com/some/module/[email protected]
78+
```
79+
80+
Tidy up the `go.mod` and `go.sum` files:
81+
82+
```bash
83+
make go/mod
84+
```
85+
86+
You have to commit the changes to `go.mod` and `go.sum` before submitting the pull request.
87+
88+
## Documentation
89+
90+
The Grafana Phlare documentation is compiled into a website published at [grafana.com](https://grafana.com/).
91+
92+
To start the website locally you can use `make docs/docs` and follow console instructions to access the website.
93+
94+
Note: if you attempt to view pages on Github, it's likely that you might find broken links or pages. That is expected and should not be addressed unless it is causing issues with the site that occur as part of the build.

0 commit comments

Comments
 (0)