-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjustfile
More file actions
188 lines (164 loc) Β· 8.27 KB
/
Copy pathjustfile
File metadata and controls
188 lines (164 loc) Β· 8.27 KB
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# SPDX-FileCopyrightText: 2026 PythonWoods <dev@pythonwoods.dev>
# SPDX-License-Identifier: Apache-2.0
#
# just β interactive developer workflow (Standard Documentation Workflow).
#
# Single source of truth for the quality pipeline. `just verify` is the
# atomic entry-point invoked by the pre-push hook AND by GitHub Actions:
# locale β‘ remote, no drift.
#
# Nox is reserved for isolated environments (multi-version compat).
#
# Quick reference:
# just sync β install / update all dependency groups
# just check β self-lint: run Zenzic on its own documentation
# just test β fast inner loop (pytest -n auto, NO coverage)
# just test-cov β audit run (serial pytest with coverage XML)
# just test-full β thorough Hypothesis profile (ci, multi-version via nox)
# just verify β Final Guard (pre-commit + test-cov + check)
# just clean β remove generated artefacts
set shell := ["bash", "-c"]
runner := "uv run --active"
nox_runner := "uv run nox -s"
# Keep BUILD_DATE deterministic across Ubuntu and Git Bash on Windows runners.
export BUILD_DATE := `date -u +'%Y/%m/%d'`
# ZENZIC_EXTRA_ARGS: allow runtime flag injection (e.g. --no-external)
ZENZIC_EXTRA_ARGS := env_var_or_default("ZENZIC_EXTRA_ARGS", "")
# βββ Workflow βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Install or update all dependency groups
sync:
uv sync --all-groups
# Self-linting: run Zenzic on its own documentation (core integrity check).
# ZRT-010 β Sovereign Parity: Pre-Launch Guard inlined; local == CI.
# Pass extra flags directly: just check --no-external
check *args:
#!/usr/bin/env bash
set -euo pipefail
{{ runner }} zenzic check all --strict {{ ZENZIC_EXTRA_ARGS }} {{ args }}
# Inner loop: ultra-fast, parallel, no coverage (TDD feedback).
# Pillar 3 (Pure Functions) guarantees pytest-xdist worker isolation.
# Excludes `slow` markers (e.g. ZRT-002 60s deadlock guard) β opt-in via `just test-slow`.
test *args:
{{ runner }} pytest -n auto -m "not slow" {{ args }}
# Opt-in: run slow tests (deadlock guards, long Hypothesis runs, etc.)
test-slow *args:
{{ runner }} pytest -m "slow" {{ args }}
# Audit: serial, deterministic, with coverage XML (pre-push gate + CI).
# Excludes @pytest.mark.slow β use test-cov-full for the complete suite.
# Coverage threshold (fail_under=80) enforced via pyproject.toml.
test-cov *args:
{{ runner }} pytest -m "not slow" --cov=src/zenzic --cov-report=term-missing --cov-report=json:coverage.json {{ args }}
# Full audit: includes slow tests (deadlock guards, 1k-file torture, Hypothesis ci).
# Run on Ubuntu only; reserved for pre-release validation.
test-cov-full *args:
{{ runner }} pytest --cov=src/zenzic --cov-report=term-missing --cov-report=json:coverage.json {{ args }}
# Run the test suite with the thorough Hypothesis profile (ci β 500 examples)
test-full *args:
HYPOTHESIS_PROFILE=ci {{ nox_runner }} tests {{ args }}
# βββ Quality Gates (4-Lifecycle-Gates model) ββββββββββββββββββββββββββββββββββ
# Fast linter pass: run all pre-commit hooks without the full test suite.
lint:
{{ runner }} pre-commit run --all-files
# Final Guard: atomic verification invoked by pre-push hook + GHA.
# Sequence: pre-commit (all hooks) β pytest tests/ β structural audit β score + stamp β badge freshness.
verify: _check-hooks release-contracts check-pinning docs-build
@echo "==> [1/5] Pre-commit hooks (lint, type-check, REUSE)..."
{{ runner }} pre-commit run --all-files
@echo "==> [2/5] Test suite..."
{{ runner }} pytest tests/
@echo "==> [3/5] Structural audit (zenzic check all --strict)..."
{{ runner }} zenzic check all --strict {{ ZENZIC_EXTRA_ARGS }}
@echo "==> [4/5] Score computation and badge stamp (zenzic score --stamp)..."
{{ runner }} zenzic score --stamp --ci
@echo "==> [5/5] Badge freshness gate..."
{{ runner }} zenzic score --check-stamp --ci
# ADR-089 β Immutable Infrastructure guard on local hooks (internal CI policy,
# not a public Zenzic linter rule). Pre-commit `rev:` keys must be 40-char
# commit SHAs, not mutable tags. Regex anchored to line-start so the
# `# vX.Y.Z` annotation comment is safe.
check-pinning:
#!/usr/bin/env bash
set -euo pipefail
echo "Validating Immutable Infrastructure (ADR-089)..."
if grep -E '^[[:space:]]*rev:[[:space:]]*v?[0-9]+\.[0-9]+' .pre-commit-config.yaml >/dev/null 2>&1; then
echo "[ADR-089] FATAL: Unpinned tag detected in pre-commit config. Zenzic internal policy requires SHA-256 pinning." >&2
grep -nE '^[[:space:]]*rev:[[:space:]]*v?[0-9]+\.[0-9]+' .pre-commit-config.yaml >&2
echo "π Update via: uvx pre-commit autoupdate --freeze" >&2
exit 1
fi
echo "β ADR-089: all pre-commit hooks pinned to immutable commit hashes."
_check-hooks:
#!/usr/bin/env bash
_missing=0
if [ ! -f .git/hooks/pre-commit ]; then
echo -e "\033[33mβ οΈ WARNING: pre-commit hook is not installed.\033[0m"
echo "Without it, linters and type-checks will NOT run automatically on git commit."
echo "π Fix it by running: uv run --active pre-commit install"
echo ""
_missing=1
fi
if [ ! -f .git/hooks/pre-push ]; then
echo -e "\033[33mβ οΈ WARNING: pre-push hook is not installed.\033[0m"
echo "Without it, you might accidentally push broken code to GitHub and fail the remote CI."
echo "π Fix it by running: uv run --active pre-commit install -t pre-push"
echo ""
_missing=1
fi
# Enforce release contracts: dirty allowed only in release-dry.
release-contracts:
#!/usr/bin/env bash
set -euo pipefail
grep -qE '^version:' justfile
grep -qE '^release part:' justfile
grep -qE '^release-dry part' justfile
grep -q -- '--dry-run --allow-dirty --verbose' justfile
if sed -n '/^release part:/,/^[^[:space:]].*:/p' justfile | tail -n +2 | grep -q -- '--allow-dirty'; then
echo "release-contracts failed: release part must not use --allow-dirty"
exit 1
fi
if sed -n '/^release part:/,/^[^[:space:]].*:/p' justfile | tail -n +2 | grep -qE 'git[[:space:]]+tag'; then
echo "release-contracts failed: release part must not create tags"
exit 1
fi
if ! grep -q 'git commit -S -s' justfile; then
echo "release-contracts failed: all git commits must use DCO (-s) and GPG signing (-S)"
exit 1
fi
# Release orchestration: explicit, transparent, and lockfile-first.
release part: release-contracts
#!/usr/bin/env bash
set -euo pipefail
case "{{ part }}" in
patch|minor|major) ;;
*) echo "Invalid part '{{ part }}'. Use patch|minor|major"; exit 2 ;;
esac
uv run --active bump-my-version bump {{ part }}
uv sync
version="$(uv run --active bump-my-version show current_version)"
git add -u
git commit -S -s -m "release: bump version to ${version}"
# Show the current project version
version:
@uv run --active bump-my-version show current_version
# Simulate a release bump without modifying any files
# Usage: just release-dry patch|minor|major [--short]
release-dry part *args:
#!/usr/bin/env bash
set -euo pipefail
_short=false
for _arg in {{args}}; do [[ "$_arg" == "--short" ]] && _short=true; done
if $_short; then
uv run --active bump-my-version bump {{part}} --dry-run --allow-dirty --verbose 2>&1 \
| grep -E 'current version|New version will be|Dry run'
else
uv run --active bump-my-version bump {{part}} --dry-run --allow-dirty --verbose
fi
# βββ Cleanup ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Remove generated artefacts (.nox is kept β reuse avoids reinstalling deps)
clean:
rm -rf dist/ .pytest_cache/ .hypothesis/ .zenzic-score.json coverage.json
# Serve the documentation site locally
docs-serve +args="":
uv run --extra docs mkdocs serve {{args}}
docs-build:
uv run --extra docs mkdocs build --strict