Repository navigation
Expand file tree
/
Copy pathJustfile
More file actions
147 lines (119 loc) · 4.63 KB
/
Copy pathJustfile
File metadata and controls
147 lines (119 loc) · 4.63 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
# One set of recipes for local development and CI: `just check` before a
# commit, `just ci` is what the Linux CI job runs.
# Build the CLI into the checkout.
default: build
# A checkout build never shadows an installed release by accident.
# Build driga into ./bin, which is not on PATH.
build:
#!/usr/bin/env bash
set -euo pipefail
# --long keeps the commit suffix on a tagged commit, so a checkout build
# never passes for a release.
version=$(git describe --tags --always --dirty --long 2>/dev/null || echo dev)
mkdir -p bin
CGO_ENABLED=0 go build -trimpath \
-ldflags "-s -w -X main.version=${version} -X main.commit=$(git rev-parse HEAD) -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-o bin/driga ./cmd/driga
echo "built bin/driga (${version})"
# Put the built binary on PATH, deliberately; it may shadow an installed release.
install: build
#!/usr/bin/env bash
set -euo pipefail
dir="${DRIGA_INSTALL_DIR:-${HOME}/.local/bin}"
mkdir -p "$dir"
install -m 0755 bin/driga "$dir/driga"
echo "installed $dir/driga ($("$dir/driga" version | head -1)); first on PATH: $(command -v driga)"
# Remove the checkout build (never the copy on PATH).
clean:
rm -rf bin dist
# ---------- Verification ----------
# Local pre-commit gate.
check: _fmt-check tidy-check vet generate-check docs-check test
@echo "All checks passed"
# Adds race, vulnerability, workflow and release-snapshot checks.
# What the Linux CI job runs.
ci: check race vuln workflow-check snapshot
@echo "CI checks passed"
# Format all Go packages.
fmt:
gofmt -w .
# gofmt prints nothing both for a clean tree and for a file it cannot parse,
# so its exit status is checked separately from its output.
[private]
_fmt-check:
#!/usr/bin/env bash
set -euo pipefail
if ! unformatted="$(gofmt -l .)"; then
echo "gofmt could not read the tree (see the errors above)" >&2
exit 1
fi
if [[ -n "$unformatted" ]]; then
echo "Unformatted files:" >&2
echo "$unformatted" >&2
exit 1
fi
# Fail when go.mod or go.sum is not tidy.
tidy-check:
go mod tidy -diff
# Vet natively and for Windows, which has its own build-tagged files.
vet:
go vet ./...
GOOS=windows go vet ./...
# Fail when the committed .env.example is behind the settings table.
generate-check:
go generate ./internal/config
git diff --exit-code -- .env.example
# Rewrite the generated reference pages under site/ from the code.
docs:
go run ./cmd/driga-docgen
# Fail when a committed reference page is behind the code it documents.
docs-check:
go run ./cmd/driga-docgen --check
# ---------- Documentation site ----------
# Install the site's dependencies from the lockfile.
site-deps:
cd site && npm ci --no-audit --no-fund
# Serve the site locally with live reload on http://localhost:7431.
site: docs site-deps
cd site && npm run dev
# Re-record site footage of the real TUI on demo data (needs vhs, ffmpeg).
site-footage:
site/footage/record.sh
# Publish the rendered footage to R2 (assets.driga.dev) and update the manifest.
site-footage-publish:
cd site/footage && node upload.mjs
# Build the site into site/dist: astro check, build, then the output checks.
# Depends on the checking recipe, not the writing one, so it cannot hide a stale page.
site-build: docs-check site-deps
cd site && npm run build
# Run tests with a disposable home and Driga data (scripts/isolated.sh).
test *args:
scripts/isolated.sh go test {{ args }} ./...
# Some tests change their budgets under -race (race_on/race_off).
# Run the suite under the race detector.
race:
CGO_ENABLED=1 scripts/isolated.sh go test -race ./...
# Run the suite in UTC, as CI runners do.
test-utc:
TZ=UTC scripts/isolated.sh go test -count=1 ./...
# Windows end-to-end suite (run on Windows; CI runs it as its own job).
e2e:
scripts/isolated.sh go test -tags e2e ./internal/e2e -v -timeout 25m
# Scan reachable code against the Go vulnerability database.
vuln:
govulncheck ./...
# actionlint silently skips the shell in run: blocks without shellcheck.
# Lint GitHub workflows, including their shell.
workflow-check:
#!/usr/bin/env bash
set -euo pipefail
command -v shellcheck >/dev/null || { echo "shellcheck is not installed; actionlint would skip every run: block" >&2; exit 1; }
actionlint
# Build every release target without publishing, signing or notarizing.
snapshot:
goreleaser check
goreleaser release --snapshot --clean --skip=publish,sign,notarize
scripts/verify-release-dist.sh dist
# Create and publish the next vYYYY.M.REVISION-alpha tag from releasable main.
release:
scripts/release.sh