Skip to content

Commit

Permalink
Merge pull request grafana/phlare#407 from dapirian/enable_trunk
Browse files Browse the repository at this point in the history
Enable trunk superlinter
  • Loading branch information
cyriltovena authored Nov 9, 2022
2 parents 7b57257 + 4e70e8d commit 067092a
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
root = true

[*]
indent_style = space
indent_size = 2
7 changes: 7 additions & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*out
*logs
*actions
*notifications
plugins
user_trunk.yaml
user.yaml
3 changes: 3 additions & 0 deletions .trunk/config/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Autoformatter friendly flake8 config (all formatting rules disabled)
[flake8]
extend-ignore = D1, D2, E1, E2, E3, E501, W1, W2, W3, W5
2 changes: 2 additions & 0 deletions .trunk/config/.isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
profile=black
10 changes: 10 additions & 0 deletions .trunk/config/.markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Autoformatter friendly markdownlint config (all formatting rules disabled)
default: true
blank_lines: false
bullet: false
html: false
indentation: false
line_length: false
spaces: false
url: false
whitespace: false
2 changes: 2 additions & 0 deletions .trunk/config/.shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
enable=all
source-path=SCRIPTDIR
1 change: 1 addition & 0 deletions .trunk/config/rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
edition = "2021"
14 changes: 14 additions & 0 deletions .trunk/config/svgo.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
plugins: [
{
name: "preset-default",
params: {
overrides: {
removeViewBox: false, // https://github.com/svg/svgo/issues/1128
sortAttrs: true,
removeOffCanvasPaths: true,
},
},
},
],
};
84 changes: 84 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
version: 0.1
cli:
version: 1.0.1
plugins:
sources:
# The official Trunk.io repo where new linters are integrated
- id: trunk
ref: v0.0.6
uri: https://github.com/trunk-io/plugins
runtimes:
enabled:
- go@1.19.3
- node@16.14.2
- python@3.10.3
lint:
enabled:
- actionlint@1.6.22
- black@22.10.0
- buf-format@1.9.0
- buf-lint@1.9.0
- check-go-mod
- clippy@1.65.0
- flake8@5.0.4
- git-diff-check
- gitleaks@8.15.0
- gofmt@1.19.3
- golangci-lint@1.50.1
- goreleaser-check@1.12.3
- hadolint@2.10.0
- isort@5.10.1
- markdownlint@0.32.2
- prettier@2.7.1
- rustfmt@1.65.0
- shellcheck@0.8.0
- shfmt@3.5.0
- svgo@3.0.0
- taplo@0.7.0
definitions:
- name: check-go-mod
commands:
- name: lint
output: pass_fail
run: bash -c "git --no-pager diff --exit-code --quiet -- go.sum go.mod vendor/ || { echo \"There are unstaged changes in go vendoring, run 'make go/mod'\"; exit 1; }"
success_codes: [0, 1]
cache_results: false
disable_upstream: true
hold_the_line: false
environment:
- name: PATH
list: ["${env.PATH}"]
- name: goreleaser-check
commands:
- name: lint
output: pass_fail
run: goreleaser check -f ${target}
success_codes: [0, 1]
read_output_from: stderr
environment:
- name: PATH
list: ["${env.PATH}"]
runtime: go
package: github.com/goreleaser/goreleaser
version_command:
parse_regex: goreleaser version ${semver} .*
run: goreleaser --version
triggers:
- linters: [check-go-mod]
targets: [go.mod]
paths: [go.mod, go.sum, vendor/**]
- linters: [goreleaser-check]
targets: [.goreleaser.yaml]
paths: [.goreleaser.yaml]
ignore:
- linters: [ALL]
paths: ["**/vendor/**"]
- linters: [prettier]
paths: [operations/phlare/helm/phlare/templates]
actions:
enabled:
- trunk-upgrade-available
# Recommended githooks actions, to turn on later:
# - trunk-announce
# - trunk-check-pre-push
# - trunk-fmt-pre-commit
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ $(BIN)/goreleaser: Makefile go.mod
@mkdir -p $(@D)
GOBIN=$(abspath $(@D)) $(GO) install github.com/goreleaser/goreleaser@v1.11.5

$(BIN)/trunk: Makefile
@mkdir -p $(@D)
curl -L https://trunk.io/releases/trunk -o $(@D)/trunk
chmod +x $(@D)/trunk

KIND_CLUSTER = phlare-dev

.PHONY: helm/lint
Expand All @@ -284,6 +289,14 @@ helm/lint: $(BIN)/helm
goreleaser/lint: $(BIN)/goreleaser
$(BIN)/goreleaser check

.PHONY: trunk/lint
trunk/lint: $(BIN)/trunk
$(BIN)/trunk check

.PHONY: trunk/fmt
trunk/fmt: $(BIN)/trunk
$(BIN)/trunk fmt

.PHONY: helm/check
helm/check: $(BIN)/kubeval $(BIN)/helm
$(BIN)/helm repo add --force-update minio https://charts.min.io/
Expand Down

0 comments on commit 067092a

Please sign in to comment.