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 ```
This commit is contained in:
parent
0f21054378
commit
07541b9bde
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
"type": "auto",
|
||||
"mode": "fix",
|
||||
"lint": "fix",
|
||||
"warningsList": [
|
||||
"attr-applicable_licenses",
|
||||
"attr-cfg",
|
||||
"attr-license",
|
||||
"attr-licenses",
|
||||
"attr-non-empty",
|
||||
"attr-output-default",
|
||||
"attr-single-file",
|
||||
"build-args-kwargs",
|
||||
"bzl-visibility",
|
||||
"confusing-name",
|
||||
"constant-glob",
|
||||
"ctx-actions",
|
||||
"ctx-args",
|
||||
"deprecated-function",
|
||||
"depset-items",
|
||||
"depset-iteration",
|
||||
"depset-union",
|
||||
"dict-concatenation",
|
||||
"dict-method-named-arg",
|
||||
"duplicated-name",
|
||||
"filetype",
|
||||
"git-repository",
|
||||
"http-archive",
|
||||
"integer-division",
|
||||
"keyword-positional-params",
|
||||
"list-append",
|
||||
"load",
|
||||
"load-on-top",
|
||||
"name-conventions",
|
||||
"native-android",
|
||||
"native-build",
|
||||
"native-cc",
|
||||
"native-java",
|
||||
"native-package",
|
||||
"native-proto",
|
||||
"native-py",
|
||||
"no-effect",
|
||||
"out-of-order-load",
|
||||
"output-group",
|
||||
"overly-nested-depset",
|
||||
"package-name",
|
||||
"package-on-top",
|
||||
"positional-args",
|
||||
"print",
|
||||
"provider-params",
|
||||
"redefined-variable",
|
||||
"repository-name",
|
||||
"return-value",
|
||||
"rule-impl-return",
|
||||
"same-origin-load",
|
||||
"skylark-comment",
|
||||
"skylark-docstring",
|
||||
"string-iteration",
|
||||
"uninitialized",
|
||||
"unnamed-macro",
|
||||
"unreachable",
|
||||
"unused-variable"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
name: Pull Request
|
||||
on: [pull_request]
|
||||
concurrency:
|
||||
group: ${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
# NOTE: This current setup does not post annotations to PRs.
|
||||
# https://github.com/marketplace/actions/trunk-check#getting-inline-annotations-for-fork-prs
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
trunk_check:
|
||||
name: Trunk Check Runner
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
checks: write # For trunk to post annotations
|
||||
contents: read # For repo checkout
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Trunk Check
|
||||
uses: trunk-io/trunk-action@v1
|
|
@ -0,0 +1,8 @@
|
|||
*out
|
||||
*logs
|
||||
*actions
|
||||
*notifications
|
||||
*tools
|
||||
plugins
|
||||
user_trunk.yaml
|
||||
user.yaml
|
|
@ -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
|
|
@ -0,0 +1,7 @@
|
|||
enable=all
|
||||
source-path=SCRIPTDIR
|
||||
disable=SC2154
|
||||
|
||||
# If you're having issues with shellcheck following source, disable the errors via:
|
||||
# disable=SC1090
|
||||
# disable=SC1091
|
|
@ -0,0 +1,10 @@
|
|||
rules:
|
||||
quoted-strings:
|
||||
required: only-when-needed
|
||||
extra-allowed: ["{|}"]
|
||||
empty-values:
|
||||
forbid-in-block-mappings: true
|
||||
forbid-in-flow-mappings: true
|
||||
key-duplicates: {}
|
||||
octal-values:
|
||||
forbid-implicit-octal: true
|
|
@ -0,0 +1,64 @@
|
|||
version: 0.1
|
||||
cli:
|
||||
version: 1.15.0
|
||||
plugins:
|
||||
sources:
|
||||
- id: trunk
|
||||
ref: v1.2.3
|
||||
uri: https://github.com/trunk-io/plugins
|
||||
runtimes:
|
||||
enabled:
|
||||
- go@1.21.0
|
||||
- node@18.12.1
|
||||
- python@3.10.8
|
||||
lint:
|
||||
definitions:
|
||||
- name: buildifier
|
||||
files: [starlark, bazel-build, bazel-workspace]
|
||||
tools: [buildifier]
|
||||
commands:
|
||||
- name: fix
|
||||
run: buildifier --lint=fix "${target}"
|
||||
output: rewrite
|
||||
cache_results: true
|
||||
formatter: true
|
||||
in_place: true
|
||||
batch: true
|
||||
success_codes: [0]
|
||||
- name: warn
|
||||
run: buildifier --lint=warn --format=json --mode=check "${target}"
|
||||
# Custom parser type defined in the trunk cli to handle buildifier's JSON output.
|
||||
output: buildifier
|
||||
cache_results: true
|
||||
batch: true
|
||||
success_codes: [0]
|
||||
suggest_if: files_present
|
||||
direct_configs:
|
||||
- .buildifier.json
|
||||
# Not a native buildifier construct, but useful for 'addTables', see test file
|
||||
- .buildifier-tables.json
|
||||
environment:
|
||||
- name: PATH
|
||||
list: ["${linter}"]
|
||||
known_good_version: 6.1.0
|
||||
version_command:
|
||||
parse_regex: ${semver}
|
||||
run: buildifier --version
|
||||
enabled:
|
||||
- actionlint@1.6.25
|
||||
- buildifier@6.3.3
|
||||
- checkov@2.4.9
|
||||
- git-diff-check
|
||||
- markdownlint@0.36.0
|
||||
- prettier@3.0.3
|
||||
- shellcheck@0.9.0
|
||||
- shfmt@3.6.0
|
||||
- trivy@0.45.0
|
||||
- trufflehog@3.55.1
|
||||
- yamllint@1.32.0
|
||||
actions:
|
||||
enabled:
|
||||
- trunk-announce
|
||||
- trunk-check-pre-push
|
||||
- trunk-fmt-pre-commit
|
||||
- trunk-upgrade-available
|
|
@ -0,0 +1 @@
|
|||
../.buildifier.json
|
Loading…
Reference in New Issue