diff --git a/.circleci/config.yml b/.circleci/config.yml index b55e30c..d0bb24d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -38,14 +38,7 @@ jobs: command: black . --check - run: name: check word dictionaries are sorted - command: | - for file in "whitelist.txt" flake8_spellcheck/*.txt; - do - if [ "$(sort < "$file")" != "$(<"$file")" ]; then - echo "$file is not sorted correctly" - exit 1 - fi - done + command: ./check-sorting.sh - run: name: yamllint command: yamllint . diff --git a/README.rst b/README.rst index 59e28ce..627297a 100644 --- a/README.rst +++ b/README.rst @@ -62,6 +62,10 @@ adding those word(s) to the appropriate dictionaries: * `technical dictionary `_ * `django dictionary `_ +Before you submit a PR, it is recommended to run ``check-sorting.sh`` in the root of this repository, +to verify that all the dictionary files are still sorted correctly. Sorting is enforced by CI, so +you'll need to make sure the files are sorted before your PR can be merged. + .. |CircleCI| image:: https://circleci.com/gh/MichaelAquilina/flake8-spellcheck.svg?style=svg :target: https://circleci.com/gh/MichaelAquilina/flake8-spellcheck diff --git a/check-sorting.sh b/check-sorting.sh new file mode 100755 index 0000000..a3150f9 --- /dev/null +++ b/check-sorting.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +cd "$(dirname "$0")" + +# Sorting is locale-dependent, so force sort to use a locale that's always +# available for consistency. +export LC_ALL=C + +all_sorted="true" + +for file in "whitelist.txt" flake8_spellcheck/*.txt; do + if [[ "$(sort < "$file")" != "$(<"$file")" ]]; then + echo "$file is not sorted correctly" >&2 + all_sorted="false" + fi +done + +if [[ "$all_sorted" == "false" ]]; then + exit 1 +fi