Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 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
63 changes: 63 additions & 0 deletions .github/_typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Configuration for typos spell checker
Copy link
Contributor Author

Choose a reason for hiding this comment

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

generated by getting an agent to attempt spell corrections and propose exclusions.

# See: https://github.com/crate-ci/typos

[default]
# Ensure we check binary file names
binary = false

[default.extend-words]
# Add custom dictionary entries here for intentional "misspellings" used in the codebase
# Preemptable is used consistently instead of "Preemptible" for caller types
Preemptable = "Preemptable"
preemptable = "preemptable"
# "ba" is a legitimate variable name in merge tests (shorthand for "b merged with a")
ba = "ba"
# Hash strings may contain letter combinations that look like typos
Ue = "Ue"
# Test data and base64 strings that contain letter combinations that look like typos
nd = "nd"
abd = "abd"
# Environment variable name that must remain for backwards compatibility
AVAILABILTY = "AVAILABILTY"
# Proto-generated field names that have typos in the proto definition
# These should be fixed in the proto file first, then regenerated
Heartbeart = "Heartbeart"
heartbeart = "heartbeart"
Comment on lines +21 to +25
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll double check these


[files]
# Exclude generated protobuf files
extend-exclude = [
"*.pb.go",
"*.pb.gw.go",
"*.proto",
"*.binpb",
# Exclude other generated or third-party files
"*.gen.go",
"*.json.gz",
".bin/**",
".testoutput/**",
"vendor/**",
".stamp/**",
"**/testdata/**",
# Exclude SVG files - they contain hex color codes that trigger false positives (e.g., #f38BA8)
"*.svg",
]

[type.go]
extend-glob = ["*.go"]

# Inline typos ignore comments:
# To ignore a specific line, add a comment on the same line or the line before:
# // typos:disable-next-line
# var myVar = "mispeling" // intentional
#
# To ignore a specific word on a line:
# var myVar = "mispeling" // typos:ignore
#
# To disable checking for an entire file, add at the top:
# // typos:disable-file
#
# To check only changed files (useful for local development):
# git diff --name-only --diff-filter=ACMR main...HEAD | typos --file-list -
# Or check only staged files:
# git diff --cached --name-only | typos --file-list -
11 changes: 11 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ jobs:
exit 1
fi

typos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: check spelling with typos
uses: crate-ci/[email protected]
with:
config: .github/_typos.toml

linters-succeed:
name: All Linters Succeed
needs:
Expand All @@ -141,6 +151,7 @@ jobs:
- lint-actions
- fmt-imports
- golangci
- typos
runs-on: ubuntu-latest
if: always()
env:
Expand Down
26 changes: 25 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ ACTIONLINT := $(LOCALBIN)/actionlint-$(ACTIONLINT_VER)
$(ACTIONLINT): | $(LOCALBIN)
$(call go-install-tool,$(ACTIONLINT),github.com/rhysd/actionlint/cmd/actionlint,$(ACTIONLINT_VER))

TYPOS_VER := v1.28.4
TYPOS := typos

WORKFLOWCHECK_VER := master # TODO: pin this specific version once 0.3.0 follow-up is released
WORKFLOWCHECK := $(LOCALBIN)/workflowcheck-$(WORKFLOWCHECK_VER)
$(WORKFLOWCHECK): | $(LOCALBIN)
Expand Down Expand Up @@ -379,7 +382,28 @@ fmt-imports: $(GCI) # Don't get confused, there is a single linter called gci, w
@printf $(COLOR) "Formatting imports..."
@$(GCI) write --skip-generated -s standard -s default ./*

lint: lint-code lint-actions lint-api lint-protos
lint-typos:
@printf $(COLOR) "Checking spelling with typos..."
@if command -v $(TYPOS) >/dev/null 2>&1; then \
$(TYPOS) --config .github/_typos.toml; \
else \
printf $(RED) "WARNING: typos is not installed. Install it from https://github.com/crate-ci/typos or run: cargo install typos-cli"; \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

opted to warn instead of installing. Open to changing this if there's a good pattern to follow for installation

echo ""; \
echo "Skipping spell check..."; \
fi

# Check spelling only on files changed from main branch
lint-typos-changed:
@printf $(COLOR) "Checking spelling on changed files with typos..."
@if command -v $(TYPOS) >/dev/null 2>&1; then \
git diff --name-only --diff-filter=ACMR $(MAIN_BRANCH)...HEAD | $(TYPOS) --config .github/_typos.toml --file-list -; \
else \
printf $(RED) "WARNING: typos is not installed. Install it from https://github.com/crate-ci/typos or run: cargo install typos-cli"; \
echo ""; \
echo "Skipping spell check..."; \
fi

lint: lint-code lint-actions lint-api lint-protos lint-typos-changed
@printf $(COLOR) "Run linters..."

lint-api: $(API_LINTER) $(API_BINPB)
Expand Down
Loading