Skip to content

Conversation

@fx
Copy link
Owner

@fx fx commented Oct 30, 2025

Summary

Refactors the shared symlinks setup script to intelligently handle .claude directory symlinking and eliminates code duplication. Adds comprehensive Docker-based test suite with CI integration.

Changes

Selective .claude Symlinking

  • Fresh install (no ~/.claude): Symlinks entire directory → all content accessible
  • Existing ~/.claude: Only symlinks specific subdirectories:
    • agents/
    • commands/
    • skills/
    • CLAUDE.md
  • Preserves user's existing files (settings, custom content, etc.)

Code Refactoring

  • Extracted .claude symlinking logic into symlink_claude() function
  • Extracted general symlinking logic into symlink_to_home() function
  • Eliminated ~40 lines of duplicated code
  • Clarified that /shared/ is Coder-only with better comments

Test Suite

  • Added test/test-dotfiles.sh with 3 Docker-based tests:
    1. Non-Coder environment (direct symlink)
    2. Coder fresh install (full directory symlink to /shared/)
    3. Coder existing ~/.claude (selective subdirectory symlinks)
  • Added GitHub Actions CI workflow (.github/workflows/test.yml)
  • Updated CLAUDE.md with testing documentation

Bug Fixes

  • Added skills/ directory to shared/claude/
  • Fixed ln command to use -n flag (prevents creating symlinks inside existing directories)

Test Results

All tests pass locally:

✓ Non-Coder test passed
✓ Coder fresh install test passed
✓ Coder existing ~/.claude test passed
✓ All tests passed!

Testing Instructions

# Start Docker if needed
sudo service docker start

# Run tests locally
./test/test-dotfiles.sh

Copilot AI review requested due to automatic review settings October 30, 2025 18:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive automated testing infrastructure for the dotfiles installation system. The tests verify correct behavior in both Coder workspace and non-Coder environments, ensuring symlink handling works properly for the .claude directory and related configurations.

  • Introduces a Docker-based test script (test/test-dotfiles.sh) that validates three installation scenarios
  • Adds GitHub Actions CI workflow for automated testing on push and pull requests
  • Refactors .chezmoiscripts/run_onchange_after_setup-shared-symlinks.sh.tmpl to extract reusable functions for symlink management
  • Documents the testing approach and procedures in CLAUDE.md

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/test-dotfiles.sh New test script that validates dotfiles installation in non-Coder, Coder fresh install, and Coder existing directory scenarios using Docker
.github/workflows/test.yml CI workflow configuration to run tests automatically on main branch and pull requests
.chezmoiscripts/run_onchange_after_setup-shared-symlinks.sh.tmpl Refactored to extract symlink_claude() and symlink_to_home() functions, improving maintainability and reusability
CLAUDE.md Added comprehensive testing documentation covering local and CI testing procedures
shared/claude/skills/README.md Added placeholder README for the skills directory

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

fx added 5 commits October 30, 2025 18:27
The third test case was failing because Git inside the Docker container refused to access /workspace/.git due to dubious ownership (mounted from host with different uid/gid). This adds `git config --global --add safe.directory /workspace` before running chezmoi to resolve the issue.
Use `safe.directory '*'` instead of specific path to ensure all Git operations work correctly in the Docker test environment, regardless of mount ownership.
Move git config safe.directory before mise/chezmoi installation to ensure the configuration is in place when chezmoi needs to access the local repository.
… issues

Instead of using the mounted /workspace directly, copy it to /tmp inside the container first. This eliminates Git ownership validation errors that occur with Docker volume mounts having different uid/gid.
@fx fx merged commit a62c395 into main Oct 30, 2025
1 check passed
@fx fx deleted the refactor/claude-selective-symlinks branch October 30, 2025 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants