Skip to content

refactor(shell): fix double-loading and sequencing in completion setup #1510

refactor(shell): fix double-loading and sequencing in completion setup

refactor(shell): fix double-loading and sequencing in completion setup #1510

name: Test Ansible Playbook
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch:
schedule:
- cron: "0 3 * * *"
jobs:
test-macos:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-15, macos-26]
env:
TERM: xterm-256color
SHELL: /bin/zsh
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set ZSH as default shell and environment vars
run: |
echo "Setting up environment..."
echo "SHELL=/bin/zsh" >> $GITHUB_ENV
echo "TERM=xterm-256color" >> $GITHUB_ENV
# Ensure ZSH is the default shell for the current user
sudo chsh -s /bin/zsh $(whoami)
# Create a .zshrc file if it doesn't exist
touch ~/.zshrc
echo 'export TERM=xterm-256color' >> ~/.zshrc
echo 'export SHELL=/bin/zsh' >> ~/.zshrc
- name: Make scripts executable
run: |
chmod +x ./bin/install.macos
chmod +x ./bin/sparkdock.macos
chmod +x ./bin/common/utils.sh
- name: Run installer script in non-interactive mode (first run - fresh install)
run: |
echo "=== FIRST RUN: Fresh installation ==="
# Run the installation script with the non-interactive flag
/bin/zsh -c "./bin/install.macos --non-interactive"
- name: Validate first installation
run: |
echo "=== Validating first installation ==="
# Check that sparkdock was installed to /opt/sparkdock
if [ ! -d "/opt/sparkdock" ]; then
echo "❌ /opt/sparkdock directory not found"
exit 1
fi
echo "✅ /opt/sparkdock directory exists"
# Check that sparkdock symlink was created
if [ ! -L "/usr/local/bin/sparkdock" ]; then
echo "❌ /usr/local/bin/sparkdock symlink not found"
exit 1
fi
echo "✅ /usr/local/bin/sparkdock symlink exists"
# Check that sjust was installed
if ! command -v sjust >/dev/null 2>&1; then
echo "❌ sjust command not found"
exit 1
fi
echo "✅ sjust command is available"
# Check that GitHub Copilot CLI was installed
if ! command -v copilot >/dev/null 2>&1; then
echo "❌ copilot command not found"
exit 1
fi
echo "✅ copilot command is available"
# Test basic functionality
echo "✅ First installation completed successfully"
- name: Fix ownership permissions and clean git state before second run
run: |
echo "=== Fixing ownership permissions and git state for second run ==="
# Fix ownership permissions recursively on /opt/sparkdock to resolve git permission issues
sudo chown -R $(whoami):$(id -gn) /opt/sparkdock
# Clean git state in http-proxy repository to avoid permission issues
if [ -d "/opt/sparkdock/http-proxy/.git" ]; then
echo "Cleaning git state in http-proxy repository..."
cd /opt/sparkdock/http-proxy
git reset --hard HEAD
git clean -fd
echo "Git state cleaned successfully"
fi
- name: Run installer script in non-interactive mode (second run - already provisioned)
run: |
echo "=== SECOND RUN: Already provisioned machine ==="
# Run the installation script again with --preserve-existing to test idempotent behavior
/bin/zsh -c "./bin/install.macos --non-interactive --preserve-existing"
- name: Validate second installation (idempotency test)
run: |
echo "=== Validating second installation (idempotency) ==="
# Check that sparkdock still exists
if [ ! -d "/opt/sparkdock" ]; then
echo "❌ /opt/sparkdock directory not found after second run"
exit 1
fi
echo "✅ /opt/sparkdock directory still exists"
# Check that sparkdock symlink still works
if [ ! -L "/usr/local/bin/sparkdock" ]; then
echo "❌ /usr/local/bin/sparkdock symlink not found after second run"
exit 1
fi
echo "✅ /usr/local/bin/sparkdock symlink still exists"
# Check that sjust still works
if ! command -v sjust >/dev/null 2>&1; then
echo "❌ sjust command not found after second run"
exit 1
fi
echo "✅ sjust command still available"
# Check that GitHub Copilot CLI still works
if ! command -v copilot >/dev/null 2>&1; then
echo "❌ copilot command not found after second run"
exit 1
fi
echo "✅ copilot command still available"
# Test that sjust can list commands (idempotency test)
sjust --list > /dev/null
echo "✅ sjust functionality verified"
echo "✅ Second installation completed successfully - installer is idempotent"
- name: Clean up test installations (optional)
if: always()
run: |
echo "Cleaning up..."
sudo rm -rf /opt/sparkdock