Skip to content

Commit 83cc4b5

Browse files
committed
New pre commit hooks + updated contributing guide
1 parent 0075056 commit 83cc4b5

File tree

5 files changed

+70
-48
lines changed

5 files changed

+70
-48
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,6 @@ releases/v0.3.2.md
139139
.crush
140140
.jscpd-frontend-report
141141
.jscpd-report
142-
scripts
142+
scripts/*
143+
!scripts/pre-commit
143144
.golangci-report.json

CONTRIBUTING.md

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Thanks for your interest in contributing! See the [README](README.md) for a project overview.
44

5+
> **Note:** The GitHub repository is a read-only push mirror. All development and contributions happen on [Codeberg](https://codeberg.org/realigned/windshift-core). Please fork, clone, and open pull requests there.
6+
57
## Prerequisites
68

79
- **Go** 1.25+
@@ -12,17 +14,30 @@ Thanks for your interest in contributing! See the [README](README.md) for a proj
1214

1315
```bash
1416
# Clone the repo
15-
git clone <repo-url> && cd core
17+
git clone https://codeberg.org/realigned/windshift-core.git && cd windshift-core/core
1618

1719
# Install frontend dependencies
1820
cd frontend && npm install && cd ..
1921

22+
# Install git hooks
23+
make hooks
24+
2025
# Start PostgreSQL + dev server (SQLite for main app, PostgreSQL for logbook)
2126
./dev.sh
2227
```
2328

2429
The dev server runs on `localhost:7777`.
2530

31+
### Git Hooks
32+
33+
The project includes a pre-commit hook that runs `golangci-lint` and `biome check` before each commit. Install it with:
34+
35+
```bash
36+
make hooks
37+
```
38+
39+
To bypass the hook for a quick commit, use `git commit --no-verify`.
40+
2641
For frontend-only development with hot reload:
2742

2843
```bash
@@ -53,7 +68,6 @@ make dev-build
5368
│ └── database/ # Database setup and migrations
5469
├── frontend/ # Svelte 5 / Vite / Tailwind CSS
5570
├── cmd/ws/ # CLI client
56-
├── tests/ # Integration tests
5771
└── .github/workflows/ # CI pipelines
5872
```
5973

@@ -81,40 +95,9 @@ cd frontend
8195
npm run lint # check
8296
npm run format # auto-format
8397
```
84-
85-
## Testing
86-
87-
### Go unit tests
88-
89-
```bash
90-
make test # runs with -tags="test" -race
91-
```
92-
93-
### Go integration tests
94-
95-
Requires a running server (start with `./dev.sh` first):
96-
97-
```bash
98-
make integration-test
99-
```
100-
101-
### Frontend unit tests
102-
103-
```bash
104-
cd frontend && npm test
105-
```
106-
107-
### Frontend E2E (Playwright)
108-
109-
```bash
110-
cd frontend && npx playwright test
111-
```
112-
113-
Production builds exclude test code via build tags (`-tags="!test"`).
114-
11598
## Submitting a Pull Request
11699

117-
**Important**: Pull Requests will not be accepted on Github to prevent Spam. Please submit all PRs via https://codeberg.org/realigned/windshift-core
100+
Please open all pull requests on [Codeberg](https://codeberg.org/realigned/windshift-core).
118101

119102
1. Push your branch and open a PR against `main`.
120103
2. CI will run automatically:

Makefile

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ BUILD_TAGS=-tags="!test"
1919
# Directories
2020
FRONTEND_DIR=frontend
2121

22-
.PHONY: all build build-linux build-windows clean deps frontend help lint dev-build release test-setup
22+
.PHONY: all build build-linux build-windows clean deps frontend help hooks lint dev-build release
2323

2424
# Default target
2525
all: clean frontend build
@@ -73,6 +73,14 @@ lint:
7373
echo "golangci-lint not installed, run 'make dev-tools' first"; \
7474
fi
7575

76+
# Install git hooks
77+
hooks:
78+
@echo "Installing git hooks..."
79+
@mkdir -p .git/hooks
80+
@cp scripts/pre-commit .git/hooks/pre-commit
81+
@chmod +x .git/hooks/pre-commit
82+
@echo "Pre-commit hook installed."
83+
7684
# Quick development build
7785
dev-build:
7886
@echo "Building development binary..."
@@ -84,15 +92,6 @@ release: clean deps frontend build
8492
@echo "Binary: $(BINARY_NAME)"
8593
@ls -lh $(BINARY_NAME)
8694

87-
# Clone test repo and run tests locally
88-
test-setup:
89-
@echo "Tests live in the private Windshiftapp/core-tests repo."
90-
@echo ""
91-
@echo "To run tests locally:"
92-
@echo " git clone git@github.com:Windshiftapp/core-tests.git /tmp/core-tests"
93-
@echo " /tmp/core-tests/overlay.sh ."
94-
@echo " go test -tags=\"test\" -race -timeout=15m ./..."
95-
9695
# Show help
9796
help:
9897
@echo "Windshift Build System"
@@ -109,11 +108,9 @@ help:
109108
@echo " make lint - Run static analysis"
110109
@echo " make deps - Update dependencies"
111110
@echo ""
112-
@echo "Testing:"
113-
@echo " make test-setup - Instructions for running tests (separate repo)"
114-
@echo ""
115111
@echo "Utilities:"
116112
@echo " make frontend - Build frontend only"
117113
@echo " make clean - Clean build artifacts"
118114
@echo " make dev-tools - Install development tools"
115+
@echo " make hooks - Install git pre-commit hook"
119116
@echo " make help - Show this help message"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Windshift is built on a minimalist philosophy: Lean frontend and backend while m
6969
## Documentation
7070

7171
- [BUILD.md](BUILD.md) - Build instructions
72+
- [CONTRIBUTING.md](CONTRIBUTING.md) - Contributing guide
7273
- [LOGGING.md](LOGGING.md) - Logging configuration
7374

7475
## License

scripts/pre-commit

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Pre-commit hook: runs Go and frontend linting before allowing a commit.
5+
# Bypass with: git commit --no-verify
6+
7+
REPO_ROOT="$(git rev-parse --show-toplevel)"
8+
FAILED=0
9+
10+
echo "Running pre-commit checks..."
11+
12+
# --- Go linting ---
13+
if command -v golangci-lint >/dev/null 2>&1; then
14+
echo " Running golangci-lint..."
15+
if ! (cd "$REPO_ROOT" && golangci-lint run --timeout=5m); then
16+
echo "FAIL: golangci-lint found issues."
17+
FAILED=1
18+
fi
19+
else
20+
echo " WARNING: golangci-lint not installed, skipping Go lint (run 'make dev-tools' to install)"
21+
fi
22+
23+
# --- Frontend linting ---
24+
if [ -d "$REPO_ROOT/frontend" ]; then
25+
echo " Running frontend checks..."
26+
if ! (cd "$REPO_ROOT/frontend" && npm run check); then
27+
echo "FAIL: frontend check found issues."
28+
FAILED=1
29+
fi
30+
else
31+
echo " WARNING: frontend/ directory not found, skipping frontend checks"
32+
fi
33+
34+
if [ "$FAILED" -ne 0 ]; then
35+
echo ""
36+
echo "Pre-commit checks failed. Fix the issues above or use 'git commit --no-verify' to bypass."
37+
exit 1
38+
fi
39+
40+
echo "All pre-commit checks passed."

0 commit comments

Comments
 (0)