Skip to content

Commit 2bc811b

Browse files
authored
Merge pull request #21 from OneNoted/local-prepush-ci
Run CI-equivalent checks before push
2 parents 9da39e9 + 3dc0166 commit 2bc811b

7 files changed

Lines changed: 113 additions & 0 deletions

File tree

.githooks/pre-push

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
5+
exec "$repo_root/scripts/local-ci.sh"

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ include = [
1616
"docs/install.md",
1717
"docs/cli.md",
1818
"docs/troubleshooting.md",
19+
"docs/contributing.md",
1920
"LICENSE",
2021
"NOTICE",
2122
"config.example.toml",

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ bindsym $mod+Alt+d exec whispers
8686
- [Installation guide](docs/install.md) — package choices, prerequisites, config path, and feature notes.
8787
- [CLI guide](docs/cli.md) — command groups, examples, and newer rewrite-policy commands.
8888
- [Troubleshooting](docs/troubleshooting.md)`wl-copy`, `/dev/uinput`, cloud checks, and hang diagnostics.
89+
- [Contributor workflow](docs/contributing.md) — install the local pre-push hook and mirror CI before opening a PR.
8990
- [config.example.toml](config.example.toml) — the canonical config template.
9091

9192
## Troubleshooting

docs/contributing.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor workflow
2+
3+
Before you push or open a PR, run the local CI workflow so you catch the same failures that GitHub Actions would catch later.
4+
5+
## Install the pre-push hook
6+
7+
Run this once in your local clone:
8+
9+
```sh
10+
scripts/install-git-hooks.sh
11+
```
12+
13+
That configures:
14+
15+
- `core.hooksPath=.githooks`
16+
- `.githooks/pre-push` to run `scripts/local-ci.sh`
17+
18+
## Run the full local CI workflow manually
19+
20+
```sh
21+
scripts/local-ci.sh
22+
```
23+
24+
By default it mirrors the repo's main CI workflow as closely as practical:
25+
26+
- `cargo fmt --all -- --check`
27+
- `cargo clippy --all-targets -- -D warnings`
28+
- `cargo test`
29+
- `cargo check --no-default-features`
30+
- `cargo check --no-default-features --features osd`
31+
- `cargo check --no-default-features --features local-rewrite`
32+
- `cargo package --locked --allow-dirty`
33+
- CUDA feature checks when `nvcc` is available
34+
- `scripts/build-release-bundle.sh`
35+
36+
## Useful overrides
37+
38+
You can skip expensive local-only steps with environment variables:
39+
40+
```sh
41+
WHISPERS_LOCAL_CI_SKIP_CUDA=1 scripts/local-ci.sh
42+
WHISPERS_LOCAL_CI_SKIP_PACKAGE=1 scripts/local-ci.sh
43+
WHISPERS_LOCAL_CI_SKIP_RELEASE_BUNDLE=1 scripts/local-ci.sh
44+
```
45+
46+
These are meant for local iteration only; the default workflow should stay as close to CI as possible before you open a PR.

scripts/build-release-bundle.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ install -Dm644 docs/cli.md \
7272
"$stage_dir/$bundle_name/share/doc/whispers/docs/cli.md"
7373
install -Dm644 docs/troubleshooting.md \
7474
"$stage_dir/$bundle_name/share/doc/whispers/docs/troubleshooting.md"
75+
install -Dm644 docs/contributing.md \
76+
"$stage_dir/$bundle_name/share/doc/whispers/docs/contributing.md"
7577
install -Dm644 config.example.toml \
7678
"$stage_dir/$bundle_name/share/doc/whispers/config.example.toml"
7779
install -Dm644 LICENSE \

scripts/install-git-hooks.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
5+
cd "$repo_root"
6+
7+
git config core.hooksPath .githooks
8+
chmod +x .githooks/pre-push
9+
10+
printf 'Configured git hooks path: %s\n' "$(git config --get core.hooksPath)"
11+
printf 'Installed pre-push hook: %s/.githooks/pre-push\n' "$repo_root"

scripts/local-ci.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
5+
cd "$repo_root"
6+
7+
skip_cuda="${WHISPERS_LOCAL_CI_SKIP_CUDA:-0}"
8+
skip_package="${WHISPERS_LOCAL_CI_SKIP_PACKAGE:-0}"
9+
skip_release_bundle="${WHISPERS_LOCAL_CI_SKIP_RELEASE_BUNDLE:-0}"
10+
11+
run_step() {
12+
local label="$1"
13+
shift
14+
printf '\n==> %s\n' "$label"
15+
"$@"
16+
}
17+
18+
run_step "Check formatting" cargo fmt --all -- --check
19+
run_step "Clippy (default features)" cargo clippy --all-targets -- -D warnings
20+
run_step "Test (default features)" cargo test
21+
22+
run_step "Check no default features" cargo check --no-default-features
23+
run_step "Check osd feature only" cargo check --no-default-features --features osd
24+
run_step "Check local rewrite feature only" cargo check --no-default-features --features local-rewrite
25+
26+
if [[ "$skip_package" != "1" ]]; then
27+
run_step "Package crate" cargo package --locked --allow-dirty
28+
else
29+
printf '\n==> Skipping cargo package (--allow-dirty) because WHISPERS_LOCAL_CI_SKIP_PACKAGE=1\n'
30+
fi
31+
32+
if [[ "$skip_cuda" == "1" ]]; then
33+
printf '\n==> Skipping CUDA checks because WHISPERS_LOCAL_CI_SKIP_CUDA=1\n'
34+
elif command -v nvcc >/dev/null 2>&1; then
35+
run_step "Check cuda feature only" cargo check --no-default-features --features cuda
36+
run_step "Check cuda + local rewrite features" cargo check --no-default-features --features cuda,local-rewrite
37+
else
38+
printf '\n==> Skipping CUDA checks because nvcc is not available on PATH\n'
39+
fi
40+
41+
if [[ "$skip_release_bundle" != "1" ]]; then
42+
run_step "Build release bundle" scripts/build-release-bundle.sh
43+
else
44+
printf '\n==> Skipping release bundle because WHISPERS_LOCAL_CI_SKIP_RELEASE_BUNDLE=1\n'
45+
fi
46+
47+
printf '\nAll local CI checks passed.\n'

0 commit comments

Comments
 (0)