From 923775a5f68eac76e94726fe71e6e50e4cf93697 Mon Sep 17 00:00:00 2001 From: Yim Lee Date: Fri, 22 Jan 2021 00:42:50 -0800 Subject: [PATCH] Use welcoming language (#90) --- CONTRIBUTING.md | 10 +++++----- docker/docker-compose.yaml | 4 ++-- scripts/{sanity.sh => soundness.sh} | 18 +++++++++++++++++- 3 files changed, 24 insertions(+), 8 deletions(-) rename scripts/{sanity.sh => soundness.sh} (90%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fa0b621..11eb1c5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,12 +65,12 @@ We require that your commit messages match our template. The easiest way to do t SwiftMetrics uses XCTest to run tests on both macOS and Linux. While the macOS version of XCTest is able to use the Objective-C runtime to discover tests at execution time, the Linux version is not. For this reason, whenever you add new tests **you have to run a script** that generates the hooks needed to run those tests on Linux, or our CI will complain that the tests are not all present on Linux. To do this, merely execute `ruby ./scripts/generate_linux_tests.rb` at the root of the package and check the changes it made. -### Run `./scripts/sanity.sh` +### Run `./scripts/soundness.sh` -The scripts directory contains a [sanity.sh script](https://github.com/apple/swift-metrics/blob/main/scripts/sanity.sh) +The scripts directory contains a [soundness.sh script](https://github.com/apple/swift-metrics/blob/main/scripts/soundness.sh) that enforces additional checks, like license headers and formatting style. -Please make sure to `./scripts/sanity.sh` before pushing a change upstream, otherwise it is likely the PR validation will fail +Please make sure to `./scripts/soundness.sh` before pushing a change upstream, otherwise it is likely the PR validation will fail on minor changes such as a missing `self.` or similar formatting issues. > The script also executes the above mentioned `generate_linux_tests.rb`. @@ -81,8 +81,8 @@ For frequent contributors, we recommend adding the script as a [git pre-push hoo cat << EOF > .git/hooks/pre-push #!/bin/bash -if [[ -f "scripts/sanity.sh" ]]; then - scripts/sanity.sh +if [[ -f "scripts/soundness.sh" ]]; then + scripts/soundness.sh fi EOF ``` diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 38c4d41..7bb11fc 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -22,9 +22,9 @@ services: - CAP_NET_RAW - CAP_NET_BIND_SERVICE - sanity: + soundness: <<: *common - command: /bin/bash -xcl "./scripts/sanity.sh" + command: /bin/bash -xcl "./scripts/soundness.sh" docs: <<: *common diff --git a/scripts/sanity.sh b/scripts/soundness.sh similarity index 90% rename from scripts/sanity.sh rename to scripts/soundness.sh index 6e73704..ca21aaa 100755 --- a/scripts/sanity.sh +++ b/scripts/soundness.sh @@ -47,6 +47,22 @@ else printf "\033[0;32mokay.\033[0m\n" fi +printf "=> Checking for unacceptable language... " +# This greps for unacceptable terminology. The square bracket[s] are so that +# "git grep" doesn't find the lines that greps :). +unacceptable_terms=( + -e blacklis[t] + -e whitelis[t] + -e slav[e] + -e sanit[y] +) +if git grep --color=never -i "${unacceptable_terms[@]}" > /dev/null; then + printf "\033[0;31mUnacceptable language found.\033[0m\n" + git grep -i "${unacceptable_terms[@]}" + exit 1 +fi +printf "\033[0;32mokay.\033[0m\n" + printf "=> Checking format... " FIRST_OUT="$(git status --porcelain)" swiftformat . > /dev/null 2>&1 @@ -60,7 +76,7 @@ else fi printf "=> Checking license headers\n" -tmp=$(mktemp /tmp/.swift-metrics-sanity_XXXXXX) +tmp=$(mktemp /tmp/.swift-metrics-soundness_XXXXXX) for language in swift-or-c bash dtrace; do printf " * $language... "