bootstrap_testing.yml 8.4 KB

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