From a3a71487b0a55c546ccfa2fb1e680d68df8bd471 Mon Sep 17 00:00:00 2001 From: rht Date: Mon, 18 Oct 2021 07:48:08 -0400 Subject: [PATCH] CI: Add Codespell linter. This tool helps catch common typos in code and documentation, which is particularly useful for our many contributors who are not native English speakers. The config is based on the codespell that I ran in https://github.com/zulip/zulip/pull/18535. --- .codespellignore | 18 ++++++++++++++++++ .github/workflows/zulip-ci.yml | 5 +++++ requirements/dev.in | 3 +++ requirements/dev.txt | 4 ++++ tools/run-codespell | 22 ++++++++++++++++++++++ version.py | 2 +- 6 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 .codespellignore create mode 100755 tools/run-codespell diff --git a/.codespellignore b/.codespellignore new file mode 100644 index 0000000000..77acea2691 --- /dev/null +++ b/.codespellignore @@ -0,0 +1,18 @@ +te +ans +pullrequest +ist +cros +wit +nwe +circularly +ned +ba +ressemble +ser +sur +hel +fpr +alls +nd +ot diff --git a/.github/workflows/zulip-ci.yml b/.github/workflows/zulip-ci.yml index 893804bb50..d054cf68f6 100644 --- a/.github/workflows/zulip-ci.yml +++ b/.github/workflows/zulip-ci.yml @@ -100,6 +100,11 @@ jobs: source tools/ci/activate-venv ./tools/test-tools + - name: Run Codespell lint + run: | + source tools/ci/activate-venv + ./tools/run-codespell + - name: Run backend lint run: | source tools/ci/activate-venv diff --git a/requirements/dev.in b/requirements/dev.in index 374e74073f..96ebc568f5 100644 --- a/requirements/dev.in +++ b/requirements/dev.in @@ -77,3 +77,6 @@ pyre-check # For sorting versions when uploading releases natsort + +# For spell check linter +codespell diff --git a/requirements/dev.txt b/requirements/dev.txt index d43dda59bb..bcab0ba665 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -228,6 +228,10 @@ click-option-group==0.5.3 \ --hash=sha256:9653a2297357335d7325a1827e71ac1245d91c97d959346a7decabd4a52d5354 \ --hash=sha256:a6e924f3c46b657feb5b72679f7e930f8e5b224b766ab35c91ae4019b4e0615e # via semgrep +codespell==2.1.0 \ + --hash=sha256:19d3fe5644fef3425777e66f225a8c82d39059dcfe9edb3349a8a2cf48383ee5 \ + --hash=sha256:b864c7d917316316ac24272ee992d7937c3519be4569209c5b60035ac5d569b5 + # via -r requirements/dev.in colorama==0.4.4 \ --hash=sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b \ --hash=sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2 diff --git a/tools/run-codespell b/tools/run-codespell new file mode 100755 index 0000000000..5c09a29e4d --- /dev/null +++ b/tools/run-codespell @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Fix common misspellings in text files (config: .codespellignore) +# Based on +# https://github.com/bitcoin/bitcoin/blob/master/test/lint/lint-spelling.sh +# +# We plan to replace this script with the `tools/lint` system as soon as we can. + +IGNORE_WORDS_FILE=.codespellignore +FILES_TO_BE_CHECKED=$* +if [ -z "$FILES_TO_BE_CHECKED" ]; then + echo "No argument specified. Checking on the entire repo..." + FILES_TO_BE_CHECKED="$(git ls-files -- ':(exclude)locale' ':(exclude)*fixtures*' ':(exclude)*.svg' ':(exclude)docs/translating' ':(exclude)yarn.lock' ':(exclude)docs/THIRDPARTY' ':(exclude)*postgresql.conf.template.erb' ':(exclude)tools/setup/emoji/emoji_names.py' ':(exclude)tools/setup/emoji/emoji_map.json' ':(exclude)zerver/management/data/unified_reactions.json')" +else + echo "Checking $FILES_TO_BE_CHECKED" +fi +mapfile -t FILES_TO_BE_CHECKED <<<"$FILES_TO_BE_CHECKED" + +if ! codespell --ignore-words=$IGNORE_WORDS_FILE "${FILES_TO_BE_CHECKED[@]}"; then + echo "You may check the files for typo again using ./tools/run-codespell ... " + exit 1 +fi diff --git a/version.py b/version.py index 37d425bca1..9b05738002 100644 --- a/version.py +++ b/version.py @@ -48,4 +48,4 @@ API_FEATURE_LEVEL = 106 # historical commits sharing the same major version, in which case a # minor version bump suffices. -PROVISION_VERSION = "164.2" +PROVISION_VERSION = "164.3"