Skip to content

Commit 0aba5b7

Browse files
committed
ci: Replace woke with codespell
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]>
1 parent a66144b commit 0aba5b7

8 files changed

+84
-23
lines changed

.codespell_ignores

Whitespace-only changes.

.codespellrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[codespell]
2+
ignore-multiline-regex = codespell:ignore-begin.*codespell:ignore-end
3+
context = 0
4+
ignore-words = .codespell_ignores

.github/workflows/ansible-lint.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,48 @@ jobs:
3535
pip3 install "git+https://github.com/linux-system-roles/[email protected]"
3636
3737
- name: Convert role to collection format
38+
id: collection
3839
run: |
3940
set -euxo pipefail
4041
TOXENV=collection lsr_ci_runtox
4142
coll_dir=".tox/ansible_collections/$LSR_ROLE2COLL_NAMESPACE/$LSR_ROLE2COLL_NAME"
43+
# cleanup after collection conversion
44+
rm -rf "$coll_dir/.ansible" .tox/ansible-plugin-scan
4245
# ansible-lint action requires a .git directory???
4346
# https://github.com/ansible/ansible-lint/blob/main/action.yml#L45
4447
mkdir -p "$coll_dir/.git"
48+
meta_req_file="${{ github.workspace }}/meta/collection-requirements.yml"
49+
test_req_file="${{ github.workspace }}/tests/collection-requirements.yml"
50+
if [ -f "$meta_req_file" ] && [ -f "$test_req_file" ]; then
51+
coll_req_file="${{ github.workspace }}/req.yml"
52+
python -c 'import sys; import yaml
53+
hsh1 = yaml.safe_load(open(sys.argv[1]))
54+
hsh2 = yaml.safe_load(open(sys.argv[2]))
55+
coll = {}
56+
for item in hsh1["collections"] + hsh2["collections"]:
57+
if isinstance(item, dict):
58+
name = item["name"]
59+
rec = item
60+
else:
61+
name = item # assume string
62+
rec = {"name": name}
63+
if name not in coll:
64+
coll[name] = rec
65+
hsh1["collections"] = list(coll.values())
66+
yaml.safe_dump(hsh1, open(sys.argv[3], "w"))' "$meta_req_file" "$test_req_file" "$coll_req_file"
67+
echo merged "$coll_req_file"
68+
cat "$coll_req_file"
69+
elif [ -f "$meta_req_file" ]; then
70+
coll_req_file="$meta_req_file"
71+
elif [ -f "$test_req_file" ]; then
72+
coll_req_file="$test_req_file"
73+
else
74+
coll_req_file=""
75+
fi
76+
echo "coll_req_file=$coll_req_file" >> $GITHUB_OUTPUT
4577
4678
- name: Run ansible-lint
47-
uses: ansible/ansible-lint@v24
79+
uses: ansible/ansible-lint@v25
4880
with:
4981
working_directory: ${{ github.workspace }}/.tox/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }}
82+
requirements_file: ${{ steps.collection.outputs.coll_req_file }}

.github/workflows/ansible-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ jobs:
4343
- name: Run ansible-test
4444
uses: ansible-community/ansible-test-gh-action@release/v1
4545
with:
46-
testing-type: sanity # wokeignore:rule=sanity
46+
testing-type: sanity
4747
ansible-core-version: stable-2.17
4848
collection-src-directory: ${{ github.workspace }}/.tox/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }}

.github/workflows/codespell.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Codespell configuration is within .codespellrc
2+
---
3+
name: Codespell
4+
on: # yamllint disable-line rule:truthy
5+
- pull_request
6+
permissions:
7+
contents: read
8+
jobs:
9+
codespell:
10+
name: Check for spelling errors
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Codespell
17+
uses: codespell-project/actions-codespell@v2
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Codespell configuration is within .codespellrc
2+
---
3+
name: Detect non-inclusive language
4+
on: # yamllint disable-line rule:truthy
5+
- pull_request
6+
permissions:
7+
contents: read
8+
jobs:
9+
codespell:
10+
name: Detect non-inclusive language
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Get variable with regex values
17+
id: regexvar
18+
run: |
19+
curl -L -s -o dictionary_usage.txt https://raw.githubusercontent.com/codespell-project/codespell/refs/heads/main/codespell_lib/data/dictionary_usage.txt
20+
regexvar=$(sed 's/->.*//g' dictionary_usage.txt | sed 's/$/|/' | tr -d '\n' | sed 's/.$//')
21+
rm dictionary_usage.txt
22+
echo "regex = $regexvar" >> .codespellrc
23+
24+
- name: Detect non-inclusive language with codespell
25+
uses: codespell-project/actions-codespell@v2
26+
with:
27+
builtin: usage

.github/workflows/woke.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Role Name
22

3-
[![ansible-lint.yml](https://github.com/linux-system-roles/template/actions/workflows/ansible-lint.yml/badge.svg)](https://github.com/linux-system-roles/template/actions/workflows/ansible-lint.yml) [![ansible-test.yml](https://github.com/linux-system-roles/template/actions/workflows/ansible-test.yml/badge.svg)](https://github.com/linux-system-roles/template/actions/workflows/ansible-test.yml) [![markdownlint.yml](https://github.com/linux-system-roles/template/actions/workflows/markdownlint.yml/badge.svg)](https://github.com/linux-system-roles/template/actions/workflows/markdownlint.yml) [![shellcheck.yml](https://github.com/linux-system-roles/template/actions/workflows/shellcheck.yml/badge.svg)](https://github.com/linux-system-roles/template/actions/workflows/shellcheck.yml) [![tft.yml](https://github.com/linux-system-roles/template/actions/workflows/tft.yml/badge.svg)](https://github.com/linux-system-roles/template/actions/workflows/tft.yml) [![tft_citest_bad.yml](https://github.com/linux-system-roles/template/actions/workflows/tft_citest_bad.yml/badge.svg)](https://github.com/linux-system-roles/template/actions/workflows/tft_citest_bad.yml) [![woke.yml](https://github.com/linux-system-roles/template/actions/workflows/woke.yml/badge.svg)](https://github.com/linux-system-roles/template/actions/workflows/woke.yml)
3+
[![ansible-lint.yml](https://github.com/linux-system-roles/template/actions/workflows/ansible-lint.yml/badge.svg)](https://github.com/linux-system-roles/template/actions/workflows/ansible-lint.yml) [![ansible-test.yml](https://github.com/linux-system-roles/template/actions/workflows/ansible-test.yml/badge.svg)](https://github.com/linux-system-roles/template/actions/workflows/ansible-test.yml) [![codespell.yml](https://github.com/linux-system-roles/template/actions/workflows/codespell.yml/badge.svg)](https://github.com/linux-system-roles/template/actions/workflows/codespell.yml) [![detect_non_inclusive_language.yml](https://github.com/linux-system-roles/template/actions/workflows/detect_non_inclusive_language.yml/badge.svg)](https://github.com/linux-system-roles/template/actions/workflows/detect_non_inclusive_language.yml) [![markdownlint.yml](https://github.com/linux-system-roles/template/actions/workflows/markdownlint.yml/badge.svg)](https://github.com/linux-system-roles/template/actions/workflows/markdownlint.yml) [![shellcheck.yml](https://github.com/linux-system-roles/template/actions/workflows/shellcheck.yml/badge.svg)](https://github.com/linux-system-roles/template/actions/workflows/shellcheck.yml) [![tft.yml](https://github.com/linux-system-roles/template/actions/workflows/tft.yml/badge.svg)](https://github.com/linux-system-roles/template/actions/workflows/tft.yml) [![tft_citest_bad.yml](https://github.com/linux-system-roles/template/actions/workflows/tft_citest_bad.yml/badge.svg)](https://github.com/linux-system-roles/template/actions/workflows/tft_citest_bad.yml)
44

55
![template](https://github.com/linux-system-roles/template/workflows/tox/badge.svg)
66

0 commit comments

Comments
 (0)