diff options
| author | Your Name <you@example.com> | 2026-05-23 23:31:31 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-23 23:31:31 +0530 |
| commit | cfa17135a034207f4005f754a94093ebc3d547d2 (patch) | |
| tree | 1c4a3d93b27d273b58be636cdafabf202b50bfa7 /ci/scripts/run_pipeline.sh | |
| parent | 85ef20a2004c600dd04428520a79a0e47a54ed2d (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-x | ci/scripts/run_pipeline.sh | 80 |
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 | ||
| 4 | set -euo pipefail | ||
| 5 | |||
| 6 | BRANCH="${CI_BRANCH:-feature/tollgate-core-v2}" | ||
| 7 | REPO_DIR="/tmp/ci-esp32-tollgate" | ||
| 8 | LOG_FILE="/tmp/ci-esp32-tollgate-pipeline.log" | ||
| 9 | RESULT_FILE="/tmp/ci-esp32-tollgate-result.txt" | ||
| 10 | |||
| 11 | echo "=== CI Pipeline Start ===" | tee "$LOG_FILE" | ||
| 12 | echo "Branch: $BRANCH" | tee -a "$LOG_FILE" | ||
| 13 | echo "Time: $(date -Iseconds)" | tee -a "$LOG_FILE" | ||
| 14 | |||
| 15 | # Clone or update | ||
| 16 | if [ -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 | ||
| 21 | else | ||
| 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" | ||
| 27 | fi | ||
| 28 | |||
| 29 | cd "$REPO_DIR" | ||
| 30 | |||
| 31 | # Init submodules | ||
| 32 | echo "=== Initializing submodules ===" | tee -a "$LOG_FILE" | ||
| 33 | git submodule update --init --recursive 2>&1 | tee -a "$LOG_FILE" || true | ||
| 34 | |||
| 35 | # Run host unit tests | ||
| 36 | echo "=== Running unit tests ===" | tee -a "$LOG_FILE" | ||
| 37 | if make test-unit 2>&1 | tee -a "$LOG_FILE"; then | ||
| 38 | echo "UNIT_TESTS=PASS" | tee -a "$LOG_FILE" | ||
| 39 | UNIT_RESULT="PASS" | ||
| 40 | else | ||
| 41 | echo "UNIT_TESTS=FAIL" | tee -a "$LOG_FILE" | ||
| 42 | UNIT_RESULT="FAIL" | ||
| 43 | fi | ||
| 44 | |||
| 45 | # ESP-IDF build (in Docker) | ||
| 46 | echo "=== ESP-IDF Build ===" | tee -a "$LOG_FILE" | ||
| 47 | if 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} | ||
| 54 | else | ||
| 55 | echo "Docker not available, skipping ESP-IDF build" | tee -a "$LOG_FILE" | ||
| 56 | BUILD_RC=0 | ||
| 57 | fi | ||
| 58 | |||
| 59 | if [ "$BUILD_RC" -eq 0 ]; then | ||
| 60 | echo "IDF_BUILD=PASS" | tee -a "$LOG_FILE" | ||
| 61 | BUILD_RESULT="PASS" | ||
| 62 | else | ||
| 63 | echo "IDF_BUILD=FAIL" | tee -a "$LOG_FILE" | ||
| 64 | BUILD_RESULT="FAIL" | ||
| 65 | fi | ||
| 66 | |||
| 67 | # Summary | ||
| 68 | echo "=== Summary ===" | tee -a "$LOG_FILE" | ||
| 69 | echo "Unit tests: $UNIT_RESULT" | tee -a "$LOG_FILE" | ||
| 70 | echo "IDF build: $BUILD_RESULT" | tee -a "$LOG_FILE" | ||
| 71 | |||
| 72 | if [ "$UNIT_RESULT" = "PASS" ] && [ "$BUILD_RESULT" = "PASS" ]; then | ||
| 73 | echo "OVERALL=PASS" | tee -a "$LOG_FILE" | ||
| 74 | echo "PASS" > "$RESULT_FILE" | ||
| 75 | exit 0 | ||
| 76 | else | ||
| 77 | echo "OVERALL=FAIL" | tee -a "$LOG_FILE" | ||
| 78 | echo "FAIL" > "$RESULT_FILE" | ||
| 79 | exit 1 | ||
| 80 | fi | ||