-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
woke has been left with Noriko's and all other PRs not being reviewed for years, hence we have been using our fork. This PR replaces woke with codespell to detect non-inclusive language and check spelling Codespell provides a built-in dictionary with recommended non-inclusive terms: https://github.com/codespell-project/codespell/blob/main/codespell_lib/data/dictionary_usage.txt Codespell supports using custom dictionaries so we can add to the list if we want. `ignore-multiline-regex` in the `.codespellrc` config allows for disabling codespell for a block of lines: ``` # codespell:ignore-begin ... codespell will not look at this text. # codespell:ignore-end ``` You can ignore words inline by adding a comment like `# codespell:ignore word`. You can ignore files and directories, and words by adding them to config file `.codespellrc`. For more information about inclusive naming initiative, see https://inclusivenaming.org/about/ Signed-off-by: Sergei Petrosian <[email protected]>
- Loading branch information
Showing
9 changed files
with
85 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[codespell] | ||
ignore-multiline-regex = codespell:ignore-begin.*codespell:ignore-end | ||
context = 0 | ||
ignore-words = .codespell_ignores |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,15 +35,48 @@ jobs: | |
pip3 install "git+https://github.com/linux-system-roles/[email protected]" | ||
- name: Convert role to collection format | ||
id: collection | ||
run: | | ||
set -euxo pipefail | ||
TOXENV=collection lsr_ci_runtox | ||
coll_dir=".tox/ansible_collections/$LSR_ROLE2COLL_NAMESPACE/$LSR_ROLE2COLL_NAME" | ||
# cleanup after collection conversion | ||
rm -rf "$coll_dir/.ansible" .tox/ansible-plugin-scan | ||
# ansible-lint action requires a .git directory??? | ||
# https://github.com/ansible/ansible-lint/blob/main/action.yml#L45 | ||
mkdir -p "$coll_dir/.git" | ||
meta_req_file="${{ github.workspace }}/meta/collection-requirements.yml" | ||
test_req_file="${{ github.workspace }}/tests/collection-requirements.yml" | ||
if [ -f "$meta_req_file" ] && [ -f "$test_req_file" ]; then | ||
coll_req_file="${{ github.workspace }}/req.yml" | ||
python -c 'import sys; import yaml | ||
hsh1 = yaml.safe_load(open(sys.argv[1])) | ||
hsh2 = yaml.safe_load(open(sys.argv[2])) | ||
coll = {} | ||
for item in hsh1["collections"] + hsh2["collections"]: | ||
if isinstance(item, dict): | ||
name = item["name"] | ||
rec = item | ||
else: | ||
name = item # assume string | ||
rec = {"name": name} | ||
if name not in coll: | ||
coll[name] = rec | ||
hsh1["collections"] = list(coll.values()) | ||
yaml.safe_dump(hsh1, open(sys.argv[3], "w"))' "$meta_req_file" "$test_req_file" "$coll_req_file" | ||
echo merged "$coll_req_file" | ||
cat "$coll_req_file" | ||
elif [ -f "$meta_req_file" ]; then | ||
coll_req_file="$meta_req_file" | ||
elif [ -f "$test_req_file" ]; then | ||
coll_req_file="$test_req_file" | ||
else | ||
coll_req_file="" | ||
fi | ||
echo "coll_req_file=$coll_req_file" >> $GITHUB_OUTPUT | ||
- name: Run ansible-lint | ||
uses: ansible/ansible-lint@v24 | ||
uses: ansible/ansible-lint@v25 | ||
with: | ||
working_directory: ${{ github.workspace }}/.tox/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }} | ||
requirements_file: ${{ steps.collection.outputs.coll_req_file }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Codespell configuration is within .codespellrc | ||
--- | ||
name: Codespell | ||
on: # yamllint disable-line rule:truthy | ||
- pull_request | ||
permissions: | ||
contents: read | ||
jobs: | ||
codespell: | ||
name: Check for spelling errors | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Codespell | ||
uses: codespell-project/actions-codespell@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Codespell configuration is within .codespellrc | ||
--- | ||
name: Detect non-inclusive language | ||
on: # yamllint disable-line rule:truthy | ||
- pull_request | ||
permissions: | ||
contents: read | ||
jobs: | ||
codespell: | ||
name: Detect non-inclusive language | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get variable with regex values | ||
id: regexvar | ||
run: | | ||
curl -L -s -o dictionary_usage.txt https://raw.githubusercontent.com/codespell-project/codespell/refs/heads/main/codespell_lib/data/dictionary_usage.txt | ||
regexvar=$(sed 's/->.*//g' dictionary_usage.txt | sed 's/$/|/' | tr -d '\n' | sed 's/.$//') | ||
rm dictionary_usage.txt | ||
echo "regex = $regexvar" >> .codespellrc | ||
- name: Detect non-inclusive language with codespell | ||
uses: codespell-project/actions-codespell@v2 | ||
with: | ||
builtin: usage |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters