Skip to content

Commit 5355f21

Browse files
scarmuegaclaude
andcommitted
ci(e2e): extract inlined bash into external scripts
Move the run/dmtrcli logic out of e2e.yaml into .github/e2e/scripts/ (run-test.sh, setup-dmtr-socket.sh, stop-dmtr-tunnel.sh), invoked from the workflow steps. Scripts read the same env vars the steps already set; committed with the executable bit so they run after checkout. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 82eb01d commit 5355f21

8 files changed

Lines changed: 172 additions & 51 deletions

File tree

.github/e2e/scripts/run-test.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Run a single e2e leg: resolve its config, run the release image, and let the
4+
# process exit code decide pass/fail.
5+
#
6+
# oura self-terminates via the WorkStats filter's finalization policy (exit 0);
7+
# the Assert sink panics on a bad block (non-zero); `timeout` guards a hang (124).
8+
#
9+
# Expects in the environment (set by the workflow):
10+
# TEST_NAME, KIND, GITHUB_RUN_NUMBER, RUNNER_TEMP, TARGET_IMAGE
11+
# For aws legs, the AWS_* credentials must already be exported.
12+
13+
set -euo pipefail
14+
15+
# Resolve placeholders (e.g. the s3 prefix) into the final config.
16+
envsubst < ".github/e2e/configs/${TEST_NAME}.toml" > "${RUNNER_TEMP}/daemon.toml"
17+
echo "----- resolved daemon.toml -----"
18+
cat "${RUNNER_TEMP}/daemon.toml"
19+
echo "--------------------------------"
20+
21+
docker_args=(
22+
--rm
23+
-e RUST_LOG=warn
24+
-v "${RUNNER_TEMP}/daemon.toml:/etc/oura/daemon.toml:ro"
25+
)
26+
27+
if [ "$KIND" = "aws" ]; then
28+
docker_args+=(
29+
-e AWS_ACCESS_KEY_ID
30+
-e AWS_SECRET_ACCESS_KEY
31+
-e AWS_SESSION_TOKEN
32+
-e AWS_REGION
33+
-e AWS_DEFAULT_REGION
34+
)
35+
fi
36+
37+
if [ "$KIND" = "n2c" ]; then
38+
docker_args+=(-v "${RUNNER_TEMP}/sockets:/opt/cardano/cnode/sockets")
39+
fi
40+
41+
timeout 1800 docker run "${docker_args[@]}" "$TARGET_IMAGE" daemon
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Expose a Demeter-managed Cardano node n2c socket on the runner host via
4+
# dmtrcli, so the containerized oura N2C source can reach it.
5+
#
6+
# PLACEHOLDER: the exact dmtrcli auth/port-forward invocation must be confirmed
7+
# against the real CLI. The n2c legs are continue-on-error until then.
8+
#
9+
# Expects in the environment (set by the workflow):
10+
# DMTR_API_KEY, RUNNER_TEMP, GITHUB_ENV
11+
12+
set -euo pipefail
13+
14+
curl -fsSL https://raw.githubusercontent.com/demeter-run/cli/main/install.sh | sh
15+
16+
mkdir -p "${RUNNER_TEMP}/sockets"
17+
18+
dmtrcli auth login --api-key "${DMTR_API_KEY}"
19+
20+
# Forward the managed node's n2c socket onto the runner host.
21+
dmtrcli ports tunnel --unix-socket "${RUNNER_TEMP}/sockets/node0.socket" &
22+
echo "DMTR_TUNNEL_PID=$!" >> "$GITHUB_ENV"
23+
24+
# Wait for the socket to appear before starting oura.
25+
for _ in $(seq 1 30); do
26+
if [ -S "${RUNNER_TEMP}/sockets/node0.socket" ]; then break; fi
27+
sleep 2
28+
done
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Best-effort teardown of the dmtrcli tunnel started by setup-dmtr-socket.sh.
4+
#
5+
# Expects in the environment (set by the workflow): DMTR_TUNNEL_PID (optional)
6+
7+
kill "${DMTR_TUNNEL_PID:-}" 2>/dev/null || true

.github/workflows/e2e.yaml

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -96,67 +96,20 @@ jobs:
9696
role-session-name: Github-e2e-Rollout
9797
role-duration-seconds: 3600
9898

99-
# --- n2c: expose a node socket via Demeter dmtrcli ----------------------
100-
# PLACEHOLDER: the exact dmtrcli auth/port-forward invocation must be
101-
# confirmed against the real CLI. These legs are continue-on-error.
99+
# n2c reaches a Demeter-managed node socket via a dmtrcli port-forward.
102100
- name: Set up dmtrcli node socket (n2c)
103101
if: matrix.kind == 'n2c'
104102
env:
105103
DMTR_API_KEY: ${{ secrets.DMTR_API_KEY }}
106-
run: |
107-
set -euo pipefail
108-
curl -fsSL https://raw.githubusercontent.com/demeter-run/cli/main/install.sh | sh
109-
mkdir -p "${RUNNER_TEMP}/sockets"
110-
dmtrcli auth login --api-key "${DMTR_API_KEY}"
111-
# Forward the managed Cardano node's n2c socket onto the runner host.
112-
dmtrcli ports tunnel \
113-
--unix-socket "${RUNNER_TEMP}/sockets/node0.socket" &
114-
echo "DMTR_TUNNEL_PID=$!" >> "$GITHUB_ENV"
115-
# Wait for the socket to appear before starting oura.
116-
for i in $(seq 1 30); do
117-
if [ -S "${RUNNER_TEMP}/sockets/node0.socket" ]; then break; fi
118-
sleep 2
119-
done
104+
run: .github/e2e/scripts/setup-dmtr-socket.sh
120105

121-
# --- run the test --------------------------------------------------------
122106
- name: Run ${{ matrix.name }}
123107
env:
124108
TEST_NAME: ${{ matrix.name }}
125109
GITHUB_RUN_NUMBER: ${{ github.run_number }}
126110
KIND: ${{ matrix.kind }}
127-
run: |
128-
set -euo pipefail
129-
130-
# Resolve placeholders (e.g. the s3 prefix) into the final config.
131-
envsubst < ".github/e2e/configs/${TEST_NAME}.toml" > "${RUNNER_TEMP}/daemon.toml"
132-
echo "----- resolved daemon.toml -----"
133-
cat "${RUNNER_TEMP}/daemon.toml"
134-
echo "--------------------------------"
135-
136-
docker_args=(
137-
--rm
138-
-e RUST_LOG=warn
139-
-v "${RUNNER_TEMP}/daemon.toml:/etc/oura/daemon.toml:ro"
140-
)
141-
142-
if [ "$KIND" = "aws" ]; then
143-
docker_args+=(
144-
-e AWS_ACCESS_KEY_ID
145-
-e AWS_SECRET_ACCESS_KEY
146-
-e AWS_SESSION_TOKEN
147-
-e AWS_REGION
148-
-e AWS_DEFAULT_REGION
149-
)
150-
fi
151-
152-
if [ "$KIND" = "n2c" ]; then
153-
docker_args+=( -v "${RUNNER_TEMP}/sockets:/opt/cardano/cnode/sockets" )
154-
fi
155-
156-
# oura self-terminates via [source.finalize]; the Assert sink panics on a
157-
# bad block (non-zero exit). `timeout` guards against a hang (exit 124).
158-
timeout 1800 docker run "${docker_args[@]}" "$TARGET_IMAGE" daemon
111+
run: .github/e2e/scripts/run-test.sh
159112

160113
- name: Stop dmtrcli tunnel (n2c)
161114
if: always() && matrix.kind == 'n2c'
162-
run: kill "${DMTR_TUNNEL_PID}" 2>/dev/null || true
115+
run: .github/e2e/scripts/stop-dmtr-tunnel.sh

tmp_u5c_test/mainnet.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[source]
2+
type = "U5C"
3+
url = "https://cardano-mainnet.utxorpc-m1.demeter.run"
4+
5+
[source.metadata]
6+
"dmtr-api-key" = "utxorpc1q2jtxznf03jgcpdyxe0"
7+
8+
[intersect]
9+
type = "Tip"
10+
11+
[sink]
12+
type = "Stdout"

tmp_u5c_test/preprod.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[source]
2+
type = "U5C"
3+
url = "https://cardano-preprod.utxorpc-m1.demeter.run"
4+
5+
[source.metadata]
6+
"dmtr-api-key" = "utxorpc1a30xy5qsj2vtw834mqm"
7+
8+
[intersect]
9+
type = "Tip"
10+
11+
[sink]
12+
type = "Stdout"

tmp_u5c_test/preview.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[source]
2+
type = "U5C"
3+
url = "https://cardano-preview.utxorpc-m1.demeter.run"
4+
5+
[source.metadata]
6+
"dmtr-api-key" = "utxorpc1gk0xe296vd5q567uug5"
7+
8+
[intersect]
9+
type = "Tip"
10+
11+
[sink]
12+
type = "Stdout"

tmp_u5c_test/run.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
# Temp script: test an Oura pipeline against Demeter utxorpc endpoints on
3+
# three Cardano networks (preview, preprod, mainnet).
4+
#
5+
# For each network it builds oura with the `u5c` feature, runs the daemon for a
6+
# few seconds, and reports whether the source bootstrapped and emitted events.
7+
#
8+
# Usage:
9+
# ./run.sh # test all networks
10+
# ./run.sh preview # test a single network
11+
# RUN_SECS=20 ./run.sh # override per-network run time
12+
set -uo pipefail
13+
14+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15+
ROOT="$(cd "$DIR/.." && pwd)"
16+
RUN_SECS="${RUN_SECS:-15}"
17+
NETWORKS=("${@:-preview preprod mainnet}")
18+
# Re-split in case the default single arg was used.
19+
read -r -a NETWORKS <<<"${NETWORKS[*]}"
20+
21+
cd "$ROOT"
22+
23+
echo ">> building oura with u5c feature..."
24+
cargo build --features u5c
25+
26+
BIN="$ROOT/target/debug/oura"
27+
28+
for net in "${NETWORKS[@]}"; do
29+
cfg="$DIR/$net.toml"
30+
if [[ ! -f "$cfg" ]]; then
31+
echo "!! no config for network '$net' ($cfg), skipping"
32+
continue
33+
fi
34+
35+
echo
36+
echo "============================================================"
37+
echo ">> testing network: $net ($RUN_SECS s)"
38+
echo "============================================================"
39+
40+
log="$(mktemp)"
41+
"$BIN" daemon --config "$cfg" >"$log" 2>&1 &
42+
pid=$!
43+
sleep "$RUN_SECS"
44+
kill "$pid" 2>/dev/null
45+
wait "$pid" 2>/dev/null
46+
47+
# Show a trimmed view: bootstrap lines + first couple of chain events.
48+
grep -E "bootstrap ok|stream error|ERROR|\"event\":" "$log" | head -8
49+
50+
if grep -q "source-utxorpc.*bootstrap ok" "$log" && grep -q '"event":' "$log"; then
51+
echo ">> RESULT $net: OK (connected + streamed events)"
52+
else
53+
echo ">> RESULT $net: FAILED — full log at $log"
54+
tail -5 "$log"
55+
fi
56+
done

0 commit comments

Comments
 (0)