Skip to content

just: add install, update + uninstall commands #381

just: add install, update + uninstall commands

just: add install, update + uninstall commands #381

Workflow file for this run

name: Test Dotfiles Setup Scripts
on:
# Run on pushes to main branch only (for direct commits to main)
push:
branches: [main]
paths:
- "**/*.bash"
- "**/*.bats"
- "**/*.sh"
- ".github/workflows/test-dotfiles.yml"
# Run on pull requests to main (covers feature branch testing)
pull_request:
branches: [main]
paths:
- "**/*.bash"
- "**/*.bats"
- "**/*.sh"
- ".github/workflows/test-dotfiles.yml"
# Allow manual triggering for debugging
workflow_dispatch:
jobs:
test:
name: Run Dotfiles Tests
runs-on: macos-latest
# Set default shell to zsh to match our target environment
defaults:
run:
shell: zsh {0}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up environment
run: |
# Set DOTFILES environment variable for tests
echo "DOTFILES=${{ github.workspace }}" >> $GITHUB_ENV
# Ensure zsh is configured properly
echo "Using zsh version: $ZSH_VERSION"
echo "Shell: $SHELL"
- name: Install shellcheck
run: |
# Install shellcheck for static analysis
brew install shellcheck
- name: Run shellcheck
run: |
# Run shellcheck on all bash scripts (.sh and .bash files)
# Configuration is handled by .shellcheckrc file
echo "Running shellcheck on bash scripts..."
# Find all bash scripts and run shellcheck
BASH_FILES=$(find . \( -name "*.sh" -o -name "*.bash" \) -type f -not -path "./.*")
ALL_BATS_TESTS=$(find -name "*.bats" -type f 2>/dev/null | sort)
if [[ -z "$BASH_FILES" ]]; then
echo "No bash scripts found to check"
exit 0
fi
echo "Found bash scripts to check:"
echo "$BASH_FILES"
echo ""
# Check each file
FAILED_FILES=""
while IFS= read -r file; do
echo "Checking: $file"
if ! shellcheck -s bash "$file"; then
FAILED_FILES="$FAILED_FILES$file\n"
fi
done <<< "$BASH_FILES"
if [[ -n "$FAILED_FILES" ]]; then
echo ""
echo "❌ Shellcheck failed for the following files:"
echo -e "$FAILED_FILES"
exit 1
fi
echo "✅ All bash scripts passed shellcheck"
- name: Install BATS
run: |
# Install BATS for running bash tests
brew install bats-core
- name: Test environment validation
run: |
# Validate that our test environment works correctly
echo "Validating test environment..."
# Check that DOTFILES is set correctly
if [[ -z "$DOTFILES" ]]; then
echo "❌ DOTFILES environment variable not set"
exit 1
fi
echo "✅ DOTFILES set to: $DOTFILES"
# Verify BATS is available
if ! command -v bats >/dev/null 2>&1; then
echo "❌ BATS not found in PATH"
exit 1
fi
echo "✅ BATS available: $(bats --version)"
echo "✅ Test infrastructure validated"
- name: Run BATS test suite
run: |
# Run comprehensive BATS test suite across all directories
echo "Running BATS test suite..."
FAILED_TESTS=""
TOTAL_TESTS=0
# Find all BATS test files
ALL_BATS_TESTS=$(find -name "*.bats" -type f 2>/dev/null | sort)
if [[ -z "$ALL_BATS_TESTS" ]]; then
echo "No BATS test files found"
exit 0
fi
echo "Found BATS test files:"
echo "$ALL_BATS_TESTS"
echo ""
# Run each test file
echo "$ALL_BATS_TESTS" | while read -r test_file; do
if [[ -n "$test_file" ]]; then
echo "Running: $test_file"
((TOTAL_TESTS++))
if ! bats "$test_file"; then
echo "❌ Failed: $test_file"
FAILED_TESTS="$FAILED_TESTS$test_file\n"
fi
echo ""
fi
done
if [[ -n "$FAILED_TESTS" ]]; then
echo "❌ BATS test failures:"
echo -e "$FAILED_TESTS"
exit 1
fi
echo "✅ All BATS tests completed successfully"
# TODO: does this make sense? what's it doing?
- name: Test symlink verification
run: |
echo "Testing symlink functionality..."
# Check if symlinks utilities exist in new location
if [[ -f "./features/symlink/utils.bash" ]]; then
echo "Testing new symlinks utilities..."
# Test that the utilities can be sourced without errors
bash -n ./features/symlink/utils.bash
# Test basic symlink functionality
source ./features/symlink/utils.bash
echo "✅ New symlinks utilities loaded successfully"
fi
echo "✅ Symlink verification completed"
- name: Summary
if: always()
run: |
echo "=== Test Summary ==="
echo "Repository: ${{ github.repository }}"
echo "Branch: ${{ github.ref_name }}"
echo "Commit: ${{ github.sha }}"
echo "Runner OS: ${{ runner.os }}"
echo "Shell: $SHELL"
echo "ZSH Version: $ZSH_VERSION"
if [[ "${{ job.status }}" == "success" ]]; then
echo "🎉 All tests passed!"
else
echo "❌ Some tests failed. Check the logs above for details."
fi