Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -16,3 +17,38 @@ 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: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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this equivalent to running ./gradlew spotlessApply?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but only for changed files - spotless has a feature that looks for changed files as well - but it still needs to load the gradle config, so it's not really fast

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and it's not doing everything that spotless does - it's a fast subset

exit $failed
"""

[tasks.lint]
description = "Run all lints"
depends = ["lint:links", "lint:markdown", "lint:java"]

[tasks."lint:fix"]
description = "Auto-fix lint issues"
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"
depends = ["lint"]
[tasks."setup:pre-commit-hook"]
description = "Install git pre-commit hook"
run = "mise generate git-pre-commit --write --task=pre-commit"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm curious if anyone uses the pre-commit hook? I would find it annoying b/c spotless is so slow on our repo

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's why it's a fast subset - see above

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what I mean is that it doesn't use gradle at all

Loading