bootstrap_testing.yml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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: Install dependencies
  125. run: |
  126. sudo -u testuser bash -c "
  127. /home/testuser/.local/share/uv/tools/qmk/bin/python -m pip install -r /home/testuser/qmk_firmware/requirements.txt
  128. "
  129. - name: Test QMK CLI
  130. run: |
  131. sudo -u testuser bash -c "
  132. export PATH=/home/testuser/.local/bin:\$PATH
  133. cd /home/testuser
  134. qmk setup -y -H /home/testuser/qmk_firmware # setup implies doctor, no need to run it separately
  135. cd /home/testuser/qmk_firmware
  136. 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
  137. "
  138. cd /home/testuser/qmk_firmware
  139. ./util/ci/generate_failure_markdown.sh > $GITHUB_STEP_SUMMARY || true
  140. [ ! -e .failed ] || exit 1
  141. bootstrap-test-macos:
  142. name: Bootstrap (macOS)
  143. strategy:
  144. fail-fast: false
  145. matrix:
  146. os:
  147. - macos-14 # Apple Silicon ARM64
  148. - macos-15 # Apple Silicon ARM64
  149. - macos-15-intel # Intel x64
  150. - macos-26 # Apple Silicon ARM64
  151. runs-on: ${{ matrix.os }}
  152. steps:
  153. - name: Checkout repository
  154. uses: actions/checkout@v6
  155. with:
  156. fetch-depth: 1
  157. submodules: recursive
  158. - name: Run bootstrap script
  159. env:
  160. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  161. run: |
  162. # Add upstream remote to the cloned repository so `qmk doctor` doesn't flag a warning
  163. git remote add upstream https://github.com/qmk/qmk_firmware.git
  164. # Run the bootstrap script
  165. export CONFIRM=1
  166. sh ./util/env-bootstrap.sh
  167. - name: Install dependencies
  168. run: |
  169. $HOME/.local/share/uv/tools/qmk/bin/python -m pip install -r requirements.txt
  170. - name: Test QMK CLI
  171. run: |
  172. # Add QMK CLI to PATH (bootstrap script installs it to ~/.local/bin on macOS)
  173. export PATH="$HOME/.local/bin:$PATH"
  174. qmk setup -y -H . # setup implies doctor, no need to run it separately
  175. 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
  176. ./util/ci/generate_failure_markdown.sh > $GITHUB_STEP_SUMMARY || true
  177. [ ! -e .failed ] || exit 1
  178. bootstrap-test-windows:
  179. name: Bootstrap (Windows)
  180. strategy:
  181. fail-fast: false
  182. matrix:
  183. msys-variant:
  184. - mingw64
  185. - clang64
  186. - ucrt64
  187. runs-on: windows-latest
  188. defaults:
  189. run:
  190. shell: msys2 {0}
  191. steps:
  192. - name: Install MSYS2
  193. uses: msys2/setup-msys2@v2
  194. with:
  195. msystem: ${{ matrix.msys-variant }}
  196. pacboy: >-
  197. git:
  198. - name: Checkout repository
  199. uses: actions/checkout@v6
  200. with:
  201. fetch-depth: 1
  202. submodules: recursive
  203. - name: Run bootstrap script
  204. env:
  205. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  206. run: |
  207. # Add upstream remote to the cloned repository so `qmk doctor` doesn't flag a warning
  208. git remote add upstream https://github.com/qmk/qmk_firmware.git
  209. # Run the bootstrap script
  210. export CONFIRM=1
  211. sh ./util/env-bootstrap.sh
  212. - name: Install dependencies
  213. run: |
  214. /opt/uv/tools/qmk/Scripts/python -m pip install -r requirements.txt
  215. - name: Test QMK CLI
  216. run: |
  217. # Add QMK CLI to PATH (bootstrap script installs it to /opt/uv/tools/bin on Windows MSYS2)
  218. export PATH="/opt/uv/tools/bin:$PATH"
  219. qmk setup -y -H . # setup implies doctor, no need to run it separately
  220. qmk mass-compile -j $(nproc) -e DUMP_CI_METADATA=yes -f 'keyboard_name==*onekey*' -km reset || touch .failed # Compile a bunch of different platforms
  221. ./util/ci/generate_failure_markdown.sh > $GITHUB_STEP_SUMMARY || true
  222. [ ! -e .failed ] || exit 1