Skip to content

Commit 975d8ee

Browse files
authored
+readme add more info about the sanity script to the contributing readme (#57)
1 parent 6742fc4 commit 975d8ee

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

CONTRIBUTING.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,31 @@ We require that your commit messages match our template. The easiest way to do t
6868
SwiftServiceLifecycle 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.
6969
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.
7070

71+
### Run `./scripts/sanity.sh`
72+
73+
The scripts directory contains a [sanity.sh script](https://github.com/swift-server/swift-service-lifecycle/blob/master/scripts/sanity.sh)
74+
that enforces additional checks, like license headers and formatting style.
75+
Please make sure to `./scripts/sanity.sh` before pushing a change upstream, otherwise it is likely the PR validation will fail
76+
on minor changes such as a missing `self.` or similar formatting issues.
77+
78+
> The script also executes the above mentioned `generate_linux_tests.rb`.
79+
80+
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
81+
in the project root directory:
82+
83+
```bash
84+
cat << EOF > .git/hooks/pre-push
85+
#!/bin/bash
86+
87+
if [[ -f "scripts/sanity.sh" ]]; then
88+
scripts/sanity.sh
89+
fi
90+
EOF
91+
```
92+
Which makes the script execute, and only allow the `git push` to complete if the check has passed.
93+
94+
In the case of formatting issues, you can then `git add` the formatting changes, and attempt the push again.
95+
7196
## How to contribute your work
7297

7398
Please open a pull request at https://github.com/swift-server/swift-service-lifecycle. Make sure the CI passes, and then wait for code review.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ It also provides a `Signal`-based shutdown hook, to shut down on signals like `T
66
Swift Service Lifecycle was designed with the idea that every application has some startup and shutdown workflow-like-logic which is often sensitive to failure and hard to get right.
77
The library codes this common need in a safe and reusable way that is non-framework specific, and designed to be integrated with any server framework or directly in an application.
88

9-
This is the beginning of a community-driven open-source project actively seeking contributions, be it code, documentation, or ideas. What Swift Service Lifecycle provides today is covered in the [API docs](https://swift-server.github.io/swift-service-lifecycle/), but it will continue to evolve with community input.
9+
This is the beginning of a community-driven open-source project actively seeking [contributions](CONTRIBUTING.md), be it code, documentation, or ideas. What Swift Service Lifecycle provides today is covered in the [API docs](https://swift-server.github.io/swift-service-lifecycle/), but it will continue to evolve with community input.
1010

1111
## Getting started
1212

0 commit comments

Comments
 (0)