Skip to content

Commit 16bbc6b

Browse files
committed
Add typos makefile, workflow and configuration, refs #560
- Only ignore dist- folder - Try but reject use typos github action - Write changes for hs-fix-typos - Add alse (parse "f" then "alse") to expected words
1 parent 71dd870 commit 16bbc6b

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

.github/workflows/typos.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Typos
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
pull_request:
8+
push:
9+
10+
env:
11+
TYPOS_VER: v1.29.1
12+
TYPOS_PLATFORM: x86_64-unknown-linux-musl
13+
CLICOLOR: 1
14+
15+
jobs:
16+
typos:
17+
defaults:
18+
run:
19+
shell: bash
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
24+
- uses: actions/checkout@v4
25+
26+
- run: |
27+
wget -q https://github.com/crate-ci/typos/releases/download/${{ env.TYPOS_VER }}/typos-${{ env.TYPOS_VER }}-${{ env.TYPOS_PLATFORM }}.tar.gz
28+
tar -xf typos-${{ env.TYPOS_VER }}-${{ env.TYPOS_PLATFORM }}.tar.gz --one-top-level=typos-${{ env.TYPOS_VER }}
29+
mkdir -p "$HOME/.local/bin"
30+
mv typos-${{ env.TYPOS_VER }} "$HOME/.local/bin/typos-${{ env.TYPOS_VER }}"
31+
chmod +x "$HOME/.local/bin/typos-${{ env.TYPOS_VER }}/typos"
32+
echo "$HOME/.local/bin/typos-${{ env.TYPOS_VER }}" >> $GITHUB_PATH
33+
34+
- run: make markdown-typos
35+
- run: make hs-typos

.typos.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[type.hs]
2+
extend-glob = []
3+
extend-ignore-identifiers-re = []
4+
extend-ignore-words-re = []
5+
extend-ignore-re = []
6+
7+
[type.hs.extend-identifiers]
8+
sIy = "sIy"
9+
vIy = "vIy"
10+
tre = "tre"
11+
inh = "inh"
12+
TypeLits = "TypeLits"
13+
fof = "fof"
14+
15+
[type.hs.extend-words]
16+
alse = "alse"

Makefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
all: help
2+
3+
PHONY: help
4+
help: ## Show the commented targets.
5+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
6+
sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
7+
8+
PHONY: help-banner
9+
help-banner: ## Show the help banner.
10+
@echo "===================================================================="
11+
@echo "§ all make with no arguments also shows this banner"
12+
@echo "§ help make help will list targets with descriptions"
13+
@echo "===================================================================="
14+
15+
.PHONY: typos-install
16+
typos-install: ## Install typos-cli for typos target using cargo.
17+
cargo install typos-cli
18+
19+
GREP_EXCLUDE := grep -v -E 'dist-'
20+
FIND_NAMED := find . -type f -name
21+
22+
.PHONY: markdown-typos
23+
markdown-typos: ## Find typos in Markdown .md files.
24+
$(FIND_NAMED) '*.md' | $(GREP_EXCLUDE) | xargs typos
25+
26+
.PHONY: markdown-fix-typos
27+
markdown-fix-typos: ## Fix typos in Markdown .md files.
28+
$(FIND_NAMED) '*.md' | $(GREP_EXCLUDE) | xargs typos --write-changes
29+
30+
.PHONY: hs-typos
31+
hs-typos: ## Find typos in Haskell .hs files.
32+
$(FIND_NAMED) '*.hs' | $(GREP_EXCLUDE) | xargs typos
33+
34+
.PHONY: hs-fix-typos
35+
hs-fix-typos: ## Fix typos in Haskell .hs files.
36+
$(FIND_NAMED) '*.hs' | $(GREP_EXCLUDE) | xargs typos --write-changes

0 commit comments

Comments
 (0)