-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
65 lines (57 loc) · 2.89 KB
/
Copy pathjustfile
File metadata and controls
65 lines (57 loc) · 2.89 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
wasm := "target/wasm32-wasip2/release/component_postgres.wasm"
# OCI reference to publish to (registry/namespace/name, no tag). Override with OCI_REF.
component_ref := env("OCI_REF", "actpkg.dev/library/postgres")
act := env("ACT", "npx @actcore/act")
actbuild := env("ACT_BUILD", "npx @actcore/act-build")
hurl := env("HURL", "hurl")
# Random port for the e2e server, in a safe range: above the well-known/common
# dev ports and below the Linux outbound ephemeral range (32768+).
port := `shuf -i 10000-19999 -n 1`
addr := "[::1]:" + port
baseurl := "http://" + addr
# Second server port for the read-only enforcement test (disjoint range from `port`).
port2 := `shuf -i 20000-29999 -n 1`
addr2 := "[::1]:" + port2
baseurl2 := "http://" + addr2
# Fetch WIT deps from the registry (ghcr.io/actcore) into wit/deps/.
# wkg-registry.toml maps the act namespace -> actcore.dev (well-known -> ghcr.io/actcore).
init:
WKG_CONFIG_FILE=wkg-registry.toml wkg wit fetch --type wit
setup: init
prek install
build:
cargo build --release
# Embed act:component metadata and act:skill into the wasm.
pack: build
{{actbuild}} pack {{wasm}}
test: pack
#!/usr/bin/env bash
set -euo pipefail
docker compose up -d --wait
SA_FULL='{"host":"127.0.0.1","port":5434,"user":"postgres","password":"postgres","dbname":"postgres","sslmode":"disable","mode":"full"}'
SA_RO='{"host":"127.0.0.1","port":5434,"user":"postgres","password":"postgres","dbname":"postgres","sslmode":"disable","mode":"read-only"}'
{{act}} run {{wasm}} --http --listen "{{addr}}" --allow wasi:sockets --session-args "$SA_FULL" &
PID=$!
{{act}} run {{wasm}} --http --listen "{{addr2}}" --allow wasi:sockets --session-args "$SA_RO" &
PID2=$!
trap "kill $PID $PID2 2>/dev/null || true; docker compose down -v" EXIT
curl --retry 60 --retry-connrefused --retry-delay 1 -fsS -o /dev/null {{baseurl}}/info
curl --retry 60 --retry-connrefused --retry-delay 1 -fsS -o /dev/null {{baseurl2}}/info
# Each e2e file is self-contained (creates its own table), so they are safe
# under hurl's default parallel --test execution — no shared setup needed.
{{hurl}} --test --variable "baseurl={{baseurl}}" e2e/info.hurl e2e/list_tools.hurl e2e/query_execute.hurl e2e/introspection.hurl e2e/explain.hurl
{{hurl}} --test --variable "baseurl={{baseurl2}}" e2e/readonly.hurl
publish: pack
#!/usr/bin/env bash
set -euo pipefail
INFO=$({{act}} inspect component-manifest {{wasm}})
VERSION=$(echo "$INFO" | jq -r .std.version)
OUTPUT=$({{actbuild}} push {{wasm}} "{{component_ref}}:$VERSION" \
--skip-if-exists \
--also-tag latest 2>&1) || { echo "$OUTPUT" >&2; exit 1; }
echo "$OUTPUT"
DIGEST=$(echo "$OUTPUT" | grep "^Digest:" | awk '{print $2}' || true)
if [ -n "${GITHUB_OUTPUT:-}" ]; then
echo "image={{component_ref}}" >> "$GITHUB_OUTPUT"
echo "digest=$DIGEST" >> "$GITHUB_OUTPUT"
fi