mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
ci: refactor CI to use mise for shared tool setup (#25727)
This commit is contained in:
@@ -728,11 +728,11 @@ endif
|
||||
# GitHub Actions linters are run in a separate CI job (lint-actions) that only
|
||||
# triggers when workflow files change, so we skip them here when CI=true.
|
||||
LINT_ACTIONS_TARGETS := $(if $(CI),,lint/actions/actionlint)
|
||||
lint: lint/shellcheck lint/go lint/ts lint/examples lint/helm lint/site-icons lint/markdown lint/check-scopes lint/migrations lint/bootstrap lint/architecture lint/emdash lint/agents $(LINT_ACTIONS_TARGETS)
|
||||
lint: lint/shellcheck lint/go lint/ts lint/examples lint/helm lint/site-icons lint/markdown lint/check-scopes lint/migrations lint/bootstrap lint/architecture lint/emdash lint/agents lint/mise-versions $(LINT_ACTIONS_TARGETS)
|
||||
.PHONY: lint
|
||||
|
||||
# Subset of lint that does not require Go or Node toolchains.
|
||||
lint-light: lint/shellcheck lint/markdown lint/helm lint/bootstrap lint/migrations lint/actions/actionlint lint/typos lint/emdash
|
||||
# Fast lint subset for lightweight hooks. Some targets use mise-managed tools.
|
||||
lint-light: lint/shellcheck lint/markdown lint/helm lint/bootstrap lint/migrations lint/actions/actionlint lint/typos lint/emdash lint/mise-versions
|
||||
.PHONY: lint-light
|
||||
|
||||
lint/site-icons:
|
||||
@@ -745,9 +745,8 @@ lint/ts: site/node_modules/.installed
|
||||
.PHONY: lint/ts
|
||||
|
||||
lint/go:
|
||||
linter_ver=$$(grep -Eo '^golangci-lint = "[^"]+"' mise.toml | sed -E 's/.*"([^"]+)"/\1/')
|
||||
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v$$linter_ver run
|
||||
go tool github.com/coder/paralleltestctx/cmd/paralleltestctx -custom-funcs="testutil.Context,chatdTestContext" ./...
|
||||
golangci-lint run
|
||||
paralleltestctx -custom-funcs="testutil.Context,chatdTestContext" ./...
|
||||
go run ./scripts/intxcheck ./...
|
||||
.PHONY: lint/go
|
||||
|
||||
@@ -790,16 +789,27 @@ lint/actions: lint/actions/actionlint lint/actions/zizmor
|
||||
.PHONY: lint/actions
|
||||
|
||||
lint/actions/actionlint:
|
||||
go tool github.com/rhysd/actionlint/cmd/actionlint
|
||||
mise exec actionlint -- actionlint
|
||||
.PHONY: lint/actions/actionlint
|
||||
|
||||
# zizmor uses GH_TOKEN to fetch imported workflows from GitHub; without it,
|
||||
# external action references are skipped silently.
|
||||
lint/actions/zizmor:
|
||||
./scripts/zizmor.sh \
|
||||
@set -euo pipefail; \
|
||||
if [ -z "$${GH_TOKEN:-}" ] && command -v gh >/dev/null 2>&1; then \
|
||||
GH_TOKEN="$$(gh auth token 2>/dev/null || true)"; \
|
||||
export GH_TOKEN; \
|
||||
fi; \
|
||||
mise exec zizmor -- zizmor \
|
||||
--strict-collection \
|
||||
--persona=regular \
|
||||
.
|
||||
.PHONY: lint/actions/zizmor
|
||||
|
||||
lint/mise-versions:
|
||||
./scripts/check_mise_versions.sh
|
||||
.PHONY: lint/mise-versions
|
||||
|
||||
# Verify api_key_scope enum contains all RBAC <resource>:<action> values.
|
||||
lint/check-scopes: coderd/database/dump.sql | _gen/bin/check-scopes
|
||||
_gen/bin/check-scopes
|
||||
@@ -811,28 +821,8 @@ lint/migrations:
|
||||
./scripts/check_pg_schema.sh "Fixtures" $(FIXTURE_FILES)
|
||||
.PHONY: lint/migrations
|
||||
|
||||
TYPOS_VERSION := $(shell grep -oP 'crate-ci/typos@\S+\s+\#\s+v\K[0-9.]+' .github/workflows/ci.yaml)
|
||||
|
||||
# Map uname values to typos release asset names.
|
||||
TYPOS_ARCH := $(shell uname -m)
|
||||
# typos release assets use aarch64, but macOS ARM reports arm64 via uname -m.
|
||||
ifeq ($(TYPOS_ARCH),arm64)
|
||||
TYPOS_ARCH := aarch64
|
||||
endif
|
||||
ifeq ($(shell uname -s),Darwin)
|
||||
TYPOS_OS := apple-darwin
|
||||
else
|
||||
TYPOS_OS := unknown-linux-musl
|
||||
endif
|
||||
|
||||
build/typos-$(TYPOS_VERSION):
|
||||
mkdir -p build/
|
||||
curl -sSfL "https://github.com/crate-ci/typos/releases/download/v$(TYPOS_VERSION)/typos-v$(TYPOS_VERSION)-$(TYPOS_ARCH)-$(TYPOS_OS).tar.gz" \
|
||||
| tar -xzf - -C build/ ./typos
|
||||
mv build/typos "$@"
|
||||
|
||||
lint/typos: build/typos-$(TYPOS_VERSION)
|
||||
build/typos-$(TYPOS_VERSION) --config .github/workflows/typos.toml
|
||||
lint/typos:
|
||||
typos --config .github/workflows/typos.toml
|
||||
.PHONY: lint/typos
|
||||
|
||||
# pre-commit and pre-push mirror CI checks locally.
|
||||
|
||||
Reference in New Issue
Block a user