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
|
[tools]
lua = "5.4"
# `mise run deps` installs the rocks into ./.rocks (gitignored); `mise run check`
# puts that tree on package.path and runs the specs. Both pin --lua-version 5.4
# because a stray system luarocks may default to another Lua.
#
# Every rock below is pure Lua, so there is no system library to install first
# and nothing to point luarocks at.
[tasks.deps]
description = "Install the Lua rocks the extension and specs need into ./.rocks"
dir = "{{config_root}}"
run = """
set -e
luarocks --lua-version 5.4 --tree .rocks install api7-lua-tinyyaml
luarocks --lua-version 5.4 --tree .rocks install toml2lua
luarocks --lua-version 5.4 --tree .rocks install luv
luarocks --lua-version 5.4 --tree .rocks install dkjson
"""
# `mise run e2e` drives the REAL panto binary against the REAL rock through a
# scripted provider protocol (see e2e/run.lua). It is deliberately not a
# dependency of `check`: it needs the sibling pantograph checkout built, which a
# rock-only contributor has no reason to have. Point PANTO_REPO elsewhere, or
# PANTO_BIN straight at a binary, to skip the build.
[tasks.e2e]
description = "End-to-end: the real panto binary, the real rock, a scripted provider"
dir = "{{config_root}}"
run = """
set -e
PANTO_REPO="${PANTO_REPO:-$(cd .. && pwd)/pantograph}"
if [ -z "${PANTO_BIN:-}" ] && [ -d "$PANTO_REPO" ]; then
(cd "$PANTO_REPO" && mise exec -- zig build)
PANTO_BIN="$PANTO_REPO/zig-out/bin/panto"
fi
# The rock's lazily required dependencies (lyaml, toml2lua, dkjson) are handed
# to the embedded interpreter from this tree; see e2e/fixture.lua.
[ -d .rocks ] || mise run deps
PANTO_BIN="$PANTO_BIN" lua e2e/run.lua
"""
[tasks.check]
description = "Run the specs against ./.rocks"
dir = "{{config_root}}"
run = """
set -e
# Without the tree the specs still pass, but every case that needs a rock skips
# itself; install once rather than reporting a green run that tested less.
[ -d .rocks ] || mise run deps
eval "$(luarocks --lua-version 5.4 --tree .rocks path)"
lua spec/run.lua
"""
[tasks.version]
description = "Rewrite the rockspec for a new version (then commit it)"
dir = "{{config_root}}"
run = """
set -eu
NEW="{{arg(name='version')}}"
SPEC="$(ls -1 ./*.rockspec)"
case "$SPEC" in *"
"*) echo "expected exactly one rockspec, found:" >&2; echo "$SPEC" >&2; exit 1;; esac
PKG="$(sed -n 's/^package = "\\(.*\\)"/\\1/p' "$SPEC")"
NEWSPEC="./$PKG-$NEW-1.rockspec"
# Write through a temp file: without it, a re-run at the same version would
# have the redirect truncate the file sed is still reading.
TMP="$(mktemp)"
sed -e "s/^version = \\".*\\"/version = \\"$NEW-1\\"/" \\
-e "s/^\\( *\\)tag = \\"v[^\\"]*\\"/\\1tag = \\"v$NEW\\"/" "$SPEC" > "$TMP"
mv "$TMP" "$NEWSPEC"
[ "$SPEC" = "$NEWSPEC" ] || rm -f "$SPEC"
luarocks lint "$NEWSPEC"
echo "wrote $NEWSPEC -- commit it, then: mise run release"
"""
[tasks.release]
description = "Tag the committed version, push the tag, upload to luarocks.org"
depends = ["check"]
dir = "{{config_root}}"
run = """
set -eu
SPEC="$(ls -1 ./*.rockspec)"
case "$SPEC" in *"
"*) echo "expected exactly one rockspec, found:" >&2; echo "$SPEC" >&2; exit 1;; esac
VER="$(sed -n 's/^version = "\\(.*\\)-[0-9]*"/\\1/p' "$SPEC")"
[ -n "$VER" ] || { echo "could not read version from $SPEC" >&2; exit 1; }
TAG="v$VER"
# jj's working copy is itself a commit, so @ is normally the empty commit a
# `jj new` just made and the release content sits in @-. Override with
# REV=@ (or any revset) when that is not the case.
REV="${REV:-@-}"
# The tag is what `luarocks upload` clones to build the .src.rock, so the
# rockspec being published has to already be in the revision being tagged.
# Uncommitted, they diverge silently: the upload would ship a rockspec that
# says $VER over sources from a commit that never had it.
if ! jj file show -r "$REV" "$SPEC" 2>/dev/null | diff -q - "$SPEC" >/dev/null 2>&1; then
echo "$SPEC at $REV differs from the working copy -- commit it first" >&2
exit 1
fi
if jj tag list | grep -q "^$TAG:"; then
echo "tag $TAG already exists -- bump the version first" >&2
exit 1
fi
# jj 0.42 creates tags natively and exports them to git in a colocated repo,
# but `jj git push` only pushes bookmarks -- tags still need git.
jj tag set "$TAG" -r "$REV"
jj tag list | grep "^$TAG:"
for remote in $(git remote); do
git push "$remote" "$TAG"
done
# Reads the API key from ~/.luarocks/upload_config.lua. Packs a .src.rock by
# cloning source.url at the tag just pushed, so the push has to come first.
luarocks upload "$SPEC"
"""
|