From a8225a5e9f9954cd30c97982c66a7d7008e26595 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Fri, 20 Mar 2026 13:25:03 +0100 Subject: [PATCH 1/3] ci: add lint meta-task, fix, and pre-commit hook Bump flint to v0.9.1. Add lint:spotless wrapping spotlessCheck, a lint meta-task that runs links + markdown + spotless in parallel, a fix task (spotlessApply + markdownlint --fix), and a pre-commit hook via mise generate. Signed-off-by: Gregor Zeitlinger --- mise.toml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mise.toml b/mise.toml index 82dea8939279..92220aeaf1a8 100644 --- a/mise.toml +++ b/mise.toml @@ -16,3 +16,22 @@ use_file_shell_for_executable_tasks = true [tasks."lint:links"] description = "Check for broken links in changed files + all local links" file = "https://raw.githubusercontent.com/grafana/flint/8a39d96e17327c54974623b252eb5260d67ed68a/tasks/lint/links.sh" # v0.9.1 + +[tasks."lint:spotless"] +description = "Check Java formatting with Spotless" +run = "./gradlew spotlessCheck" + +[tasks.lint] +description = "Run all lints" +depends = ["lint:links", "lint:markdown", "lint:spotless"] + +[tasks.fix] +description = "Auto-fix lint issues" +run = ["./gradlew spotlessApply", "mise run lint:markdown -- --fix"] + +[tasks.pre-commit] +description = "Pre-commit hook: lint changed files" +depends = ["lint"] +[tasks."setup:pre-commit-hook"] +description = "Install git pre-commit hook" +run = "mise generate git-pre-commit --write --task=pre-commit" From 23d74db656b4aff695f224b84f65273da1548440 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Fri, 20 Mar 2026 15:40:46 +0000 Subject: [PATCH 2/3] use google-java-format native binary instead of Gradle spotless for local lint Replaces the slow Gradle-based spotlessCheck/spotlessApply (~5min) with google-java-format native binary (~42ms) for changed files only. CI still runs the full spotlessCheck via Gradle. --- mise.toml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/mise.toml b/mise.toml index 92220aeaf1a8..caaa38b78819 100644 --- a/mise.toml +++ b/mise.toml @@ -1,6 +1,7 @@ [tools] lychee = "0.23.0" markdownlint-cli2 = "0.22.0" +"ubi:google/google-java-format" = "1.34.1" [settings] # Only install tools explicitly defined in the [tools] section above @@ -17,17 +18,33 @@ use_file_shell_for_executable_tasks = true description = "Check for broken links in changed files + all local links" file = "https://raw.githubusercontent.com/grafana/flint/8a39d96e17327c54974623b252eb5260d67ed68a/tasks/lint/links.sh" # v0.9.1 -[tasks."lint:spotless"] -description = "Check Java formatting with Spotless" -run = "./gradlew spotlessCheck" +[tasks."lint:java"] +description = "Check Java formatting and license headers (changed files only)" +run = """ +files=$(git diff --name-only --diff-filter=d origin/main...HEAD -- '*.java') +[ -z "$files" ] && exit 0 +failed=0 +for f in $files; do + if ! head -4 "$f" | grep -q "SPDX-License-Identifier: Apache-2.0"; then + echo "Missing license header: $f" + failed=1 + fi +done +google-java-format --dry-run --set-exit-if-changed $files || failed=1 +exit $failed +""" [tasks.lint] description = "Run all lints" -depends = ["lint:links", "lint:markdown", "lint:spotless"] +depends = ["lint:links", "lint:markdown", "lint:java"] [tasks.fix] description = "Auto-fix lint issues" -run = ["./gradlew spotlessApply", "mise run lint:markdown -- --fix"] +run = """ +files=$(git diff --name-only --diff-filter=d origin/main...HEAD -- '*.java') +[ -n "$files" ] && google-java-format -i $files +mise run lint:markdown -- --fix +""" [tasks.pre-commit] description = "Pre-commit hook: lint changed files" From a46df34a0c3115b9ae4932b192554d277c8b8c35 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Fri, 20 Mar 2026 17:56:33 +0000 Subject: [PATCH 3/3] Rename fix task to lint:fix --- mise.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mise.toml b/mise.toml index caaa38b78819..9b7585b3d499 100644 --- a/mise.toml +++ b/mise.toml @@ -38,7 +38,7 @@ exit $failed description = "Run all lints" depends = ["lint:links", "lint:markdown", "lint:java"] -[tasks.fix] +[tasks."lint:fix"] description = "Auto-fix lint issues" run = """ files=$(git diff --name-only --diff-filter=d origin/main...HEAD -- '*.java')