Skip to content

Commit 78b5bf3

Browse files
committed
Add check for non-inclusive language
Add a check for usage of terms and language that is considered non-inclusive. We are using the woke tool for this with a wordlist that can be found at https://github.com/linux-system-roles/tox-lsr/blob/main/src/tox_lsr/config_files/woke.yml Note: this commit uses the customized woke placed locally in .github/actions/custom-woke-action. It will be replaced with the official woke once get-woke/woke#252 (Add an option "--count-only-error-for-failure") is processed. CHANGELOG.md - cleanup non-inclusive words. tests/tasks/setup_ipa.yml - Apply "wokeignore:rule" Signed-off-by: Noriko Hosoi <nhosoi@redhat.com>
1 parent 4c2474a commit 78b5bf3

8 files changed

Lines changed: 187 additions & 1 deletion

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright © 2020 Caitlin Elfring <celfring@gmail.com>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# woke-action
2+
3+
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/get-woke/woke-action?logo=github&sort=semver)](https://github.com/get-woke/woke-action/releases)
4+
5+
Woke GitHub Actions allow you to execute [`woke`](https://github.com/get-woke/woke) command within GitHub Actions.
6+
7+
The output of the actions can be viewed from the Actions tab in the main repository view.
8+
9+
## Usage
10+
11+
The most common usage is to run `woke` on a file/directory. This workflow can be configured by adding the following content to the GitHub Actions workflow YAML file (ie in `.github/workflows/woke.yaml`).
12+
13+
```yaml
14+
name: woke
15+
on:
16+
- pull_request
17+
jobs:
18+
woke:
19+
name: woke
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v2
24+
25+
- name: woke
26+
uses: get-woke/woke-action@v0
27+
with:
28+
# Cause the check to fail on any broke rules
29+
fail-on-error: true
30+
```
31+
32+
## Inputs
33+
34+
Inputs to configure the `woke` GitHub Actions.
35+
36+
| Input | Default | Description |
37+
|------------------|-----------------------|---------------------------------------------------------------------------------------------------|
38+
| `woke-args` | `.` | (Optional) Additional flags to run woke with (see <https://github.com/get-woke/woke#usage>) |
39+
| `woke-version` | latest | (Optional) Release version of `woke` (defaults to latest version) |
40+
| `fail-on-error` | `false` | (Optional) Fail the GitHub Actions check for any failures. |
41+
| `workdir` | `.` | (Optional) Run `woke` this working directory relative to the root directory. |
42+
| `github-token` | `${{ github.token }}` | (Optional) Custom GitHub Access token (ie `${{ secrets.MY_CUSTOM_TOKEN }}`). |
43+
44+
## License
45+
46+
This application is licensed under the MIT License, you may obtain a copy of it
47+
[here](https://github.com/get-woke/woke-action/blob/main/LICENSE).
48+
49+
## Only Changed Files
50+
51+
If you're interested in only running `woke` against files that have changed in a PR,
52+
consider something like [Get All Changed Files Action](https://github.com/marketplace/actions/get-all-changed-files). With this, you can add a workflow that looks like:
53+
54+
```yaml
55+
56+
name: 'woke'
57+
on:
58+
- pull_request
59+
jobs:
60+
woke:
61+
name: 'woke'
62+
runs-on: ubuntu-latest
63+
steps:
64+
- name: 'Checkout'
65+
uses: actions/checkout@v2
66+
67+
- uses: jitterbit/get-changed-files@v1
68+
id: files
69+
70+
- name: 'woke'
71+
uses: get-woke/woke-action@v0
72+
with:
73+
# Cause the check to fail on any broke rules
74+
fail-on-error: true
75+
# See https://github.com/marketplace/actions/get-all-changed-files
76+
# for more options
77+
woke-args: ${{ steps.files.outputs.added_modified }}
78+
```
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: 'Run woke'
2+
description: >-
3+
Run woke on pull requests to detect non-inclusive language
4+
in your source code.
5+
author: 'Caitlin Elfring (caitlinelfring)'
6+
inputs:
7+
github-token:
8+
description: 'GITHUB_TOKEN'
9+
required: true
10+
default: ${{ github.token }}
11+
woke-args:
12+
description: 'woke arguments'
13+
default: '.'
14+
required: false
15+
fail-on-error:
16+
description: |
17+
Exit code when errors are found [true,false]
18+
Default is `false`.
19+
default: 'false'
20+
required: false
21+
workdir:
22+
description: 'Working directory relative to the root directory.'
23+
default: '.'
24+
required: false
25+
woke-version:
26+
description: >-
27+
woke version, defaults to the latest `v0` version.
28+
Override to pin to a specific version
29+
default: 'v0'
30+
required: false
31+
runs:
32+
using: 'composite'
33+
steps:
34+
- run: $GITHUB_ACTION_PATH/entrypoint.sh
35+
shell: bash
36+
env:
37+
# INPUT_<VARIABLE_NAME> is not available in Composite run steps
38+
# https://github.com/actions/runner/issues/665
39+
INPUT_GITHUB_TOKEN: ${{ inputs.github-token }}
40+
INPUT_WOKE_VERSION: ${{ inputs.woke-version }}
41+
INPUT_WOKE_ARGS: ${{ inputs.woke-args }}
42+
INPUT_FAIL_ON_ERROR: ${{ inputs.fail-on-error }}
43+
INPUT_WORKDIR: ${{ inputs.workdir }}
44+
branding:
45+
icon: 'check-circle'
46+
color: 'gray-dark'
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
# shellcheck disable=SC2086
3+
4+
set -e
5+
6+
cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit 1
7+
8+
TEMP_PATH="$(mktemp -d)"
9+
PATH="${TEMP_PATH}:$PATH"
10+
11+
echo '::group:: Installing woke ... https://github.com/nhosoi/woke'
12+
curl https://raw.githubusercontent.com/nhosoi/woke/main/woke -o "${TEMP_PATH}/woke"
13+
chmod 0755 "${TEMP_PATH}/woke"
14+
echo '::endgroup::'
15+
16+
echo '::group:: Running woke ...'
17+
woke \
18+
--output github-actions \
19+
--exit-1-on-failure="${INPUT_FAIL_ON_ERROR:-false}" \
20+
${INPUT_WOKE_ARGS}
21+
echo '::endgroup::'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
I have a whitelist and a blacklist. What should I do about it?

.github/workflows/woke.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# yamllint disable rule:line-length
2+
name: Check for non-inclusive language
3+
on: # yamllint disable-line rule:truthy
4+
- pull_request
5+
jobs:
6+
woke:
7+
runs-on: ubuntu-latest
8+
steps:
9+
# This step checks out a copy of your repository.
10+
- uses: actions/checkout@v3
11+
# This step references the directory that contains the action.
12+
- name: custom woke
13+
# Originally, uses: get-woke/woke-action@v0
14+
uses: ./.github/actions/custom-woke-action
15+
with:
16+
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"
17+
# Cause the check to fail on any broke rules
18+
fail-on-error: true

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ correct ones).
1818

1919
### Other Changes
2020

21-
- changelog_to_tag action - support other than "master" for the main branch name (#129)
21+
- changelog_to_tag action - github action ansible test improvements
2222

2323
[1.1.6] - 2022-07-19
2424
--------------------

tests/tasks/setup_ipa.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- name: Clone ansible-freeipa repo
1313
git:
1414
repo: https://github.com/freeipa/ansible-freeipa
15+
# wokeignore:rule=master
1516
version: master
1617
dest: /tmp/freeipa-repo
1718
delegate_to: 127.0.0.1

0 commit comments

Comments
 (0)