Skip to content

Commit a9312c2

Browse files
committed
test: add more linting configuration & documentation
1 parent eec730d commit a9312c2

File tree

7 files changed

+60
-3
lines changed

7 files changed

+60
-3
lines changed

.github/semantic.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
commitsOnly: true
2+
allowMergeCommits: false

.github/workflows/pre-commit.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,16 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/[email protected]
14+
15+
- uses: actions/setup-go@v2
16+
with:
17+
# renovate: go-version
18+
go-version: 1.17.7
19+
20+
- name: Install go tooling
21+
run: |
22+
go get golang.org/x/lint/golint
23+
go get golang.org/x/tools/cmd/goimports
24+
go get github.com/fzipp/gocyclo/cmd/gocyclo
25+
1426
- uses: pre-commit/[email protected]

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ repos:
77
stages: [commit-msg]
88
additional_dependencies: ["@commitlint/config-conventional"]
99

10+
- repo: https://github.com/dnephin/pre-commit-golang
11+
rev: v0.5.0
12+
hooks:
13+
- id: go-fmt
14+
- id: go-vet
15+
- id: go-mod-tidy
16+
- id: go-lint # requires golang.org/x/lint/golint
17+
- id: go-imports # requires golang.org/x/tools/cmd/goimports
18+
- id: go-cyclo # requires github.com/fzipp/gocyclo/cmd/gocyclo
19+
args: [-over=15]
20+
1021
- repo: https://github.com/pre-commit/mirrors-prettier
1122
rev: v2.5.1
1223
hooks:

CONTRIBUTING.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,28 @@
22

33
Contributions are welcome. Please note the [Code of Conduct](CODE_OF_CONDUCT.md) and set up pre-commit as described below.
44

5-
## Repository setup
5+
## Tool & Repository setup
66

7-
Please set up pre-commit after cloning the repository:
7+
CI pipelines check all code changes when you open a PR. To not have to go back and fix all issues manually, the following setup is recommended.
8+
9+
You will need the following tools:
10+
11+
- [go](https://go.dev/). For the specific version used, check the [pre-commit workflow](.github/workflows/pre-commit.yml) at the `go-version` configuration
12+
- [pre-commit](https://pre-commit.com/)
13+
14+
Once this is done, run the following:
815

916
```sh
17+
# Linters used with pre-commit
18+
go install golang.org/x/lint/golint@latest
19+
go install golang.org/x/tools/cmd/goimports@latest
20+
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
21+
22+
# Set up pre-commit hooks
1023
pre-commit install --hook-type commit-msg --hook-type pre-commit
1124
```
25+
26+
## Commit messages
27+
28+
This project uses [Conventional commits](https://www.conventionalcommits.org/en/v1.0.0-beta.4/)
29+
to enable better overview over changes and enables automated tooling based on commit messages.

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/envelope-zero/backend
2+
3+
go 1.17

go.sum

Whitespace-only changes.

renovate.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,16 @@
77
"labels": ["renovate"],
88
"rangeStrategy": "pin",
99
"rebaseWhen": "behind-base-branch",
10-
"semanticCommits": "enabled"
10+
"semanticCommits": "enabled",
11+
"regexManagers": [
12+
{
13+
"description": "Upgrade go version in a GitHub workflow",
14+
"fileMatch": ["(^workflow-templates|\\.github/workflows)/[^/]+\\.ya?ml$"],
15+
"matchStrings": [
16+
"# renovate: go-version\\s*go-version:\\s*\"?(?<currentValue>.*)\"?"
17+
],
18+
"datasourceTemplate": "golang-version",
19+
"depNameTemplate": "go"
20+
}
21+
]
1122
}

0 commit comments

Comments
 (0)