-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
76 lines (62 loc) · 1.95 KB
/
Justfile
File metadata and controls
76 lines (62 loc) · 1.95 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
set dotenv-load := false
# List available recipes
default:
@just --list
# Run all quality checks: linting, tests, and coverage threshold
qa: lint test-coverage-gate
# Run all linters in parallel
lint:
@echo -n 'cs-fixer phpstan rector' | parallel --will-cite --halt now,fail=1 --delimiter=' ' just lint-{}
# Check code style (PSR-12)
lint-cs-fixer:
php-cs-fixer fix --diff --verbose --dry-run
# Run static analysis
lint-phpstan:
phpstan analyse
# Check for Rector refactoring opportunities
lint-rector:
rector --dry-run
# Auto-fix code style
format:
php-cs-fixer fix --diff --verbose
# Apply Rector refactorings
format-rector:
rector
# Run tests
test:
phpunit
# Run tests with coverage report
test-coverage:
phpunit --coverage-text --coverage-html=var/coverage
# Run tests with coverage and fail if line coverage is below threshold
[private]
test-coverage-gate:
#!/usr/bin/env bash
set -euo pipefail
threshold=85
output=$(phpunit --coverage-text --coverage-clover=var/coverage.xml 2>&1)
echo "$output"
# Extract the "Lines:" percentage from coverage summary
coverage=$(echo "$output" | grep -oP 'Lines:\s+\K[0-9]+(?:\.[0-9]+)?' | head -1)
if [ -z "$coverage" ]; then
echo "ERROR: Could not parse line coverage from PHPUnit output."
exit 1
fi
# Compare using bc for float comparison
below=$(echo "$coverage < $threshold" | bc -l)
if [ "$below" -eq 1 ]; then
echo ""
echo "FAILED: Line coverage ${coverage}% is below the ${threshold}% threshold."
exit 1
fi
echo ""
echo "OK: Line coverage ${coverage}% meets the ${threshold}% threshold."
# Generate API documentation
docs:
docker run --rm --user "$(id -u):$(id -g)" -v $(pwd):/data phpdoc/phpdoc:3 run --setting="guides.enabled=true"
# Download fresh W3C spec files
update-specs:
php bin/update-specs.php
# Run code generation from W3C specs
generate: update-specs
php bin/generate.php