Skip to content

Commit 288a5b8

Browse files
ci: add quality gates and lockfile policy guard
1 parent a8bc359 commit 288a5b8

File tree

4 files changed

+95
-1
lines changed

4 files changed

+95
-1
lines changed

.githooks/pre-commit

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Library repositories must not commit Cargo.lock.
5+
if git diff --cached --name-only | grep -Eq '(^|/)Cargo\.lock$'; then
6+
echo "error: Cargo.lock must not be committed in library repositories (it should be gitignored)." >&2
7+
exit 1
8+
fi
9+
10+

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
policy:
9+
name: policy (no Cargo.lock)
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Fail if Cargo.lock is committed
14+
run: |
15+
set -euo pipefail
16+
if git ls-files | grep -Eq '(^|/)Cargo\.lock$'; then
17+
echo "error: Cargo.lock must not be committed in library repositories (it should be gitignored)." >&2
18+
exit 1
19+
fi
20+
21+
fmt:
22+
name: fmt
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: dtolnay/rust-toolchain@nightly
27+
with:
28+
components: rustfmt
29+
- name: cargo fmt (check)
30+
run: cargo +nightly fmt --all -- --check
31+
32+
test:
33+
name: check / test / clippy
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
- uses: dtolnay/rust-toolchain@stable
38+
with:
39+
components: clippy
40+
- name: cargo check
41+
run: cargo check --all-targets
42+
- name: cargo test
43+
run: cargo test
44+
- name: cargo clippy
45+
run: cargo clippy --all-targets -- -D warnings
46+
47+

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Currently, Smart String is in active development, and its API might undergo chan
1919
tried-and-true patterns from earlier works, the library as a standalone entity is relatively new. Hence, it's advised to
2020
use it with caution and feel free to provide feedback, report issues, or suggest improvements.
2121

22-
Not yet covered by tests.
22+
Some core behavior is covered by unit tests, but coverage is incomplete.
2323

2424
## Features
2525

@@ -65,3 +65,20 @@ Licensed under either of
6565
Unless you explicitly state otherwise, any contribution intentionally submitted
6666
for inclusion in the work by you, as defined in the Apache-2.0 license,
6767
shall be dual licensed as above, without any additional terms or conditions.
68+
69+
## Development
70+
71+
Recommended (enable repo hooks once per clone):
72+
73+
```bash
74+
git config core.hooksPath .githooks
75+
```
76+
77+
Quality gates:
78+
79+
```bash
80+
cargo +nightly fmt --all -- --check
81+
cargo check --all-targets
82+
cargo test
83+
cargo +stable clippy --all-targets -- -D warnings
84+
```

rustfmt.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Project configuration for rustfmt Rust code formatter.
2+
# See full list of configurations at:
3+
# https://github.com/rust-lang-nursery/rustfmt/blob/master/Configurations.md
4+
5+
max_width = 100
6+
enum_discrim_align_threshold = 40
7+
format_strings = false
8+
group_imports = "StdExternalCrate"
9+
imports_granularity = "Item"
10+
11+
format_code_in_doc_comments = true
12+
format_macro_matchers = true
13+
use_try_shorthand = true
14+
15+
#error_on_line_overflow = true
16+
#error_on_unformatted = true
17+
18+
unstable_features = true
19+
20+

0 commit comments

Comments
 (0)