|
| 1 | +name: Test Arch Setup Script |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, develop ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + workflow_dispatch: # Allow manual triggering |
| 9 | + |
| 10 | +jobs: |
| 11 | + test-arch-setup: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + container: |
| 14 | + image: archlinux:latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Setup Arch environment |
| 21 | + run: | |
| 22 | + pacman -Syu --noconfirm |
| 23 | + pacman -S --noconfirm sudo base-devel git |
| 24 | + |
| 25 | + # Create test user |
| 26 | + useradd -m -G wheel -s /bin/bash testuser |
| 27 | + echo "testuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers |
| 28 | + |
| 29 | + # Create mock Dotfiles structure |
| 30 | + sudo -u testuser mkdir -p /home/testuser/Dotfiles/{sway,nvim,foot,waybar,blueman,proto} |
| 31 | + sudo -u testuser bash -c 'echo "export PS1=\"[ci-test] \u@\h:\w$ \"" > /home/testuser/Dotfiles/.bashrc' |
| 32 | + sudo -u testuser bash -c 'echo "source ~/.bashrc" > /home/testuser/Dotfiles/.bash_profile' |
| 33 | + sudo -u testuser bash -c 'echo "# Mock sway config" > /home/testuser/Dotfiles/sway/config' |
| 34 | + sudo -u testuser bash -c 'echo "# Mock nvim config" > /home/testuser/Dotfiles/nvim/init.lua' |
| 35 | + sudo -u testuser bash -c 'echo "# Mock foot config" > /home/testuser/Dotfiles/foot/foot.ini' |
| 36 | + sudo -u testuser bash -c 'echo "# Mock waybar config" > /home/testuser/Dotfiles/waybar/config' |
| 37 | + sudo -u testuser bash -c 'echo "# Mock blueman config" > /home/testuser/Dotfiles/blueman/config' |
| 38 | + |
| 39 | + - name: Copy script to test environment |
| 40 | + run: | |
| 41 | + cp arch_setup.sh /home/testuser/ |
| 42 | + chown testuser:testuser /home/testuser/arch_setup.sh |
| 43 | + chmod +x /home/testuser/arch_setup.sh |
| 44 | + |
| 45 | + - name: Test script syntax |
| 46 | + run: | |
| 47 | + sudo -u testuser bash -n /home/testuser/arch_setup.sh |
| 48 | + echo "✅ Script syntax is valid" |
| 49 | + |
| 50 | + - name: Test dry-run mode (if implemented) |
| 51 | + run: | |
| 52 | + # You could add a --dry-run flag to your script |
| 53 | + # sudo -u testuser /home/testuser/arch_setup.sh --dry-run |
| 54 | + echo "⏩ Skipping dry-run (not implemented)" |
| 55 | + |
| 56 | + - name: Test package installation (partial) |
| 57 | + run: | |
| 58 | + # Test installing a subset of packages to avoid long CI times |
| 59 | + sudo -u testuser bash -c " |
| 60 | + export HOME=/home/testuser |
| 61 | + cd /home/testuser |
| 62 | + |
| 63 | + # Test core packages only |
| 64 | + sudo pacman -S --noconfirm git neovim foot sway |
| 65 | + echo '✅ Core packages installed successfully' |
| 66 | + |
| 67 | + # Test symlink creation |
| 68 | + ln -sf ~/Dotfiles/.bashrc ~/.bashrc |
| 69 | + ln -sf ~/Dotfiles/.bash_profile ~/.bash_profile |
| 70 | + echo '✅ Symlinks created successfully' |
| 71 | + |
| 72 | + # Verify symlinks |
| 73 | + ls -la ~/.bashrc ~/.bash_profile |
| 74 | + echo '✅ Symlinks verified' |
| 75 | + " |
| 76 | + |
| 77 | + - name: Test configuration validation |
| 78 | + run: | |
| 79 | + sudo -u testuser bash -c " |
| 80 | + export HOME=/home/testuser |
| 81 | + cd /home/testuser |
| 82 | + |
| 83 | + # Check if configs exist |
| 84 | + test -f ~/.bashrc && echo '✅ .bashrc exists' |
| 85 | + test -f ~/.bash_profile && echo '✅ .bash_profile exists' |
| 86 | + |
| 87 | + # Test if bashrc sources correctly |
| 88 | + bash -c 'source ~/.bashrc && echo \"✅ .bashrc sources correctly\"' |
| 89 | + " |
| 90 | + |
| 91 | + - name: Generate test report |
| 92 | + run: | |
| 93 | + echo "## Test Results" > test_report.md |
| 94 | + echo "- ✅ Script syntax validation passed" >> test_report.md |
| 95 | + echo "- ✅ Core package installation successful" >> test_report.md |
| 96 | + echo "- ✅ Symlink creation successful" >> test_report.md |
| 97 | + echo "- ✅ Configuration validation passed" >> test_report.md |
| 98 | + echo "- ⚠️ Full script execution skipped (CI time constraints)" >> test_report.md |
| 99 | + |
| 100 | + cat test_report.md |
| 101 | + |
| 102 | + - name: Upload test artifacts |
| 103 | + uses: actions/upload-artifact@v4 |
| 104 | + if: always() |
| 105 | + with: |
| 106 | + name: test-results |
| 107 | + path: test_report.md |
| 108 | + |
| 109 | + test-shellcheck: |
| 110 | + runs-on: ubuntu-latest |
| 111 | + steps: |
| 112 | + - name: Checkout repository |
| 113 | + uses: actions/checkout@v4 |
| 114 | + |
| 115 | + - name: Run shellcheck |
| 116 | + uses: ludeeus/action-shellcheck@master |
| 117 | + with: |
| 118 | + scandir: '.' |
| 119 | + format: gcc |
| 120 | + severity: warning |
0 commit comments