From 99f8b397167c650b902be58eeb9272230362ebef Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sun, 16 Mar 2025 17:44:45 +0000 Subject: [PATCH] lint: Run codespell automatically Signed-off-by: Colin Watson --- .codespell-ignore | 6 ++++++ .devcontainer/Dockerfile | 4 ++++ .github/workflows/tests.yml | 5 ++++- Makefile | 4 ++++ shell.nix | 1 + test/lint/codespell.sh | 2 ++ 6 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 .codespell-ignore create mode 100755 test/lint/codespell.sh diff --git a/.codespell-ignore b/.codespell-ignore new file mode 100644 index 0000000000..d3ea676eff --- /dev/null +++ b/.codespell-ignore @@ -0,0 +1,6 @@ +AtLeast +destOp +ECT +inport +renderD +requestor diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 528d4e4d57..cd324ecc61 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -50,6 +50,7 @@ RUN sed -r -i 's/^Components: main$/Components: main contrib/g' /etc/apt/sources lxc-templates \ make \ man-db \ + pipx \ pkg-config \ protoc-gen-go \ python3-matplotlib \ @@ -69,6 +70,9 @@ RUN sed -r -i 's/^Components: main$/Components: main contrib/g' /etc/apt/sources # zfsutils-linux xz-utils +# With pipx >= 1.5.0, we could use pipx --global instead. +RUN PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install codespell + # Add vscode user and add it to sudoers. RUN groupadd -g 1000 $USERNAME && \ useradd -s /bin/bash -u $USER_UID -g $USER_GID -m $USERNAME && \ diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 912838b102..94a21706b2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -90,10 +90,13 @@ jobs: libtool \ libudev-dev \ make \ + pipx \ pkg-config \ shellcheck - python3 -m pip install flake8 + # With pipx >= 1.5.0, we could use pipx --global instead. + PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin \ + pipx install codespell flake8 - name: Fix repository permissions run: | diff --git a/Makefile b/Makefile index 217a1af931..81dcce11d0 100644 --- a/Makefile +++ b/Makefile @@ -307,6 +307,10 @@ endif ifeq ($(shell command -v flake8),) echo "Please install flake8" exit 1 +endif +ifeq ($(shell command -v codespell),) + echo "Please install codespell" + exit 1 endif flake8 test/deps/import-busybox shellcheck --shell sh test/*.sh test/includes/*.sh test/suites/*.sh test/backends/*.sh test/lint/*.sh diff --git a/shell.nix b/shell.nix index 076b6d5374..b478c3a1b2 100644 --- a/shell.nix +++ b/shell.nix @@ -35,6 +35,7 @@ pkgs.mkShell { gopls # static-analysis + codespell debianutils go-licenses go-swagger diff --git a/test/lint/codespell.sh b/test/lint/codespell.sh new file mode 100755 index 0000000000..a1bae6b48b --- /dev/null +++ b/test/lint/codespell.sh @@ -0,0 +1,2 @@ +#!/bin/sh -eu +codespell -S 'internal/server/apparmor/*.profile.go' -I .codespell-ignore client cmd doc grafana internal scripts shared test