diff --git a/.codespell_ignores b/.codespell_ignores new file mode 100644 index 0000000..e69de29 diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..4f0f759 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,4 @@ +[codespell] +ignore-multiline-regex = codespell:ignore-begin.*codespell:ignore-end +context = 0 +ignore-words = .codespell_ignores diff --git a/.github/workflows/ansible-lint.yml b/.github/workflows/ansible-lint.yml index d0ee41b..666b231 100644 --- a/.github/workflows/ansible-lint.yml +++ b/.github/workflows/ansible-lint.yml @@ -35,15 +35,48 @@ jobs: pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.4.0" - 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 }} diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 4dbdaa2..c9868a2 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -43,6 +43,6 @@ jobs: - name: Run ansible-test uses: ansible-community/ansible-test-gh-action@release/v1 with: - testing-type: sanity # wokeignore:rule=sanity + testing-type: sanity ansible-core-version: stable-2.17 collection-src-directory: ${{ github.workspace }}/.tox/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }} diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 0000000..8eadb61 --- /dev/null +++ b/.github/workflows/codespell.yml @@ -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 diff --git a/.github/workflows/detect_non_inclusive_language.yml b/.github/workflows/detect_non_inclusive_language.yml new file mode 100644 index 0000000..ae49baf --- /dev/null +++ b/.github/workflows/detect_non_inclusive_language.yml @@ -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 diff --git a/.github/workflows/woke.yml b/.github/workflows/woke.yml deleted file mode 100644 index 4cded0d..0000000 --- a/.github/workflows/woke.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -# yamllint disable rule:line-length -name: Woke -on: # yamllint disable-line rule:truthy - - pull_request -jobs: - woke: - name: Detect non-inclusive language - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Run lsr-woke-action - # Originally, uses: get-woke/woke-action@v0 - uses: linux-system-roles/lsr-woke-action@main - with: - woke-args: "-c https://raw.githubusercontent.com/linux-system-roles/tox-lsr/main/src/tox_lsr/config_files/woke.yml --count-only-error-for-failure" - # Cause the check to fail on any broke rules - fail-on-error: true diff --git a/README.md b/README.md index 7229849..7dc2029 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Role Name -[![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) +[![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) ![template](https://github.com/linux-system-roles/template/workflows/tox/badge.svg)