Skip to content

Commit 2a8800a

Browse files
feat(ci): Add --ci flag for non-interactive install script mode
- Add --ci flag to install.sh that bypasses interactive prompts - CI mode uses temp directory for vault, skips auth and Obsidian - Supports RAD_PASSPHRASE env var for Radicle identity creation - Add install-script-syntax job to verify script parsing
1 parent 9f63a91 commit 2a8800a

2 files changed

Lines changed: 67 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,24 @@ jobs:
4343
- name: Run tests
4444
run: npm run test
4545
timeout-minutes: 5
46+
47+
install-script-syntax:
48+
runs-on: ubuntu-latest
49+
timeout-minutes: 5
50+
steps:
51+
- uses: actions/checkout@v4
52+
53+
- name: Verify install.sh syntax
54+
run: bash -n install.sh
55+
56+
- name: Test --ci flag parsing
57+
run: |
58+
# Verify the script accepts --ci flag and outputs CI mode message
59+
# Note: We can't run the full install in CI, just test parsing
60+
bash -c 'source <(head -120 install.sh); echo "CI_MODE=$CI_MODE"'
61+
62+
# Test that command_exists function works
63+
bash -c '
64+
source <(sed -n "117,120p" install.sh)
65+
command_exists bash && echo "command_exists: OK"
66+
'

install.sh

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
# --test-fail before-gh Simulate failure before GitHub CLI installed (no automatic issue creation available)
2222
# --test-fail after-gh Simulate failure after GitHub CLI installed (should offer automatic issue creation)
2323
# --test-radicle-fallback Force GitHub source fallback for Radicle installation (simulates server outage)
24+
#
25+
# CI mode (non-interactive):
26+
# bash install.sh --ci Run in CI mode with defaults, no prompts, temp directory vault
2427

2528
# Create log file FIRST (before anything else)
2629
LOG_FILE="/tmp/interbrain-install-$(date +%Y%m%d-%H%M%S).log"
@@ -47,7 +50,14 @@ echo "=================================="
4750
echo ""
4851

4952
# Check if running in non-interactive mode (piped without bash)
50-
if [ ! -t 0 ]; then
53+
# CI mode bypasses this check and uses defaults/env vars
54+
if [ "$CI_MODE" = "true" ]; then
55+
echo "Running in CI mode - non-interactive with defaults"
56+
DEFAULT_VAULT_PARENT="/tmp"
57+
DEFAULT_VAULT_NAME="interbrain-ci-test-$$"
58+
SKIP_AUTH=true
59+
SKIP_OBSIDIAN=true
60+
elif [ ! -t 0 ]; then
5161
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
5262
echo "⚠️ NON-INTERACTIVE MODE NOT SUPPORTED"
5363
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
@@ -81,6 +91,7 @@ DREAMER_UUID=""
8191
BRANCH="main" # Default to main branch
8292
TEST_FAIL=""
8393
TEST_RADICLE_FALLBACK=false
94+
CI_MODE=false
8495
while [[ $# -gt 0 ]]; do
8596
case $1 in
8697
--uri)
@@ -103,6 +114,10 @@ while [[ $# -gt 0 ]]; do
103114
TEST_RADICLE_FALLBACK=true
104115
shift
105116
;;
117+
--ci)
118+
CI_MODE=true
119+
shift
120+
;;
106121
*)
107122
shift
108123
;;
@@ -1112,7 +1127,11 @@ else
11121127
info " • Community features"
11131128
echo ""
11141129

1115-
if [ -t 0 ]; then
1130+
if [ "$SKIP_AUTH" = "true" ]; then
1131+
# CI mode - skip auth entirely
1132+
info "CI mode: Skipping GitHub authentication"
1133+
GH_USER="[CI mode - skipped]"
1134+
elif [ -t 0 ]; then
11161135
# Interactive mode - offer authentication
11171136
echo "Do you have a GitHub account?"
11181137
echo ""
@@ -1230,7 +1249,28 @@ else
12301249
echo " 2. Create a passphrase (keep this safe!)"
12311250
echo ""
12321251

1233-
if [ -t 0 ]; then
1252+
if [ "$CI_MODE" = "true" ] && [ -n "$RAD_PASSPHRASE" ]; then
1253+
# CI mode with passphrase - create identity non-interactively
1254+
info "CI mode: Creating Radicle identity with RAD_PASSPHRASE"
1255+
rad auth --alias "CI-Test-$$"
1256+
1257+
if rad self --did >/dev/null 2>&1; then
1258+
success "Radicle identity created (CI mode)"
1259+
RAD_DID=$(rad self --did)
1260+
RAD_ALIAS=$(rad self --alias 2>/dev/null || echo "CI-Test")
1261+
echo " DID: $RAD_DID"
1262+
echo " Alias: $RAD_ALIAS"
1263+
else
1264+
warning "CI mode: Radicle identity creation failed"
1265+
RAD_DID="[CI mode - failed]"
1266+
RAD_ALIAS="[Not created]"
1267+
fi
1268+
elif [ "$CI_MODE" = "true" ]; then
1269+
# CI mode without passphrase - skip
1270+
info "CI mode: Skipping Radicle identity (no RAD_PASSPHRASE)"
1271+
RAD_DID="[CI mode - skipped]"
1272+
RAD_ALIAS="[Not created]"
1273+
elif [ -t 0 ]; then
12341274
# Interactive mode - offer choice
12351275
read -p "Create Radicle identity now? [Y/n] (you can skip and rerun installer later): " -n 1 -r
12361276
echo ""
@@ -1472,7 +1512,9 @@ echo ""
14721512
echo "Step 14/$TOTAL_STEPS: Registering vault with Obsidian..."
14731513
echo "-----------------------------"
14741514

1475-
if [[ "$OSTYPE" == "darwin"* ]] && [ "$OBSIDIAN_INSTALLED" = true ]; then
1515+
if [ "$SKIP_OBSIDIAN" = "true" ]; then
1516+
info "CI mode: Skipping Obsidian registration and launch"
1517+
elif [[ "$OSTYPE" == "darwin"* ]] && [ "$OBSIDIAN_INSTALLED" = true ]; then
14761518
# Kill Obsidian if running so it can read the updated config
14771519
if pgrep -x "Obsidian" > /dev/null; then
14781520
info "Closing Obsidian to update vault registry..."

0 commit comments

Comments
 (0)