Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 37 additions & 4 deletions .claude/tasks/2025-07-06-setup-improvements.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Setup.zsh Improvement Plan

## Current Status (July 6, 2025)
## Current Status (July 7, 2025)

**Task**: Improve reliability and testability of dotfiles setup process through TDD approach
**Total PRs Planned**: 10 PRs
**Completed**: 5 PRs
**Current**: Working on PR 6
**Total PRs Planned**: 10 PRs + 2 Infrastructure PRs
**Completed**: 8 PRs (including SSH Installation Testing)
**Current**: Working on Infrastructure Improvements (PR 8.1 & 8.2)

## Completed PRs

Expand Down Expand Up @@ -38,6 +38,39 @@
- **Functions**: `capture_error`, `retry_with_backoff`, `handle_error`
- **Integration**: Sourced in setup.zsh, replaces aggressive ERR trap approach

### ✅ PR 6: Installation Script Test Infrastructure (Merged)
- **Outcome**: Shared testing patterns and utilities for installation script testing
- **Key Files**: `test/install/lib/install-test-utils.zsh`, `test/install/lib/install-mocks.zsh`
- **Functions**: Installation-specific mocking, environment isolation, validation patterns
- **Integration**: Foundation for testing individual installation scripts

### ✅ PR 7: Homebrew Detection Testing (Merged)
- **Outcome**: Complete behavior bundle for Homebrew installation with detection utilities
- **Key Files**: `lib/homebrew-utils.zsh`, `test/install/test-homebrew-detection.zsh`
- **Functions**: `detect_homebrew()`, `homebrew_bundle_available()`, installation script integration
- **Pattern**: Complete behavior bundle (utilities + tests + integration + actual usage)

### ✅ PR 8: SSH Installation Testing (Merged)
- **Outcome**: Complete SSH key detection with testing and installation script integration
- **Key Files**: `lib/ssh-utils.zsh`, `test/install/test-ssh-detection.zsh`, updated `bin/install/ssh.zsh`
- **Functions**: `detect_ssh_keys()`, `ssh_key_pair_found()`, centralized path configuration
- **Improvements**: Post-implementation refactoring, dead code elimination, enhanced CLAUDE.md guidelines

## Infrastructure Improvements (In Progress)

### ✅ PR 8.1: Pull Request Template (Completed)
- **Goal**: Standardize PR descriptions using established patterns from successful PRs
- **Implementation**: `.github/PULL_REQUEST_TEMPLATE.md` with structured sections
- **Features**: Summary, changes, testing checkboxes, off-topic commit handling, quality gates
- **Benefits**: Consistent PR format, reduced cognitive load, captured process learnings

### 🔄 PR 8.2: GitHub Actions CI (In Progress)
- **Goal**: Automatic test execution on PRs with GitHub UI status indicators
- **Implementation**: `.github/workflows/test-dotfiles.yml` using existing test infrastructure
- **Features**: macOS runner, zsh shell, smart path triggering, existing test/run-tests.zsh integration
- **Benefits**: Visible test status in PR UI, early issue detection, no manual test verification
- **Status**: Workflow created, ready for testing

## Key Technical Decisions & Patterns

### Testing Philosophy
Expand Down
115 changes: 115 additions & 0 deletions .github/workflows/test-dotfiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Test Dotfiles Setup Scripts

on:
# Run on pushes to main branch
push:
branches: [ main ]
paths:
- 'setup.zsh'
- 'bin/**'
- 'lib/**'
- 'test/**'
- 'macos/Brewfile'
- 'config/**'
- '.github/workflows/test-dotfiles.yml'

# Run on pull requests to main
pull_request:
branches: [ main ]
paths:
- 'setup.zsh'
- 'bin/**'
- 'lib/**'
- 'test/**'
- 'macos/Brewfile'
- 'config/**'
- '.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"

# Make test runner executable
chmod +x test/run-tests.zsh

- name: Run test suite
run: |
# Run all tests using our existing test runner
./test/run-tests.zsh

- name: Verify test coverage
run: |
# Count test files and verify they were all executed
echo "Verifying test coverage..."

EXPECTED_TESTS=$(find test -name "test-*.zsh" -type f -not -path "*/lib/*" | wc -l | tr -d ' ')
echo "Found $EXPECTED_TESTS test files in repository"

# The test runner reports how many files it executed
# This helps catch cases where tests exist but aren't being run
echo "Expected test file count: $EXPECTED_TESTS"

- 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 key test directories exist
if [[ ! -d "$DOTFILES/test" ]]; then
echo "❌ Test directory not found"
exit 1
fi

if [[ ! -f "$DOTFILES/test/run-tests.zsh" ]]; then
echo "❌ Test runner not found"
exit 1
fi

echo "✅ Test infrastructure validated"

- 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