From 782f15dccb5bec164b15f55fdd6de847ac544b00 Mon Sep 17 00:00:00 2001 From: Nawaz Hussain K Date: Thu, 15 Jun 2023 11:52:00 -0700 Subject: [PATCH] add makefile targets to install and verify using codespell 2.2.5 - adds target to install codespell v2.2.5 at hack/tools/bin/codespell - adds a target to verify codebase with installed codespell bin - remove codespell github action --- .github/workflows/codespell.yml | 22 ---------------------- Makefile | 20 +++++++++++++++++++- docs/book/src/developers/development.md | 7 +++++-- 3 files changed, 24 insertions(+), 25 deletions(-) delete mode 100644 .github/workflows/codespell.yml diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml deleted file mode 100644 index f5ee5d7b168..00000000000 --- a/.github/workflows/codespell.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Codespell -on: - pull_request: -permissions: - contents: read - -jobs: - codespell: - runs-on: ubuntu-latest - steps: - - name: Harden Runner - uses: step-security/harden-runner@55d479fb1c5bcad5a4f9099a5d9f37c8857b2845 # v2.4.1 - with: - egress-policy: audit - - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - - uses: codespell-project/actions-codespell@94259cd8be02ad2903ba34a22d9c13de21a74461 # master - with: - skip: .git,_artifacts,*.sum - ignore_words_file: .codespellignore - check_filenames: true - check_hidden: true diff --git a/Makefile b/Makefile index 6c82346bc31..d4071dcc2cb 100644 --- a/Makefile +++ b/Makefile @@ -125,6 +125,11 @@ KIND_VER := v0.20.0 KIND_BIN := kind KIND := $(TOOLS_BIN_DIR)/$(KIND_BIN)-$(KIND_VER) +CODESPELL_VER := 2.2.5 +CODESPELL_BIN := codespell +CODESPELL_DIST_DIR := codespell_dist +CODESPELL := $(TOOLS_BIN_DIR)/$(CODESPELL_DIST_DIR)/$(CODESPELL_BIN) + SETUP_ENVTEST_VER := v0.0.0-20211110210527-619e6b92dab9 SETUP_ENVTEST_BIN := setup-envtest SETUP_ENVTEST := $(abspath $(TOOLS_BIN_DIR)/$(SETUP_ENVTEST_BIN)-$(SETUP_ENVTEST_VER)) @@ -239,7 +244,7 @@ format-tiltfile: ## Format the Tiltfile. ./hack/verify-starlark.sh fix .PHONY: verify -verify: verify-boilerplate verify-modules verify-gen verify-shellcheck verify-conversions verify-tiltfile ## Run "verify-boilerplate", "verify-modules", "verify-gen", "verify-shellcheck", "verify-conversions", "verify-tiltfile" rules. +verify: verify-boilerplate verify-modules verify-gen verify-shellcheck verify-conversions verify-tiltfile verify-codespell ## Run "verify-boilerplate", "verify-modules", "verify-gen", "verify-shellcheck", "verify-conversions", "verify-tiltfile" "verify-codespell" rules. .PHONY: verify-boilerplate verify-boilerplate: ## Verify boilerplate header. @@ -269,6 +274,10 @@ verify-conversions: $(CONVERSION_VERIFIER) ## Verifies expected API conversion verify-tiltfile: ## Verify Tiltfile format. ./hack/verify-starlark.sh +.PHONY: verify-codespell +verify-codespell: codespell ## Verify codespell. + @$(CODESPELL) $(ROOT_DIR) --ignore-words=$(ROOT_DIR)/.codespellignore --skip="*.git,*_artifacts,*.sum,$(ROOT_DIR)/hack/tools/bin/codespell_dist" + ## -------------------------------------- ## Development ## -------------------------------------- @@ -771,6 +780,7 @@ helm: $(HELM) ## Build a local copy of helm. yq: $(YQ) ## Build a local copy of yq. kind: $(KIND) ## Build a local copy of kind. setup-envtest: $(SETUP_ENVTEST) ## Build a local copy of setup-envtest. +codespell : $(CODESPELL) ## Build a local copy of codespell. $(CONVERSION_VERIFIER): go.mod cd $(TOOLS_DIR); go build -tags=tools -o $@ sigs.k8s.io/cluster-api/hack/tools/conversion-verifier @@ -850,3 +860,11 @@ $(SETUP_ENVTEST_BIN): $(SETUP_ENVTEST) ## Build a local copy of setup-envtest. $(SETUP_ENVTEST): # Build setup-envtest from tools folder. GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(SETUP_ENVTEST_PKG) $(SETUP_ENVTEST_BIN) $(SETUP_ENVTEST_VER) + +$(CODESPELL): ## Build codespell from tools folder. + @which $(CODESPELL) >/dev/null || ( \ + mkdir -p $(TOOLS_BIN_DIR); \ + pip install --target=$(TOOLS_BIN_DIR)/$(CODESPELL_DIST_DIR) $(CODESPELL_BIN)==$(CODESPELL_VER); \ + mv $(TOOLS_BIN_DIR)/$(CODESPELL_DIST_DIR)/bin/$(CODESPELL_BIN) $(TOOLS_BIN_DIR)/$(CODESPELL_DIST_DIR); \ + rm -r $(TOOLS_BIN_DIR)/$(CODESPELL_DIST_DIR)/bin; \ + ) diff --git a/docs/book/src/developers/development.md b/docs/book/src/developers/development.md index 199c62f4b37..b745e299233 100644 --- a/docs/book/src/developers/development.md +++ b/docs/book/src/developers/development.md @@ -62,11 +62,13 @@ - [install instructions](https://kubectl.docs.kubernetes.io/installation/kustomize/) on Windows + WSL2. - [install instructions][kustomizelinux] on Linux. 6. Install Python 3.x or 2.7.x, if neither is already installed. -7. Install make. +7. Install pip + - [pip installation instruction](https://pip.pypa.io/en/stable/installation/#installation) +8. Install make. - `brew install make` on MacOS. - `sudo apt install make` on Windows + WSL2. - `sudo apt install make` on Linux. -8. Install [timeout][timeout] +9. Install [timeout][timeout] - `brew install coreutils` on macOS. When developing on Windows, it is suggested to set up the project on Windows + WSL2 and the file should be checked out on as wsl file system for better results. @@ -459,6 +461,7 @@ If you're interested in submitting PRs to the project, please be sure to run som ```bash make lint # Runs a suite of quick scripts to check code structure make lint-fix # Runs a suite of quick scripts to fix lint errors +make verify # Runs a suite of verifying binaries make test # Runs tests on the Go code ```