upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/ci/scripts/run_pipeline.sh
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-23 23:31:31 +0530
committerYour Name <you@example.com>2026-05-23 23:31:31 +0530
commitcfa17135a034207f4005f754a94093ebc3d547d2 (patch)
tree1c4a3d93b27d273b58be636cdafabf202b50bfa7 /ci/scripts/run_pipeline.sh
parent85ef20a2004c600dd04428520a79a0e47a54ed2d (diff)
ci: add Ansible CI/CD workflow with nostr relay listener
- ci_listener.py: WebSocket client subscribed to ngit.orangesync.tech for NIP-34 git state events (kind 30617), triggers pipeline on push - run_pipeline.sh: clone + make test-unit + Docker ESP-IDF build - systemd service: tollgate-ci-listener with auto-restart - Ansible role ci_runner: Docker, ESP-IDF image, listener deployment - 20-ci-runner.yml: playbook for CI runner setup - 30-hardware-tests.yml: playbook for localhost board testing
Diffstat (limited to 'ci/scripts/run_pipeline.sh')
-rwxr-xr-xci/scripts/run_pipeline.sh80
1 files changed, 80 insertions, 0 deletions
diff --git a/ci/scripts/run_pipeline.sh b/ci/scripts/run_pipeline.sh
new file mode 100755
index 0000000..2bef754
--- /dev/null
+++ b/ci/scripts/run_pipeline.sh
@@ -0,0 +1,80 @@
1#!/bin/bash
2# CI pipeline for esp32-tollgate
3# Triggered by ci_listener.py on NIP-34 push events
4set -euo pipefail
5
6BRANCH="${CI_BRANCH:-feature/tollgate-core-v2}"
7REPO_DIR="/tmp/ci-esp32-tollgate"
8LOG_FILE="/tmp/ci-esp32-tollgate-pipeline.log"
9RESULT_FILE="/tmp/ci-esp32-tollgate-result.txt"
10
11echo "=== CI Pipeline Start ===" | tee "$LOG_FILE"
12echo "Branch: $BRANCH" | tee -a "$LOG_FILE"
13echo "Time: $(date -Iseconds)" | tee -a "$LOG_FILE"
14
15# Clone or update
16if [ -d "$REPO_DIR" ]; then
17 echo "Updating existing clone..." | tee -a "$LOG_FILE"
18 git -C "$REPO_DIR" fetch --all 2>&1 | tee -a "$LOG_FILE" || true
19 git -C "$REPO_DIR" checkout "$BRANCH" 2>&1 | tee -a "$LOG_FILE" || true
20 git -C "$REPO_DIR" reset --hard "origin/$BRANCH" 2>&1 | tee -a "$LOG_FILE" || true
21else
22 echo "Cloning repository..." | tee -a "$LOG_FILE"
23 mkdir -p "$(dirname "$REPO_DIR")"
24 git clone --branch "$BRANCH" \
25 "nostr://npub12m5exm2uk3xa674cc5r0hlyvccs5xxn7qv83ezuteefv5972nquq4j4szl/ngit.orangesync.tech/esp32-tollgate" \
26 "$REPO_DIR" 2>&1 | tee -a "$LOG_FILE"
27fi
28
29cd "$REPO_DIR"
30
31# Init submodules
32echo "=== Initializing submodules ===" | tee -a "$LOG_FILE"
33git submodule update --init --recursive 2>&1 | tee -a "$LOG_FILE" || true
34
35# Run host unit tests
36echo "=== Running unit tests ===" | tee -a "$LOG_FILE"
37if make test-unit 2>&1 | tee -a "$LOG_FILE"; then
38 echo "UNIT_TESTS=PASS" | tee -a "$LOG_FILE"
39 UNIT_RESULT="PASS"
40else
41 echo "UNIT_TESTS=FAIL" | tee -a "$LOG_FILE"
42 UNIT_RESULT="FAIL"
43fi
44
45# ESP-IDF build (in Docker)
46echo "=== ESP-IDF Build ===" | tee -a "$LOG_FILE"
47if command -v docker &>/dev/null; then
48 docker run --rm \
49 -v "$REPO_DIR:/project" \
50 -w /project \
51 espressif/idf:latest \
52 bash -c "idf.py build 2>&1" | tee -a "$LOG_FILE"
53 BUILD_RC=${PIPESTATUS[0]:-1}
54else
55 echo "Docker not available, skipping ESP-IDF build" | tee -a "$LOG_FILE"
56 BUILD_RC=0
57fi
58
59if [ "$BUILD_RC" -eq 0 ]; then
60 echo "IDF_BUILD=PASS" | tee -a "$LOG_FILE"
61 BUILD_RESULT="PASS"
62else
63 echo "IDF_BUILD=FAIL" | tee -a "$LOG_FILE"
64 BUILD_RESULT="FAIL"
65fi
66
67# Summary
68echo "=== Summary ===" | tee -a "$LOG_FILE"
69echo "Unit tests: $UNIT_RESULT" | tee -a "$LOG_FILE"
70echo "IDF build: $BUILD_RESULT" | tee -a "$LOG_FILE"
71
72if [ "$UNIT_RESULT" = "PASS" ] && [ "$BUILD_RESULT" = "PASS" ]; then
73 echo "OVERALL=PASS" | tee -a "$LOG_FILE"
74 echo "PASS" > "$RESULT_FILE"
75 exit 0
76else
77 echo "OVERALL=FAIL" | tee -a "$LOG_FILE"
78 echo "FAIL" > "$RESULT_FILE"
79 exit 1
80fi