Skip to content

Commit 07541b9

Browse files
author
Siddhartha Bagaria
committed
Setup Trunk as a meta-linter for the repo
Configures buildifier to run with a config obtained from removing docstring and 'sorted items in dict' warnings from the example config. ``` .trunk/tools/buildifier -config=example ```
1 parent 0f21054 commit 07541b9

File tree

8 files changed

+189
-0
lines changed

8 files changed

+189
-0
lines changed

.buildifier.json

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"type": "auto",
3+
"mode": "fix",
4+
"lint": "fix",
5+
"warningsList": [
6+
"attr-applicable_licenses",
7+
"attr-cfg",
8+
"attr-license",
9+
"attr-licenses",
10+
"attr-non-empty",
11+
"attr-output-default",
12+
"attr-single-file",
13+
"build-args-kwargs",
14+
"bzl-visibility",
15+
"confusing-name",
16+
"constant-glob",
17+
"ctx-actions",
18+
"ctx-args",
19+
"deprecated-function",
20+
"depset-items",
21+
"depset-iteration",
22+
"depset-union",
23+
"dict-concatenation",
24+
"dict-method-named-arg",
25+
"duplicated-name",
26+
"filetype",
27+
"git-repository",
28+
"http-archive",
29+
"integer-division",
30+
"keyword-positional-params",
31+
"list-append",
32+
"load",
33+
"load-on-top",
34+
"name-conventions",
35+
"native-android",
36+
"native-build",
37+
"native-cc",
38+
"native-java",
39+
"native-package",
40+
"native-proto",
41+
"native-py",
42+
"no-effect",
43+
"out-of-order-load",
44+
"output-group",
45+
"overly-nested-depset",
46+
"package-name",
47+
"package-on-top",
48+
"positional-args",
49+
"print",
50+
"provider-params",
51+
"redefined-variable",
52+
"repository-name",
53+
"return-value",
54+
"rule-impl-return",
55+
"same-origin-load",
56+
"skylark-comment",
57+
"skylark-docstring",
58+
"string-iteration",
59+
"uninitialized",
60+
"unnamed-macro",
61+
"unreachable",
62+
"unused-variable"
63+
]
64+
}

.github/workflows/lint.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Pull Request
2+
on: [pull_request]
3+
concurrency:
4+
group: ${{ github.head_ref || github.run_id }}
5+
cancel-in-progress: true
6+
7+
# NOTE: This current setup does not post annotations to PRs.
8+
# https://github.com/marketplace/actions/trunk-check#getting-inline-annotations-for-fork-prs
9+
10+
permissions: read-all
11+
12+
jobs:
13+
trunk_check:
14+
name: Trunk Check Runner
15+
runs-on: ubuntu-latest
16+
permissions:
17+
checks: write # For trunk to post annotations
18+
contents: read # For repo checkout
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v3
23+
24+
- name: Trunk Check
25+
uses: trunk-io/trunk-action@v1

.trunk/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*out
2+
*logs
3+
*actions
4+
*notifications
5+
*tools
6+
plugins
7+
user_trunk.yaml
8+
user.yaml

.trunk/configs/.markdownlint.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Autoformatter friendly markdownlint config (all formatting rules disabled)
2+
default: true
3+
blank_lines: false
4+
bullet: false
5+
html: false
6+
indentation: false
7+
line_length: false
8+
spaces: false
9+
url: false
10+
whitespace: false

.trunk/configs/.shellcheckrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
enable=all
2+
source-path=SCRIPTDIR
3+
disable=SC2154
4+
5+
# If you're having issues with shellcheck following source, disable the errors via:
6+
# disable=SC1090
7+
# disable=SC1091

.trunk/configs/.yamllint.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
rules:
2+
quoted-strings:
3+
required: only-when-needed
4+
extra-allowed: ["{|}"]
5+
empty-values:
6+
forbid-in-block-mappings: true
7+
forbid-in-flow-mappings: true
8+
key-duplicates: {}
9+
octal-values:
10+
forbid-implicit-octal: true

.trunk/trunk.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
version: 0.1
2+
cli:
3+
version: 1.15.0
4+
plugins:
5+
sources:
6+
- id: trunk
7+
ref: v1.2.3
8+
uri: https://github.com/trunk-io/plugins
9+
runtimes:
10+
enabled:
11+
12+
13+
14+
lint:
15+
definitions:
16+
- name: buildifier
17+
files: [starlark, bazel-build, bazel-workspace]
18+
tools: [buildifier]
19+
commands:
20+
- name: fix
21+
run: buildifier --lint=fix "${target}"
22+
output: rewrite
23+
cache_results: true
24+
formatter: true
25+
in_place: true
26+
batch: true
27+
success_codes: [0]
28+
- name: warn
29+
run: buildifier --lint=warn --format=json --mode=check "${target}"
30+
# Custom parser type defined in the trunk cli to handle buildifier's JSON output.
31+
output: buildifier
32+
cache_results: true
33+
batch: true
34+
success_codes: [0]
35+
suggest_if: files_present
36+
direct_configs:
37+
- .buildifier.json
38+
# Not a native buildifier construct, but useful for 'addTables', see test file
39+
- .buildifier-tables.json
40+
environment:
41+
- name: PATH
42+
list: ["${linter}"]
43+
known_good_version: 6.1.0
44+
version_command:
45+
parse_regex: ${semver}
46+
run: buildifier --version
47+
enabled:
48+
49+
50+
51+
- git-diff-check
52+
53+
54+
55+
56+
57+
58+
59+
actions:
60+
enabled:
61+
- trunk-announce
62+
- trunk-check-pre-push
63+
- trunk-fmt-pre-commit
64+
- trunk-upgrade-available

tests/.buildifier.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.buildifier.json

0 commit comments

Comments
 (0)