fix: LICENSE name #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test Dotfiles | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| changes: | |
| name: Detect Changes | |
| runs-on: ubuntu-latest | |
| outputs: | |
| shell: ${{ steps.filter.outputs.shell }} | |
| lua: ${{ steps.filter.outputs.lua }} | |
| nvim: ${{ steps.filter.outputs.nvim }} | |
| devbox: ${{ steps.filter.outputs.devbox }} | |
| chezmoi: ${{ steps.filter.outputs.chezmoi }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dorny/paths-filter@v3 | |
| id: filter | |
| with: | |
| filters: | | |
| shell: | |
| - 'dot_zshrc.tmpl' | |
| - 'dot_zshenv.tmpl' | |
| - 'install.sh' | |
| - '.chezmoiscripts/**' | |
| - '.github/workflows/**' | |
| lua: | |
| - 'dot_config/nvim/**/*.lua' | |
| - '.github/workflows/**' | |
| nvim: | |
| - 'dot_config/nvim/**' | |
| - '.github/workflows/**' | |
| devbox: | |
| - 'dot_local/share/devbox/global/default/devbox.json' | |
| - '.github/workflows/**' | |
| chezmoi: | |
| - '**/*.tmpl' | |
| - '.chezmoi*' | |
| - 'dot_config/**' | |
| - 'private_dot_ssh/**' | |
| - '.github/workflows/**' | |
| format: | |
| name: Format Check | |
| needs: changes | |
| if: needs.changes.outputs.shell == 'true' || needs.changes.outputs.lua == 'true' || needs.changes.outputs.devbox == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install formatters | |
| run: | | |
| # shfmt (shell formatter) | |
| curl -sS https://webinstall.dev/shfmt | bash | |
| export PATH="$HOME/.local/bin:$PATH" | |
| # stylua (lua formatter) | |
| curl -sL https://github.com/JohnnyMorganz/StyLua/releases/latest/download/stylua-linux-x86_64.zip -o stylua.zip | |
| unzip stylua.zip -d /usr/local/bin | |
| chmod +x /usr/local/bin/stylua | |
| - name: Check shell format (shfmt) | |
| run: | | |
| export PATH="$HOME/.local/bin:$PATH" | |
| echo "Checking shell format..." | |
| # Check zsh files (remove template syntax first) | |
| for file in dot_zshrc.tmpl dot_zshenv.tmpl; do | |
| if [[ -f "$file" ]]; then | |
| sed 's/{{[^}]*}}//g' "$file" > /tmp/check.sh | |
| shfmt -d -i 2 -ci /tmp/check.sh || echo "::warning::$file needs formatting" | |
| fi | |
| done | |
| - name: Check lua format (stylua) | |
| run: | | |
| echo "Checking lua format..." | |
| stylua --check dot_config/nvim/ || echo "::warning::Lua files need formatting" | |
| - name: Check JSON format | |
| run: | | |
| echo "Checking JSON format..." | |
| python3 -c " | |
| import json | |
| import sys | |
| files = ['dot_local/share/devbox/global/default/devbox.json'] | |
| for f in files: | |
| with open(f) as fp: | |
| data = json.load(fp) | |
| formatted = json.dumps(data, indent=2) | |
| with open(f) as fp: | |
| original = fp.read().strip() | |
| if formatted != original: | |
| print(f'::warning::{f} needs formatting') | |
| " | |
| lint: | |
| name: Lint | |
| needs: changes | |
| if: needs.changes.outputs.shell == 'true' || needs.changes.outputs.lua == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install zsh | |
| run: sudo apt-get update && sudo apt-get install -y zsh | |
| - name: Check zsh syntax | |
| run: | | |
| echo "Checking zsh syntax..." | |
| for file in dot_zshrc.tmpl dot_zshenv.tmpl; do | |
| if [[ -f "$file" ]]; then | |
| # Remove chezmoi template syntax for syntax check | |
| sed 's/{{[^}]*}}//g' "$file" > /tmp/check.zsh | |
| zsh -n /tmp/check.zsh && echo "✓ $file" || exit 1 | |
| fi | |
| done | |
| - name: ShellCheck | |
| run: | | |
| echo "Running ShellCheck..." | |
| # Install shellcheck if not present (ubuntu-latest usually has it) | |
| if ! command -v shellcheck &> /dev/null; then | |
| sudo apt-get update && sudo apt-get install -y shellcheck | |
| fi | |
| # Check install.sh and scripts in .chezmoiscripts | |
| find . -type f \( -name "install.sh" -o -path "./.chezmoiscripts/*.sh" \) -print0 | xargs -0 shellcheck | |
| - name: Check lua syntax | |
| run: | | |
| echo "Checking lua syntax..." | |
| sudo apt-get install -y lua5.4 | |
| find dot_config/nvim -name "*.lua" -exec lua5.4 -p {} \; -print | |
| chezmoi-linux: | |
| name: Chezmoi (Linux) | |
| needs: changes | |
| if: needs.changes.outputs.chezmoi == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install chezmoi | |
| run: sh -c "$(curl -fsLS get.chezmoi.io)" -- -b /usr/local/bin | |
| - name: Setup test config (provide prompted values) | |
| run: | | |
| mkdir -p ~/.config/chezmoi | |
| cat > ~/.config/chezmoi/chezmoi.yaml << 'EOF' | |
| data: | |
| name: "Test User" | |
| email: "test@example.com" | |
| work_email: "test@work.example.com" | |
| EOF | |
| - name: Test chezmoi init (dry-run) | |
| run: | | |
| echo "Testing chezmoi template expansion..." | |
| chezmoi init --source="${PWD}" --dry-run --verbose | |
| - name: Verify template expansion | |
| run: | | |
| chezmoi init --source="${PWD}" | |
| chezmoi managed | head -20 | |
| chezmoi cat ~/.config/git/config || true | |
| chezmoi-macos: | |
| name: Chezmoi (macOS) | |
| needs: changes | |
| if: needs.changes.outputs.chezmoi == 'true' | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install chezmoi | |
| run: brew install chezmoi | |
| - name: Setup test config (provide prompted values) | |
| run: | | |
| mkdir -p ~/.config/chezmoi | |
| cat > ~/.config/chezmoi/chezmoi.yaml << 'EOF' | |
| data: | |
| name: "Test User" | |
| email: "test@example.com" | |
| work_email: "test@work.example.com" | |
| EOF | |
| - name: Test chezmoi init (dry-run) | |
| run: | | |
| echo "Testing chezmoi template expansion..." | |
| chezmoi init --source="${PWD}" --dry-run --verbose | |
| - name: Verify template expansion | |
| run: | | |
| chezmoi init --source="${PWD}" | |
| chezmoi managed | head -20 | |
| devbox: | |
| name: Devbox Validation | |
| needs: changes | |
| if: needs.changes.outputs.devbox == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Validate devbox.json | |
| run: | | |
| echo "Validating devbox.json..." | |
| python3 -c "import json; json.load(open('dot_local/share/devbox/global/default/devbox.json'))" | |
| echo "✓ Valid JSON" | |
| - name: Install devbox | |
| uses: jetify-com/devbox-install-action@v0.14.0 | |
| with: | |
| enable-cache: true | |
| project-path: dot_local/share/devbox/global/default | |
| - name: Test devbox packages | |
| run: | | |
| echo "Testing devbox package resolution..." | |
| devbox install --config dot_local/share/devbox/global/default/devbox.json | |
| neovim: | |
| name: Neovim Config | |
| needs: changes | |
| if: needs.changes.outputs.nvim == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Neovim | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y neovim | |
| - name: Setup Neovim config | |
| run: | | |
| mkdir -p ~/.config | |
| cp -r dot_config/nvim ~/.config/nvim | |
| - name: Test Neovim startup | |
| run: | | |
| echo "Testing Neovim startup..." | |
| timeout 60 nvim --headless -c 'qall' 2>&1 || true | |
| echo "✓ Neovim config loaded" | |
| - name: Validate init.lua | |
| run: nvim --headless -c 'lua print("init.lua OK")' -c 'qall' 2>&1 | |
| # Aggregator job for branch protection | |
| # This job always runs and reports success only if all required jobs passed or were skipped | |
| ci-complete: | |
| name: CI Complete | |
| needs: [format, lint, chezmoi-linux, chezmoi-macos, devbox, neovim] | |
| if: always() | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check job results | |
| env: | |
| RESULTS: ${{ join(needs.*.result, ' ') }} | |
| run: | | |
| echo "Job results: $RESULTS" | |
| for result in $RESULTS; do | |
| if [[ "$result" == "failure" || "$result" == "cancelled" ]]; then | |
| echo "❌ CI failed: found $result" | |
| exit 1 | |
| fi | |
| done | |
| echo "✅ CI complete: all jobs passed or were skipped" |