From a6653cfb9692c08c55d2b9f3525038930c81835d Mon Sep 17 00:00:00 2001 From: William Mantly Date: Thu, 16 Jul 2026 17:00:27 -0400 Subject: [PATCH 1/2] Add CI: shellcheck setup.sh, syntax-check bootstrap.js theta-env has no app code of its own to unit-test (it orchestrates the proxy/sso-manager-node submodules) -- this catches the one thing that can actually break silently: setup.sh and bootstrap.js. --- .github/workflows/lint.yml | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..d2e5373 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,41 @@ +name: Lint + +# theta-env has no app code of its own to unit-test (it orchestrates the +# proxy/sso-manager-node submodules) -- this checks the one thing that can +# actually break silently: setup.sh and bootstrap.js. +on: + pull_request: + branches: + - master + push: + branches-ignore: + - master + +jobs: + shellcheck: + name: Shellcheck setup.sh + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Syntax check + run: bash -n setup.sh + + - name: Shellcheck + run: shellcheck -S warning setup.sh + + bootstrap-syntax: + name: Syntax check bootstrap.js + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 22.x + + - name: Syntax check + run: node --check bootstrap/bootstrap.js From c7b90b7e7c68da0a1ae1b375e054e6c25af143fc Mon Sep 17 00:00:00 2001 From: William Mantly Date: Thu, 16 Jul 2026 17:02:29 -0400 Subject: [PATCH 2/2] setup.sh: fix shellcheck findings (SC2115, SC2155 x2, SC2034) - rm -rf "$BACKUP_DIR/$old" -> "${BACKUP_DIR:?}/$old": if BACKUP_DIR ever ended up empty, this was rm -rf /$old. Low practical risk (BACKUP_DIR is a hardcoded ./backups default), but cheap to harden. - export FOO="$(...)" split into assign-then-export so a failing command substitution isn't masked by export's own exit status. - Removed CLIENT_SECRET=$(getval CLIENT_SECRET): extracted from bootstrap's output but never used afterward (already written directly into proxy-secrets.js by bootstrap.js itself). --- setup.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/setup.sh b/setup.sh index 1b7651a..3ea1355 100755 --- a/setup.sh +++ b/setup.sh @@ -558,7 +558,7 @@ backup_before_rebuild() { # Only prune real backup dirs — skip symlinks (a stray symlink could # point rm at an arbitrary tree) and non-dir entries. [[ -d "$BACKUP_DIR/$old" && ! -L "$BACKUP_DIR/$old" ]] || continue - rm -rf "$BACKUP_DIR/$old" || true + rm -rf "${BACKUP_DIR:?}/$old" || true removed=$((removed + 1)) done < <(ls -1 "$BACKUP_DIR" 2>/dev/null | sort -r | tail -n +$((keep + 1))) [[ "$removed" -gt 0 ]] && info " pruned $removed old backup(s) (keeping $keep)." @@ -572,7 +572,8 @@ backup_before_rebuild # hash from inside the Docker build context. Resolve it on the host (where # the submodule DOES resolve correctly) and pass it in as a build arg; see # docker-compose.yml and sso-manager-node's Dockerfile.openldap. -export SSO_GIT_COMMIT="$(git -C sso-manager-node rev-parse --short HEAD 2>/dev/null || echo unknown)" +SSO_GIT_COMMIT="$(git -C sso-manager-node rev-parse --short HEAD 2>/dev/null || echo unknown)" +export SSO_GIT_COMMIT info "Building + starting sso-manager (first run builds the image; this takes a while)..." "${COMPOSE[@]}" up -d --build sso-manager @@ -629,7 +630,6 @@ BOOTSTRAP_OUT=$("${COMPOSE[@]}" exec -T sso-manager node /bootstrap/bootstrap.js getval() { echo "$BOOTSTRAP_OUT" | grep -m1 "^$1=" | cut -d= -f2-; } CLIENT_ID=$(getval CLIENT_ID) -CLIENT_SECRET=$(getval CLIENT_SECRET) ALREADY_CONFIGURED=$(getval ALREADY_CONFIGURED) [[ -n "$CLIENT_ID" ]] || die "bootstrap did not return CLIENT_ID:\n${BOOTSTRAP_OUT}" @@ -641,7 +641,8 @@ fi # ── 6. Start the proxy, wait for health ─────────────────────────────────────── # PROXY_GIT_COMMIT: same reasoning as SSO_GIT_COMMIT above. -export PROXY_GIT_COMMIT="$(git -C proxy rev-parse --short HEAD 2>/dev/null || echo unknown)" +PROXY_GIT_COMMIT="$(git -C proxy rev-parse --short HEAD 2>/dev/null || echo unknown)" +export PROXY_GIT_COMMIT info "Building + starting proxy (first run builds the image; this takes a while)..." "${COMPOSE[@]}" up -d --build proxy