Skip to content

Commit 89aaab8

Browse files
authored
chore: add git hooks and CONTRIBUTING.md
Refs: #475
1 parent c4fbd91 commit 89aaab8

File tree

3 files changed

+92
-21
lines changed

3 files changed

+92
-21
lines changed

.lefthook.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
pre-commit:
2+
parallel: true
3+
jobs:
4+
- name: fmt
5+
run: rustfmt {staged_files}
6+
glob: "*.rs"
7+
stage_fixed: true
8+
- name: clippy
9+
run: cargo clippy --workspace --all-targets --all-features -- -W clippy::pedantic -D warnings
10+
glob: "*.rs"
11+
- name: bindings
12+
run: tools/update_bindings.sh && git diff --exit-code docsrs_bindings.rs
13+
glob: "allowed_bindings.rs"

CONTRIBUTING.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Contributing to `ext-php-rs`
2+
3+
Thank you for your interest in contributing to `ext-php-rs`! We welcome contributions of all kinds:
4+
5+
- Documentation expansion (examples in particular!)
6+
- Safety reviews (especially if you have experience with Rust and the Zend API).
7+
- Bug fixes and features.
8+
- Feature requests.
9+
- And more!
10+
11+
If you have bigger changes in mind, please open an issue first to discuss the change with us.
12+
13+
## Git Hooks
14+
15+
To catch common mistakes, we use git hooks to run checks before commits and pushes.
16+
For this we use [lefthook](https://github.com/evilmartians/lefthook). See
17+
[the installation docs](https://lefthook.dev/installation/) for instructions on how to install it on
18+
your system.
19+
20+
After installing lefthook, you can run the following command to install the hooks:
21+
22+
```bash
23+
lefthook install
24+
```
25+
26+
### Dependencies
27+
28+
- When changing the `allowed_bindings.rs`, you need to have `docker` and `buildx` installed. This is required to
29+
build the bindings in a consistent environment. See the [installation guide](https://docs.docker.com/engine/install/)
30+
for instructions on how to install Docker.
31+
32+
## Testing
33+
34+
We have both unit and integration tests. When contributing, please ensure that your changes are at least
35+
covered by an integration test. If possible, add unit tests as well. This might not always be possible
36+
due to the need of a running PHP interpreter.
37+
38+
### State of unit tests
39+
There are still large parts of the library that are not covered by unit tests. We strive to cover
40+
as much as possible, but this is a work in progress. If you make changes to untested code, we would
41+
appreciate it if you could add tests for the code you changed.
42+
43+
If this is not possible, or requires a lot of unrelated changes, you don't have to add tests. However,
44+
we would appreciate it if you are able to add those tests in a follow-up PR.
45+
46+
## Documentation
47+
48+
Our documentation is located in the `guide` directory.
49+
If you update functionality, please ensure that the documentation is updated accordingly.
50+
51+
### Breaking Changes
52+
If you make a breaking change, please
53+
If your change is a [breaking change](https://semver.org) a migration guide MUST be included. This
54+
MUST be placed in the `guide/src/migration-guides` directory and named `v<next-version>.md` (e.g. `v0.14.md`).
55+
This guide MUST also be linked in the `guide/src/SUMMARY.md` file under the `Migration Guides` section.
56+
57+
## Commit Messages
58+
59+
We are using [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) to generate our changelogs.
60+
For that reason our tooling ensures that all commit messages adhere to that standard.
61+
62+
To make this easier you can use [convco](https://convco.github.io) to generate commit messages.
63+
64+
## Use of AI tools
65+
66+
- Using AI tools to generate Issues is NOT allowed. AI issues will be closed without comment.
67+
- Using AI tools to generate entire PRs is NOT allowed.
68+
- Using AI tools to generate short code snippets is allowed, but the contributor must review and understand
69+
the generated code. Think of it as a code completion tool.
70+
71+
This is to ensure that the contributor has a good understanding of the code and its purpose.
72+
73+
## License
74+
75+
Unless you explicitly state otherwise, any contribution intentionally submitted
76+
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
77+
dual licensed as described in the [README](README.md#license), without any additional terms or conditions.

README.md

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -179,27 +179,8 @@ Check out one of the example projects:
179179

180180
## Contributions
181181

182-
Contributions are very much welcome. I am a novice Rust developer and any
183-
suggestions are wanted and welcome. Feel free to file issues and PRs through
184-
Github.
185-
186-
Contributions welcome include:
187-
188-
- Documentation expansion (examples in particular!)
189-
- Safety reviews (especially if you have experience with Rust and the Zend API).
190-
- Bug fixes and features.
191-
- Feature requests.
192-
193-
When contributing, please keep in mind the following:
194-
- Create tests if possible.
195-
- Update the documentation if necessary.
196-
- If your change is a [breaking change](https://semver.org) a migration guide MUST be included. This
197-
should be placed in the `guide/src/migration-guides` directory.
198-
- Use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). We use these to automatically generate changelogs.
199-
200-
Unless you explicitly state otherwise, any contribution intentionally submitted
201-
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
202-
dual licensed as above, without any additional terms or conditions.
182+
We welcome contributions to the project! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file
183+
for more information on how to contribute.
203184

204185
## Development
205186

0 commit comments

Comments
 (0)