[GHA] Unacceptable language check #16
Workflow file for this run
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
name: Pull Request | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize, ready_for_review] | |
## We are cancelling previously triggered workflow runs | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
unit-tests: | |
name: Unit tests | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
swift: | |
- image: swift:5.8-jammy | |
- image: swift:5.9-jammy | |
- image: swift:5.10-noble | |
- image: swiftlang/swift:nightly-6.0-jammy | |
- image: swiftlang/swift:nightly-main-jammy | |
container: | |
image: ${{ matrix.swift.image }} | |
timeout-minutes: 20 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Run tests | |
run: swift test | |
api-breakage: | |
name: API breakage check | |
runs-on: ubuntu-latest | |
container: | |
image: swift:5.10-noble | |
timeout-minutes: 20 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
# We need to fetch everything otherwise only the head commit will be fetched. | |
fetch-depth: 0 | |
- name: Mark the workspace as safe | |
# https://github.com/actions/checkout/issues/766 | |
run: git config --global --add safe.directory ${GITHUB_WORKSPACE} | |
- name: Run API breakage check | |
run: swift package diagnose-api-breaking-changes origin/main | |
docs-check: | |
name: Documentation check | |
runs-on: ubuntu-latest | |
container: | |
image: swift:5.10-noble | |
timeout-minutes: 20 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Run documentation check | |
shell: bash | |
run: | | |
set -eu | |
raw_targets=$(sed -E -n -e 's/^.* - documentation_targets: \[(.*)\].*$/\1/p' .spi.yml) | |
targets=(${raw_targets//,/ }) | |
for target in "${targets[@]}"; do | |
swift package plugin generate-documentation --target "$target" --warnings-as-errors --analyze --level detailed | |
done | |
acceptable-language-check: | |
name: Acceptable language check | |
runs-on: ubuntu-latest | |
timeout-minutes: 1 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Run acceptable language check | |
shell: bash | |
run: | | |
set -euo pipefail | |
log() { printf -- "** %s\n" "$*" >&2; } | |
error() { printf -- "** ERROR: %s\n" "$*" >&2; } | |
fatal() { error "$@"; exit 1; } | |
UNACCEPTABLE_WORDS="blacklist|whitelist|slave|master|sane|sanity|insane|insanity|kill|killed|killing|hang|hung|hanged|hanging" | |
log "Checking for unacceptable language..." | |
PATHS_WITH_UNACCEPTABLE_LANGUAGE=$(git grep \ | |
-l -F -w -E ${UNACCEPTABLE_WORDS} \ | |
) || true | /usr/bin/paste -s -d " " - | |
if [ -n "${PATHS_WITH_UNACCEPTABLE_LANGUAGE}" ]; then | |
fatal "❌ Found unacceptable language in files: ${PATHS_WITH_UNACCEPTABLE_LANGUAGE}." | |
fi | |
log "✅ Found no unacceptable language." |