blob: fb24e366ca048a80b513acf6952fe9c3f6818612 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
# Witryna development tasks
# List available recipes
default:
@just --list
# --- Formatting ---
# Auto-format Rust code
fmt:
cargo fmt --all
# --- Linting ---
# Lint Rust (fmt check + clippy)
lint-rust:
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
# Lint YAML files (if any exist)
lint-yaml:
@if find . -name '*.yml' -o -name '*.yaml' | grep -q .; then yamllint $(find . -name '*.yml' -o -name '*.yaml'); else echo "No YAML files, skipping"; fi
# Scan for leaked secrets
lint-secrets:
gitleaks protect --staged
# Clippy pedantic + nursery (advisory, not enforced in CI)
lint-pedantic:
cargo clippy --all-targets --all-features -- -W clippy::pedantic -W clippy::nursery
# Clippy picky: pedantic + nursery + restriction subset (strict, advisory)
lint-picky:
cargo clippy --all-targets --all-features -- -W clippy::pedantic -W clippy::nursery -W clippy::unwrap_used -W clippy::expect_used -W clippy::panic -W clippy::indexing_slicing -W clippy::clone_on_ref_ptr -W clippy::print_stdout -W clippy::print_stderr
# Run all lints
lint: lint-rust lint-yaml lint-secrets
# --- Testing ---
# Run unit tests
test:
cargo test --all
# Run integration tests (Tier 1 needs git, Tier 2 needs podman/docker)
test-integration:
cargo test --features integration
# Run integration tests with single thread (required for SIGHUP tests)
test-integration-serial:
cargo test --features integration -- --test-threads=1
# Run all lints, unit tests, and integration tests
test-all: lint test test-integration
# --- Building ---
# Build a release binary
build-release:
cargo build --release
# --- Man pages ---
# View witryna(1) man page (run `cargo build` first)
man-1:
man -l target/man/witryna.1
# View witryna.toml(5) man page
man-5:
man -l man/witryna.toml.5
# --- Packaging ---
# Build Debian package
build-deb:
cargo deb
# Show contents of built Debian package
inspect-deb:
#!/usr/bin/env bash
set -euo pipefail
deb=$(find target/debian -name 'witryna_*.deb' 2>/dev/null | head -1)
if [[ -z "$deb" ]]; then echo "No .deb found — run 'just build-deb' first" >&2; exit 1; fi
echo "=== Info ===" && dpkg-deb --info "$deb"
echo "" && echo "=== Contents ===" && dpkg-deb --contents "$deb"
# Build RPM package (requires: cargo install cargo-generate-rpm)
build-rpm:
cargo build --release
cargo generate-rpm
# Show contents of built RPM package
inspect-rpm:
#!/usr/bin/env bash
set -euo pipefail
rpm=$(find target/generate-rpm -name 'witryna-*.rpm' 2>/dev/null | head -1)
if [[ -z "$rpm" ]]; then echo "No .rpm found — run 'just build-rpm' first" >&2; exit 1; fi
echo "=== Info ===" && rpm -qip "$rpm"
echo "" && echo "=== Contents ===" && rpm -qlp "$rpm"
echo "" && echo "=== Config files ===" && rpm -qcp "$rpm"
echo "" && echo "=== Scripts ===" && rpm -q --scripts -p "$rpm"
# --- Release ---
RELEASE_HOST := "git@sandcrawler"
RELEASE_PATH := "/srv/git/release"
# Build tarball with binary, config, service, man pages, examples
build-tarball: build-release
#!/usr/bin/env bash
set -euo pipefail
version=$(cargo metadata --format-version=1 --no-deps | grep -o '"version":"[^"]*"' | head -1 | cut -d'"' -f4)
name="witryna-${version}-linux-amd64"
staging="target/tarball/${name}"
rm -rf "$staging"
mkdir -p "$staging/examples/hooks" "$staging/examples/caddy" "$staging/examples/nginx" "$staging/examples/systemd"
cp target/release/witryna "$staging/"
cp examples/witryna.toml "$staging/"
cp debian/witryna.service "$staging/"
cp target/man/witryna.1 "$staging/"
cp man/witryna.toml.5 "$staging/"
cp README.md "$staging/"
cp examples/hooks/caddy-deploy.sh "$staging/examples/hooks/"
cp examples/caddy/Caddyfile "$staging/examples/caddy/"
cp examples/nginx/witryna.conf "$staging/examples/nginx/"
cp examples/witryna.yaml "$staging/examples/"
cp examples/systemd/docker.conf "$staging/examples/systemd/"
cp examples/systemd/podman.conf "$staging/examples/systemd/"
tar -czf "target/tarball/${name}.tar.gz" -C target/tarball "$name"
echo "target/tarball/${name}.tar.gz"
# Upload deb to release server
release-deb: build-deb
#!/usr/bin/env bash
set -euo pipefail
f=$(find target/debian -name 'witryna_*.deb' | sort -V | tail -1)
if [[ -z "$f" ]]; then echo "No .deb found" >&2; exit 1; fi
sha256sum "$f" > "${f}.sha256"
scp "$f" "${f}.sha256" "{{RELEASE_HOST}}:{{RELEASE_PATH}}/"
echo "Done — https://release.craftknight.com/"
# Upload rpm to release server
release-rpm: build-rpm
#!/usr/bin/env bash
set -euo pipefail
f=$(find target/generate-rpm -name 'witryna-*.rpm' | sort -V | tail -1)
if [[ -z "$f" ]]; then echo "No .rpm found" >&2; exit 1; fi
sha256sum "$f" > "${f}.sha256"
scp "$f" "${f}.sha256" "{{RELEASE_HOST}}:{{RELEASE_PATH}}/"
echo "Done — https://release.craftknight.com/"
# Upload tarball to release server
release-tarball: build-tarball
#!/usr/bin/env bash
set -euo pipefail
f=$(find target/tarball -name 'witryna-*.tar.gz' | sort -V | tail -1)
if [[ -z "$f" ]]; then echo "No tarball found" >&2; exit 1; fi
sha256sum "$f" > "${f}.sha256"
scp "$f" "${f}.sha256" "{{RELEASE_HOST}}:{{RELEASE_PATH}}/"
echo "Done — https://release.craftknight.com/"
# Build and upload all packages (deb + rpm + tarball)
release: release-deb release-rpm release-tarball
# --- Pre-commit ---
# Run all pre-commit checks (mirrors lefthook)
pre-commit: lint test
|