add sanity.sh info to contributing.md

This commit is contained in:
Konrad `ktoso` Malawski 2020-07-17 10:05:33 +09:00 committed by Konrad `ktoso` Malawski
parent 56ae451f00
commit 313c84fdec
1 changed files with 26 additions and 0 deletions

View File

@ -65,6 +65,32 @@ 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`
The scripts directory contains a [sanity.sh script](https://github.com/swift-server/swift-service-lifecycle/blob/master/scripts/sanity.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
on minor changes such as a missing `self.` or similar formatting issues.
> The script also executes the above mentioned `generate_linux_tests.rb`.
For frequent contributors, we recommend adding the script as a [git pre-push hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks), which you can do via executing the following command in the project root directory:
```bash
cat << EOF > .git/hooks/pre-push
#!/bin/bash
if [[ -f "scripts/sanity.sh" ]]; then
scripts/sanity.sh
fi
EOF
```
Which makes the script execute, and only allow the `git push` to complete if the check has passed.
In the case of formatting issues, you can then `git add` the formatting changes, and attempt the push again.
## How to contribute your work
Please open a pull request at https://github.com/apple/swift-metrics. Make sure the CI passes, and then wait for code review.