|
| 1 | +name: Bootstrap Script Testing |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [bootstrap] |
| 6 | + paths: |
| 7 | + - "util/env-bootstrap.sh" |
| 8 | + - ".github/workflows/bootstrap_testing.yml" |
| 9 | + - "lib/python/**" |
| 10 | + pull_request: |
| 11 | + branches: [master, develop, xap] |
| 12 | + paths: |
| 13 | + - "util/env-bootstrap.sh" |
| 14 | + - ".github/workflows/bootstrap_testing.yml" |
| 15 | + - "lib/python/**" |
| 16 | + workflow_dispatch: |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + |
| 21 | +jobs: |
| 22 | + bootstrap-test-linux: |
| 23 | + name: Bootstrap (Linux) |
| 24 | + runs-on: ubuntu-latest |
| 25 | + |
| 26 | + strategy: |
| 27 | + fail-fast: false |
| 28 | + matrix: |
| 29 | + distribution: |
| 30 | + # Ubuntu/Debian based |
| 31 | + - debian:11 |
| 32 | + - debian:12 |
| 33 | + - debian:13 |
| 34 | + - ubuntu:20.04 |
| 35 | + - ubuntu:22.04 |
| 36 | + - ubuntu:24.04 |
| 37 | + |
| 38 | + # RHEL/CentOS/Fedora based |
| 39 | + - fedora:41 |
| 40 | + - fedora:42 |
| 41 | + - fedora:43 |
| 42 | + - rockylinux:8 |
| 43 | + - rockylinux:9 |
| 44 | + - rockylinux/rockylinux:10 |
| 45 | + - almalinux:8 |
| 46 | + - almalinux:9 |
| 47 | + - almalinux:10 |
| 48 | + |
| 49 | + # OpenSUSE based (we skip Tumbleweed as it has issues with package versions between pattern installs and other dependencies preinstalled into the base container) |
| 50 | + - opensuse/leap:latest |
| 51 | + |
| 52 | + # Gentoo-based |
| 53 | + - gentoo/stage3:latest |
| 54 | + |
| 55 | + # Arch based |
| 56 | + - archlinux:latest |
| 57 | + - cachyos/cachyos:latest |
| 58 | + - manjarolinux/base:latest |
| 59 | + |
| 60 | + container: |
| 61 | + image: ${{ matrix.distribution }} |
| 62 | + options: --privileged |
| 63 | + |
| 64 | + steps: |
| 65 | + - name: Install base dependencies |
| 66 | + run: | |
| 67 | + # Attempt to run the package installation up to 10 times to mitigate transient network issues |
| 68 | + for n in $(seq 1 10); do |
| 69 | + { |
| 70 | + echo "Attempt #$n of 10 to install base dependencies:" |
| 71 | + case "${{ matrix.distribution }}" in |
| 72 | + *ubuntu*|*debian*) |
| 73 | + apt-get update |
| 74 | + apt-get install -y sudo git passwd |
| 75 | + ;; |
| 76 | + *fedora*|*rockylinux*|*almalinux*) |
| 77 | + dnf install -y sudo git passwd findutils # findutils=xargs |
| 78 | + ;; |
| 79 | + *suse*) |
| 80 | + zypper --non-interactive refresh |
| 81 | + zypper --non-interactive install sudo git shadow findutils # findutils=xargs |
| 82 | + ;; |
| 83 | + *gentoo*) |
| 84 | + emerge-webrsync |
| 85 | + emerge --noreplace --ask=n sudo dev-vcs/git shadow findutils # findutils=xargs |
| 86 | + ;; |
| 87 | + *archlinux*|*cachyos*|*manjaro*) |
| 88 | + pacman -Syu --noconfirm |
| 89 | + pacman -S --noconfirm sudo git |
| 90 | + ;; |
| 91 | + esac |
| 92 | + } && break || sleep 10 |
| 93 | + done |
| 94 | +
|
| 95 | + # Fix PAM configuration for sudo in containers |
| 96 | + # Fix /etc/shadow permissions - common issue in container environments |
| 97 | + chmod 640 /etc/shadow || chmod 400 /etc/shadow || true |
| 98 | +
|
| 99 | + # Disable problematic PAM modules that commonly fail in RHEL-like containers |
| 100 | + sed -i 's/^session.*pam_systemd.so/#&/' /etc/pam.d/sudo || true |
| 101 | + sed -i 's/^session.*pam_loginuid.so/#&/' /etc/pam.d/sudo || true |
| 102 | +
|
| 103 | + # Ensure proper sudoers configuration |
| 104 | + echo 'Defaults !requiretty' >> /etc/sudoers |
| 105 | + echo 'Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"' >> /etc/sudoers |
| 106 | +
|
| 107 | + - name: Checkout repository |
| 108 | + uses: actions/checkout@v6 |
| 109 | + with: |
| 110 | + fetch-depth: 1 |
| 111 | + submodules: recursive |
| 112 | + path: qmk_firmware |
| 113 | + |
| 114 | + - name: Create test user |
| 115 | + run: | |
| 116 | + # Create a test user for the bootstrap script |
| 117 | + useradd -m -s /bin/bash -U testuser |
| 118 | + echo 'testuser:testpassword' | chpasswd || true |
| 119 | + |
| 120 | + # Configure passwordless sudo |
| 121 | + echo "root ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers # some distros complain about root not being in sudoers |
| 122 | + echo "testuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers |
| 123 | + |
| 124 | + # Test sudo functionality |
| 125 | + sudo -u testuser whoami || echo "Sudo test failed, but continuing..." |
| 126 | +
|
| 127 | + - name: Move QMK repository to test user home |
| 128 | + run: | |
| 129 | + # Add upstream remote to the cloned repository so `qmk doctor` doesn't flag a warning |
| 130 | + git -C qmk_firmware remote add upstream https://github.com/qmk/qmk_firmware.git |
| 131 | + # Move the QMK repository to the test user's home directory |
| 132 | + mv qmk_firmware /home/testuser/qmk_firmware |
| 133 | + chown -R testuser:testuser /home/testuser/qmk_firmware |
| 134 | +
|
| 135 | + - name: Run bootstrap script |
| 136 | + env: |
| 137 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 138 | + run: | |
| 139 | + # Ensure the bootstrap script can access sudo |
| 140 | + sudo -u testuser --preserve-env=GITHUB_TOKEN bash -c " |
| 141 | + export CONFIRM=1 |
| 142 | + export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin |
| 143 | + cd /home/testuser |
| 144 | + bash /home/testuser/qmk_firmware/util/env-bootstrap.sh |
| 145 | + " |
| 146 | +
|
| 147 | + - name: Test QMK CLI |
| 148 | + run: | |
| 149 | + sudo -u testuser bash -c " |
| 150 | + export PATH=/home/testuser/.local/bin:\$PATH |
| 151 | + cd /home/testuser |
| 152 | + qmk setup -y -H /home/testuser/qmk_firmware # setup implies doctor, no need to run it separately |
| 153 | + cd /home/testuser/qmk_firmware |
| 154 | + qmk mass-compile -j $(nproc) -e DUMP_CI_METADATA=yes -f 'keyboard_name==*onekey*' -km reset -p || touch .failed # Compile a bunch of different platforms |
| 155 | + " |
| 156 | + |
| 157 | + cd /home/testuser/qmk_firmware |
| 158 | + ./util/ci/generate_failure_markdown.sh > $GITHUB_STEP_SUMMARY || true |
| 159 | + [ ! -e .failed ] || exit 1 |
| 160 | +
|
| 161 | + bootstrap-test-macos: |
| 162 | + name: Bootstrap (macOS) |
| 163 | + strategy: |
| 164 | + fail-fast: false |
| 165 | + matrix: |
| 166 | + os: |
| 167 | + - macos-13 # Intel x64 |
| 168 | + - macos-14 # Apple Silicon ARM64 |
| 169 | + - macos-15 # Apple Silicon ARM64 |
| 170 | + - macos-15-intel # Intel x64 |
| 171 | + - macos-26 # Apple Silicon ARM64 |
| 172 | + |
| 173 | + runs-on: ${{ matrix.os }} |
| 174 | + |
| 175 | + steps: |
| 176 | + - name: Checkout repository |
| 177 | + uses: actions/checkout@v6 |
| 178 | + with: |
| 179 | + fetch-depth: 1 |
| 180 | + submodules: recursive |
| 181 | + |
| 182 | + - name: Run bootstrap script |
| 183 | + env: |
| 184 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 185 | + run: | |
| 186 | + # Add upstream remote to the cloned repository so `qmk doctor` doesn't flag a warning |
| 187 | + git remote add upstream https://github.com/qmk/qmk_firmware.git |
| 188 | + # Run the bootstrap script |
| 189 | + export CONFIRM=1 |
| 190 | + sh ./util/env-bootstrap.sh |
| 191 | +
|
| 192 | + - name: Test QMK CLI |
| 193 | + run: | |
| 194 | + # Add QMK CLI to PATH (bootstrap script installs it to ~/.local/bin on macOS) |
| 195 | + export PATH="$HOME/.local/bin:$PATH" |
| 196 | + qmk setup -y -H . # setup implies doctor, no need to run it separately |
| 197 | + qmk mass-compile -j $(sysctl -n hw.ncpu) -e DUMP_CI_METADATA=yes -f 'keyboard_name==*onekey*' -km reset || touch .failed # Compile a bunch of different platforms |
| 198 | + |
| 199 | + ./util/ci/generate_failure_markdown.sh > $GITHUB_STEP_SUMMARY || true |
| 200 | + [ ! -e .failed ] || exit 1 |
| 201 | +
|
| 202 | + bootstrap-test-windows: |
| 203 | + name: Bootstrap (Windows) |
| 204 | + |
| 205 | + strategy: |
| 206 | + fail-fast: false |
| 207 | + matrix: |
| 208 | + msys-variant: |
| 209 | + - mingw64 |
| 210 | + - clang64 |
| 211 | + - ucrt64 |
| 212 | + |
| 213 | + runs-on: windows-latest |
| 214 | + defaults: |
| 215 | + run: |
| 216 | + shell: msys2 {0} |
| 217 | + |
| 218 | + steps: |
| 219 | + - name: Install MSYS2 |
| 220 | + uses: msys2/setup-msys2@v2 |
| 221 | + with: |
| 222 | + msystem: ${{ matrix.msys-variant }} |
| 223 | + pacboy: >- |
| 224 | + git: |
| 225 | +
|
| 226 | + - name: Checkout repository |
| 227 | + uses: actions/checkout@v6 |
| 228 | + with: |
| 229 | + fetch-depth: 1 |
| 230 | + submodules: recursive |
| 231 | + |
| 232 | + - name: Run bootstrap script |
| 233 | + env: |
| 234 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 235 | + run: | |
| 236 | + # Add upstream remote to the cloned repository so `qmk doctor` doesn't flag a warning |
| 237 | + git remote add upstream https://github.com/qmk/qmk_firmware.git |
| 238 | + # Run the bootstrap script |
| 239 | + export CONFIRM=1 |
| 240 | + sh ./util/env-bootstrap.sh |
| 241 | +
|
| 242 | + - name: Test QMK CLI |
| 243 | + run: | |
| 244 | + # Add QMK CLI to PATH (bootstrap script installs it to /opt/uv/tools/bin on Windows MSYS2) |
| 245 | + export PATH="/opt/uv/tools/bin:$PATH" |
| 246 | + qmk setup -y -H . # setup implies doctor, no need to run it separately |
| 247 | + qmk mass-compile -j $(nproc) -e DUMP_CI_METADATA=yes -f 'keyboard_name==*onekey*' -km reset || touch .failed # Compile a bunch of different platforms |
| 248 | + |
| 249 | + ./util/ci/generate_failure_markdown.sh > $GITHUB_STEP_SUMMARY || true |
| 250 | + [ ! -e .failed ] || exit 1 |
| 251 | +
|
0 commit comments