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