-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
128 lines (111 loc) · 4.42 KB
/
Taskfile.yaml
File metadata and controls
128 lines (111 loc) · 4.42 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
version: '3'
tasks:
# test:
# desc: |
# Run the unit test suite via gavel, mirroring the `test` job in
# .github/workflows/test.yaml. Excludes the heavy benchmark, generator,
# spec, and e2e packages so it matches CI scope.
#
# Anything after `--` is passed straight through to gavel, so:
# task test -- --focus "MyFlow"
# task test -- ./query --extra-args=--ginkgo.label-filter=focus
# task test -- --dry-run
# Without extra args, runs every unit package matching CI.
# cmds:
# - |
# gavel test --timeout 30m --test-timeout 15m \
# --ignore ./bench \
# --ignore ./hack \
# --ignore ./specs \
# --ignore ./tests/e2e \
# --ignore ./tests/e2e-blobs \
# {{if .CLI_ARGS}}{{.CLI_ARGS}}{{else}}./...{{end}}
test:migrate:
desc: |
Mirrors the `migrate` job in .github/workflows/test.yaml using an
embedded postgres. Runs the hack/migrate-e2e orchestrator, which
spins up embedded postgres, applies base migrations from origin/main
(via a git worktree + the hack/migrate binary built from main's
code), then re-applies migrations from the current working tree to
validate the upgrade path. No external database required.
cmds:
- go run ./hack/migrate-e2e {{.CLI_ARGS}}
test:bench:
desc: |
Mirrors the benchmark workflow in .github/workflows/benchmark.yml.
Compares the current working tree against a base revision, runs both
`Other` and `RLS` benchmark suites, generates benchstat output +
summaries under .bench/results/, and fails if regressions exceed the
threshold. Defaults:
BASE_REF=$(git merge-base HEAD origin/main)
BENCH_SIZES=15000
COUNT=6
TIMEOUT=20m
THRESHOLD=5
Extra go test args can be passed with `task test:bench -- ...`.
cmds:
- |
set -eu
ROOT="$(pwd)"
BASE_REF="${BASE_REF:-$(git merge-base HEAD origin/main)}"
BENCH_SIZES="${BENCH_SIZES:-15000}"
COUNT="${COUNT:-6}"
TIMEOUT="${TIMEOUT:-20m}"
THRESHOLD="${THRESHOLD:-5}"
EXTRA_GO_TEST_ARGS="{{.CLI_ARGS}}"
BASE_DIR="$ROOT/.bench/base"
RESULTS_DIR="$ROOT/.bench/results"
BENCHSTAT_BIN="$ROOT/.bin/benchstat"
SUMMARY_SCRIPT="$ROOT/.github/scripts/benchstat-summary.py"
git rev-parse --verify "$BASE_REF^{commit}" >/dev/null
mkdir -p "$ROOT/.bin" "$RESULTS_DIR"
GOBIN="$ROOT/.bin" go install golang.org/x/perf/cmd/benchstat@latest
cleanup() {
git worktree remove --force "$BASE_DIR" >/dev/null 2>&1 || true
}
trap cleanup EXIT INT TERM
git worktree remove --force "$BASE_DIR" >/dev/null 2>&1 || true
mkdir -p "$ROOT/.bench"
git worktree add "$BASE_DIR" "$BASE_REF"
rm -rf "$BASE_DIR/bench"
cp -r "$ROOT/bench" "$BASE_DIR/bench"
run_suite() {
label="$1"
bench_args="$2"
suite_dir="$RESULTS_DIR/$label"
base_out="$suite_dir/bench-base.txt"
head_out="$suite_dir/bench-head.txt"
stat_out="$suite_dir/benchstat.txt"
summary_out="$suite_dir/bench-summary.md"
mkdir -p "$suite_dir"
echo "==> Benchmark ($label)"
echo "Base: $BASE_REF"
echo "Head: $(git rev-parse HEAD)"
echo
cd "$BASE_DIR"
if ! DUTY_BENCH_SIZES="$BENCH_SIZES" \
go test $bench_args -count="$COUNT" -timeout "$TIMEOUT" \
github.com/flanksource/duty/bench $EXTRA_GO_TEST_ARGS >"$base_out" 2>&1; then
cat "$base_out"
return 1
fi
cat "$base_out"
cd "$ROOT"
if ! DUTY_BENCH_SIZES="$BENCH_SIZES" \
go test $bench_args -count="$COUNT" -timeout "$TIMEOUT" \
github.com/flanksource/duty/bench $EXTRA_GO_TEST_ARGS >"$head_out" 2>&1; then
cat "$head_out"
return 1
fi
cat "$head_out"
"$BENCHSTAT_BIN" "$base_out" "$head_out" >"$stat_out"
if ! python3 "$SUMMARY_SCRIPT" "$stat_out" >"$summary_out"; then
cat "$summary_out"
else
cat "$summary_out"
fi
python3 "$SUMMARY_SCRIPT" --threshold "$THRESHOLD" "$stat_out" >/dev/null
echo
}
run_suite other "-bench=. -skip=BenchmarkRLS"
run_suite rls "-bench=BenchmarkRLS"