Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): Add codespell to Makefile and GitHub Actions #3996

Merged
merged 26 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bf24feb
feat(ci): Add codespell to Makefile and GitHub Actions
CharlieTLe Apr 13, 2023
4d22afe
Merge branch 'main' into feat-codespell-ci
CharlieTLe Apr 13, 2023
3feba7e
Use docker to run python and codespell
CharlieTLe Apr 14, 2023
5c314ce
Remove wording on requirement for python
CharlieTLe Apr 14, 2023
8ef8c39
Merge branch 'main' into feat-codespell-ci
hanyuancheung Apr 17, 2023
e8cb24d
Merge branch 'main' into feat-codespell-ci
CharlieTLe Apr 18, 2023
64c9585
Apply suggestions from code review
CharlieTLe Apr 19, 2023
95879a2
Merge branch 'main' into feat-codespell-ci
CharlieTLe Apr 22, 2023
45acbfd
Merge branch 'main' into feat-codespell-ci
hanyuancheung Apr 24, 2023
bed942c
Pin versions into requirements.txt
CharlieTLe May 1, 2023
45052cb
Merge branch 'main' into feat-codespell-ci
CharlieTLe May 1, 2023
d957379
Pin version in requirements.txt
CharlieTLe May 1, 2023
34a2316
Fix typo in license
CharlieTLe May 1, 2023
165ca6b
Revert typo fix on deleted file
CharlieTLe May 3, 2023
d3db3df
Merge branch 'main' into feat-codespell-ci
CharlieTLe May 3, 2023
b233b04
Merge branch 'main' into feat-codespell-ci
CharlieTLe May 4, 2023
8dfc013
Merge branch 'main' into feat-codespell-ci
CharlieTLe May 9, 2023
21cbb3f
Update .github/workflows/codespell.yaml
CharlieTLe May 9, 2023
42dfcdf
Update codespell.yaml
CharlieTLe May 9, 2023
bf545fc
Update codespell.yaml
CharlieTLe May 9, 2023
664b066
Merge branch 'main' into feat-codespell-ci
CharlieTLe May 10, 2023
c17054e
Merge branch 'main' into feat-codespell-ci
CharlieTLe May 11, 2023
7e96296
Merge branch 'main' into feat-codespell-ci
CharlieTLe May 15, 2023
2b920e4
Merge branch 'main' into feat-codespell-ci
CharlieTLe May 16, 2023
839040a
Merge branch 'main' into feat-codespell-ci
pellared May 18, 2023
73bfe21
Merge branch 'main' into feat-codespell-ci
MrAlias May 18, 2023
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
5 changes: 5 additions & 0 deletions .codespellignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ot
fo
te
MrAlias marked this conversation as resolved.
Show resolved Hide resolved
collison
MrAlias marked this conversation as resolved.
Show resolved Hide resolved
consequentially
10 changes: 10 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# https://github.com/codespell-project/codespell
[codespell]
builtin = clear,rare,informal
check-filenames =
check-hidden =
ignore-words = .codespellignore
interactive = 1
skip = .git,go.mod,go.sum,semconv,venv,.tools
uri-ignore-words-list = *
write =
24 changes: 24 additions & 0 deletions .github/workflows/codespell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: codespell
on:
push:
CharlieTLe marked this conversation as resolved.
Show resolved Hide resolved
branches:
- main
pull_request:
jobs:
codespell:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
CharlieTLe marked this conversation as resolved.
Show resolved Hide resolved
- name: Codespell with annotations
uses: codespell-project/actions-codespell@v1
with:
builtin: clear,rare,informal
CharlieTLe marked this conversation as resolved.
Show resolved Hide resolved
check_filenames: true
check_hidden: true
ignore_words_file: .codespellignore
only_warn: true
skip: "./.git/*,go.mod,go.sum,./semconv/*"
uri_ignore_words_list: "*"
CharlieTLe marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Thumbs.db

.tools/
venv/
.idea/
.vscode/
*.iml
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ linters-settings:
- name: constant-logical-expr
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-as-argument
# TODO (#3372) reenable linter when it is compatible. https://github.com/golangci/golangci-lint/issues/3280
# TODO (#3372) re-enable linter when it is compatible. https://github.com/golangci/golangci-lint/issues/3280
- name: context-as-argument
disabled: true
arguments:
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ precommit` - the `precommit` target is the default).
The `precommit` target also fixes the formatting of the code and
checks the status of the go module files.

Additionally, there is a `codespell` target that checks for common
typos in the code. It is not run by default, but you can run it
manually with `make codespell`. It will set up a virtual environment
in `venv` and install `codespell` there.

If after running `make precommit` the output of `git status` contains
`nothing to commit, working tree clean` then it means that everything
is up-to-date and properly formatted.
Expand Down
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,39 @@ $(TOOLS)/gojq: PACKAGE=github.com/itchyny/gojq/cmd/gojq
.PHONY: tools
tools: $(CROSSLINK) $(DBOTCONF) $(GOLANGCI_LINT) $(MISSPELL) $(GOCOVMERGE) $(STRINGER) $(PORTO) $(GOJQ) $(SEMCONVGEN) $(MULTIMOD) $(SEMCONVKIT)

# Virtualized python tools via docker

# The directory where the virtual environment is created.
VENVDIR := venv

# The directory where the python tools are installed.
PYTOOLS := $(VENVDIR)/bin

# The pip executable in the virtual environment.
PIP := $(PYTOOLS)/pip

# The directory in the docker image where the current directory is mounted.
WORKDIR := /workdir

# The python image to use for the virtual environment.
PYTHONIMAGE := python:3.11.3-slim-bullseye
CharlieTLe marked this conversation as resolved.
Show resolved Hide resolved

# Run the python image with the current directory mounted.
DOCKERPY := docker run --rm -v "$(CURDIR):$(WORKDIR)" -w $(WORKDIR) $(PYTHONIMAGE)

# Create a virtual environment for Python tools.
$(PYTOOLS):
# The `--upgrade` flag is needed to ensure that the virtual environment is
# created with the latest pip version.
@$(DOCKERPY) bash -c "python3 -m venv $(VENVDIR) && $(PIP) install --upgrade pip"

# Install python packages into the virtual environment.
$(PYTOOLS)/%: | $(PYTOOLS)
@$(DOCKERPY) $(PIP) install -r requirements.txt

CODESPELL = $(PYTOOLS)/codespell
$(CODESPELL): PACKAGE=codespell

# Build

.PHONY: generate build
Expand Down Expand Up @@ -176,6 +209,10 @@ vanity-import-fix: | $(PORTO)
misspell: | $(MISSPELL)
@$(MISSPELL) -w $(ALL_DOCS)

.PHONY: codespell
codespell: | $(CODESPELL)
@$(DOCKERPY) $(CODESPELL)

.PHONY: license-check
license-check:
@licRes=$$(for f in $$(find . -type f \( -iname '*.go' -o -iname '*.sh' \) ! -path '**/third_party/*' ! -path './.git/*' ) ; do \
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
codespell==2.2.4