Skip to content

Commit dfa577b

Browse files
committed
Create ~/Work directory and clone devsetup there via gh
After gh is installed and authenticated, setup.sh now creates ~/Work and clones the devsetup repo there as the canonical location. On subsequent runs it pulls updates. CI workflow now provides GH_TOKEN via github.token so gh auth and the clone step work in the GitHub Actions environment. Added bats tests to verify ~/Work exists and devsetup is cloned.
1 parent d54eb6d commit dfa577b

3 files changed

Lines changed: 54 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
run: bash setup.sh
2727
env:
2828
CI: "true"
29+
GH_TOKEN: ${{ github.token }}
2930

3031
- name: Install bats
3132
run: sudo apt-get install -y -qq bats
@@ -35,3 +36,5 @@ jobs:
3536
export PATH="$HOME/.local/bin:$PATH"
3637
eval "$(mise activate bash)"
3738
bats test/setup_test.bats
39+
env:
40+
GH_TOKEN: ${{ github.token }}

setup.sh

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,37 @@ else
256256
gh auth login --web --git-protocol https
257257
fi
258258

259+
# ---------------------------------------------------------------------------
260+
# Work directory and devsetup clone
261+
# ---------------------------------------------------------------------------
262+
263+
WORK_DIR="$HOME/Work"
264+
DEVSETUP_DIR="$WORK_DIR/devsetup"
265+
DEVSETUP_REPO="${DEVSETUP_REPO:-trusted/devsetup}"
266+
267+
fmt_header "Work Directory"
268+
269+
if [ -d "$WORK_DIR" ]; then
270+
fmt_ok "$WORK_DIR already exists"
271+
else
272+
fmt_install "Creating $WORK_DIR"
273+
mkdir -p "$WORK_DIR"
274+
fi
275+
276+
fmt_header "Clone devsetup"
277+
278+
if [ -d "$DEVSETUP_DIR/.git" ]; then
279+
fmt_ok "devsetup already cloned at $DEVSETUP_DIR"
280+
git -C "$DEVSETUP_DIR" pull --quiet 2>/dev/null || true
281+
else
282+
fmt_install "Cloning $DEVSETUP_REPO to $DEVSETUP_DIR"
283+
gh repo clone "$DEVSETUP_REPO" "$DEVSETUP_DIR" -- --quiet
284+
fi
285+
286+
# If we were running from the temp bootstrap location, switch SCRIPT_DIR
287+
# to the canonical ~/Work/devsetup so migrations use the right path.
288+
SCRIPT_DIR="$DEVSETUP_DIR"
289+
259290
# ---------------------------------------------------------------------------
260291
# mise (version manager)
261292
# ---------------------------------------------------------------------------
@@ -419,6 +450,9 @@ echo "= Trusted Dev Setup Complete ="
419450
echo ""
420451
echo "Next steps:"
421452
echo " 1. Open a new terminal (or run: source ~/.zshrc)"
422-
echo " 2. Clone a project: gh repo clone trusted/<repo-name>"
453+
echo " 2. Clone a project: cd ~/Work && gh repo clone trusted/<repo-name>"
423454
echo " 3. Run project setup: cd <repo-name> && bin/setup"
424455
echo ""
456+
echo "To re-run this setup later:"
457+
echo " ~/Work/devsetup/setup.sh"
458+
echo ""

test/setup_test.bats

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,19 @@
9191
@test "migration state directory exists" {
9292
[ -d "$HOME/.local/state/trusted/devsetup/migrations" ]
9393
}
94+
95+
# ---------------------------------------------------------------------------
96+
# Work directory and devsetup clone
97+
# ---------------------------------------------------------------------------
98+
99+
@test "~/Work directory exists" {
100+
[ -d "$HOME/Work" ]
101+
}
102+
103+
@test "devsetup is cloned to ~/Work/devsetup" {
104+
[ -d "$HOME/Work/devsetup/.git" ]
105+
}
106+
107+
@test "~/Work/devsetup contains setup.sh" {
108+
[ -f "$HOME/Work/devsetup/setup.sh" ]
109+
}

0 commit comments

Comments
 (0)