diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9d76c79 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +root = true + +[*.md] +max_line_length = 120 diff --git a/.github/config/flint.toml b/.github/config/flint.toml new file mode 100644 index 0000000..e33a26b --- /dev/null +++ b/.github/config/flint.toml @@ -0,0 +1,9 @@ +[settings] +exclude = [ + "CHANGELOG.md", + "yaml/testdata/**", + "yaml/docker-compose-docker-lgtm-template.yml", +] + +[checks.renovate-deps] +exclude_managers = ["github-actions", "github-runners"] diff --git a/.github/config/super-linter.env b/.github/config/super-linter.env deleted file mode 100644 index ac2c59a..0000000 --- a/.github/config/super-linter.env +++ /dev/null @@ -1,32 +0,0 @@ -# testdata/ and docker-compose-docker-lgtm-template.yml contain Go template syntax (e.g. {{ .Port }}) — not valid YAML -FILTER_REGEX_EXCLUDE=renovate-tracked-deps.json|testdata/|docker-compose-docker-lgtm-template\.yml -IGNORE_GITIGNORED_FILES=true -LOG_LEVEL=ERROR - -# Keys MUST be sorted alphabetically — dotenv-linter enforces this in CI. - -# --- Allow-list: only these linters run --- -# (switching from deny-list to allow-list for clarity and performance) -# Note: Go linting is handled by lint:go task (mise-pinned golangci-lint) - -VALIDATE_BASH=true -VALIDATE_EDITORCONFIG=true -VALIDATE_ENV=true -VALIDATE_GITHUB_ACTIONS=true -VALIDATE_GIT_MERGE_CONFLICT_MARKERS=true -VALIDATE_JSON_PRETTIER=true -VALIDATE_MARKDOWN=true -VALIDATE_MARKDOWN_PRETTIER=true -VALIDATE_RENOVATE=true -VALIDATE_SHELL_SHFMT=true -VALIDATE_SPELL_CODESPELL=true -VALIDATE_YAML_PRETTIER=true - -# --- Autofix --- -FIX_ENV=true -FIX_JSON_PRETTIER=true -FIX_MARKDOWN=true -FIX_MARKDOWN_PRETTIER=true -FIX_SHELL_SHFMT=true -FIX_SPELL_CODESPELL=true -FIX_YAML_PRETTIER=true diff --git a/.github/renovate-tracked-deps.json b/.github/renovate-tracked-deps.json index 5c0450f..5a55ad4 100644 --- a/.github/renovate-tracked-deps.json +++ b/.github/renovate-tracked-deps.json @@ -67,15 +67,21 @@ }, "mise.toml": { "mise": [ + "actionlint", + "editorconfig-checker", + "github:grafana/flint", "go", "golangci-lint", + "hadolint", "lychee", "node", - "npm:renovate" - ], - "regex": [ - "ghcr.io/super-linter/super-linter", - "grafana/flint" + "npm:@biomejs/biome", + "npm:markdownlint-cli2", + "npm:prettier", + "npm:renovate", + "pipx:codespell", + "shellcheck", + "shfmt" ] }, "yaml/testdata/docker-compose-addition.yaml": { diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 483d718..82ba8f8 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -3,7 +3,7 @@ extends: [ "config:best-practices", "config:recommended", - "github>grafana/flint", + "github>grafana/flint#v0.20.3", ], automerge: true, } diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8fc47a1..7ac57a1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,12 +1,12 @@ --- -name: Build, Lint, and Test +name: Build and Test on: [pull_request] permissions: {} jobs: - test: + build: runs-on: ubuntu-24.04 steps: - name: Check out @@ -17,5 +17,7 @@ jobs: with: version: v2026.4.15 sha256: c55befc52e5694f388b927ef304362ca7b9e919d97d43c342fca57f2eccea255 + - name: Build + run: mise run build - name: Run tests - run: mise run check + run: mise run test diff --git a/.markdownlint.yml b/.markdownlint.yml new file mode 100644 index 0000000..0ba7306 --- /dev/null +++ b/.markdownlint.yml @@ -0,0 +1,2 @@ +# Line length is enforced by editorconfig-checker via .editorconfig +MD013: false diff --git a/AGENTS.md b/AGENTS.md index 2cf22da..ceb1735 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -27,28 +27,25 @@ mise run integration-test # Run end-to-end tests mise run e2e-test - -# Run all checks (lint + test + format check) -mise run check ``` ## Linting ```bash -# Auto-fix and verify (recommended dev workflow) -mise run fix +# Auto-fix lint issues (recommended dev workflow) +mise run lint:fix # Verify only (same command used in CI) mise run lint -# Go linting only -mise run lint:go - -# Format Go code -mise run fmt +# Run all checks +mise run check ``` -Lint tasks are sourced from [grafana/flint](https://github.com/grafana/flint). +Linting is handled by [flint v2](https://github.com/grafana/flint). +Flint runs shellcheck, shfmt, actionlint, hadolint, markdownlint, prettier, +codespell, editorconfig, lychee, renovate-deps, and gofmt. EditorConfig rules +live in `.editorconfig`. ## Architecture @@ -103,6 +100,6 @@ Key flags: `-timeout` (default 30s), `-lgtm-version` (default "latest"), `-manua ## CI -- Build + lint + test on PRs (`mise run check`) +- Lint on PRs (`mise run lint`), build on PRs (`mise run build`), tests on PRs (`mise run test`) - Integration tests and e2e tests in separate workflows -- Linting via flint (super-linter, lychee, golangci-lint) +- Linting via flint v2 diff --git a/biome.jsonc b/biome.jsonc new file mode 100644 index 0000000..19969b0 --- /dev/null +++ b/biome.jsonc @@ -0,0 +1,7 @@ +{ + // Keep JSON formatting aligned with the repo's two-space style. + "formatter": { + "indentStyle": "space", + "indentWidth": 2 + } +} diff --git a/mise.toml b/mise.toml index 0e94c89..4d1c1c8 100644 --- a/mise.toml +++ b/mise.toml @@ -1,44 +1,32 @@ [tools] go = "1.26.2" +node = "24.15.0" + +# Linters +actionlint = "1.7.10" +editorconfig-checker = "v3.6.0" +"github:grafana/flint" = "0.20.3" golangci-lint = "2.11.4" +hadolint = "v2.14.0" lychee = "0.22.0" -node = "24.15.0" +"npm:@biomejs/biome" = "2.4.12" +"npm:markdownlint-cli2" = "0.17.2" +"npm:prettier" = "3.8.1" "npm:renovate" = "43.127.1" +"pipx:codespell" = "2.4.1" +shellcheck = "v0.11.0" +shfmt = "v3.12.0" [env] -RENOVATE_TRACKED_DEPS_EXCLUDE="github-actions,github-runners" -# renovate: datasource=docker depName=ghcr.io/super-linter/super-linter -SUPER_LINTER_VERSION="v8.4.0@sha256:c5e3307932203ff9e1e8acfe7e92e894add6266605b5d7fb525fb371a59a26f4" +FLINT_CONFIG_DIR = ".github/config" -# Shared lint tasks from flint (https://github.com/grafana/flint) -[tasks."lint:super-linter"] -description = "Run Super-Linter on the repository" -file = "https://raw.githubusercontent.com/grafana/flint/5af56d473d2f82ec5af0fad36b054bde2bd2f8cf/tasks/lint/super-linter.sh" # v0.20.1 -[tasks."lint:links"] -description = "Check for broken links in changed files + all local links" -file = "https://raw.githubusercontent.com/grafana/flint/5af56d473d2f82ec5af0fad36b054bde2bd2f8cf/tasks/lint/links.sh" # v0.20.1 -[tasks."lint:renovate-deps"] -description = "Verify renovate-tracked-deps.json is up to date" -file = "https://raw.githubusercontent.com/grafana/flint/5af56d473d2f82ec5af0fad36b054bde2bd2f8cf/tasks/lint/renovate-deps.py" # v0.20.1 - -[tasks."setup:native-lint-tools"] -description = "Install native lint tools matching the pinned super-linter version" -file = "https://raw.githubusercontent.com/grafana/flint/5af56d473d2f82ec5af0fad36b054bde2bd2f8cf/tasks/setup/native-lint-tools.sh" # v0.20.1 -[tasks."lint:fast"] -description = "Run fast lints (no Renovate)" -depends = ["lint:super-linter", "lint:links", "lint:go"] - -[tasks.native-lint] -description = "Run lints natively (no container)" -run = "NATIVE=true mise run lint:fast" +[tasks.lint] +description = "Run all lints" +run = "flint run" -[tasks.pre-commit] -description = "Pre-commit hook: native lint" -depends = ["setup:native-lint-tools"] -run = "NATIVE=true mise run lint:fast" -[tasks."setup:pre-commit-hook"] -description = "Install git pre-commit hook that runs native linting" -run = "mise generate git-pre-commit --write --task=pre-commit" +[tasks."lint:fix"] +description = "Auto-fix lint issues" +run = "flint run --fix" [tasks.test] description = "Run tests" @@ -49,34 +37,14 @@ description = "Run integration tests" env.INTEGRATION_TESTS = "true" run = "go test github.com/grafana/oats/tests" -[tasks.fmt] -description = "Format code" -run = "gofmt -w ." - -[tasks.check-fmt] -description = "Check code formatting" -run = "gofmt -l . | grep . && exit 1 || exit 0" - -[tasks."lint:go"] -description = "Lint Go code" -run = "golangci-lint run" - -[tasks."lint"] -description = "Run all lints" -depends = ["lint:fast", "lint:renovate-deps"] +[tasks.build] +description = "Build the project" +run = "go build" -[tasks.fix] -description = "Auto-fix lint issues and regenerate tracked deps" -run = "AUTOFIX=true mise run lint" +[tasks.check] +description = "Run all checks" +depends = ["lint", "test"] [tasks.deps] description = "Update dependencies" run = "go mod tidy" - -[tasks.check] -description = "Run all checks" -depends = ['lint:go', 'test', 'check-fmt'] - -[tasks.build] -description = "Build the project" -run = "go build"