bootstrap_testing.yml 8.5 KB

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