logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

ci_build_major_branch_keymap.yml (5447B)


  1. name: CI Build Major Branch Keymap
  2. permissions:
  3. contents: read
  4. actions: write
  5. on:
  6. workflow_call:
  7. inputs:
  8. branch:
  9. type: string
  10. required: true
  11. keymap:
  12. type: string
  13. required: true
  14. slice_length:
  15. type: string
  16. required: true
  17. jobs:
  18. generate_targets:
  19. name: "Generate targets (${{ inputs.keymap }})"
  20. runs-on: ubuntu-latest
  21. container: ghcr.io/qmk/qmk_cli
  22. outputs:
  23. targets: ${{ steps.generate_targets.outputs.targets }}
  24. steps:
  25. - name: Install prerequisites
  26. run: |
  27. apt-get update
  28. apt-get install -y jq
  29. - name: Disable safe.directory check
  30. run: |
  31. git config --global --add safe.directory '*'
  32. - name: Checkout QMK Firmware
  33. uses: actions/checkout@v4
  34. - name: Generate build targets
  35. id: generate_targets
  36. run: |
  37. { # Intentionally use `shuf` here so that we share manufacturers across all build groups -- some have a lot of ARM-based boards which inherently take longer
  38. counter=0
  39. echo -n '{'
  40. qmk find -km ${{ inputs.keymap }} 2>/dev/null | sort | uniq | shuf | xargs -L${{ inputs.slice_length }} | while IFS=$'\n' read target ; do
  41. if [ $counter -gt 0 ]; then
  42. echo -n ','
  43. fi
  44. counter=$((counter+1))
  45. printf "\"group %02d\":{" $counter
  46. echo -n '"targets":"'
  47. echo $target | tr ' ' '\n' | sort | uniq | xargs echo -n
  48. echo -n '"}'
  49. done
  50. echo -n '}'
  51. } | sed -e 's@\n@@g' > targets.json
  52. # Output the target keys as a variable
  53. echo "targets=$(jq -c 'keys' targets.json)" >> $GITHUB_OUTPUT
  54. - name: Upload targets json
  55. uses: actions/upload-artifact@v4
  56. with:
  57. name: targets-${{ inputs.keymap }}
  58. path: targets.json
  59. build_targets:
  60. name: "Compile ${{ matrix.target }} (${{ inputs.keymap }})"
  61. needs: generate_targets
  62. runs-on: ubuntu-latest
  63. container: ghcr.io/qmk/qmk_cli
  64. continue-on-error: true
  65. strategy:
  66. matrix:
  67. target: ${{ fromJson(needs.generate_targets.outputs.targets) }}
  68. steps:
  69. - name: Install prerequisites
  70. run: |
  71. apt-get update
  72. apt-get install -y jq
  73. - name: Disable safe.directory check
  74. run: |
  75. git config --global --add safe.directory '*'
  76. - name: Checkout QMK Firmware
  77. uses: actions/checkout@v4
  78. - name: Get target definitions
  79. uses: actions/download-artifact@v5
  80. with:
  81. name: targets-${{ inputs.keymap }}
  82. path: .
  83. - name: Deploy submodules
  84. run: |
  85. qmk git-submodule -f
  86. - name: Dump targets
  87. run: |
  88. jq -r '.["${{ matrix.target }}"].targets' targets.json | tr ' ' '\n' | sort
  89. - name: Build targets
  90. continue-on-error: true
  91. run: |
  92. export NCPUS=$(( $(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null) -1 ))
  93. qmk mass-compile -t -j $NCPUS -e DUMP_CI_METADATA=yes $(jq -r '.["${{ matrix.target }}"].targets' targets.json) || touch .failed
  94. - name: Upload binaries
  95. uses: actions/upload-artifact@v4
  96. with:
  97. name: firmware-${{ inputs.keymap }}-${{ matrix.target }}
  98. if-no-files-found: ignore
  99. path: |
  100. *.bin
  101. *.hex
  102. *.uf2
  103. .build/failed.*
  104. .failed
  105. - name: Fail build if any group failed
  106. run: |
  107. # Exit with failure if the compilation stage failed
  108. [ ! -f .failed ] || exit 1
  109. repack_firmware:
  110. if: always()
  111. name: "Repack artifacts"
  112. needs: build_targets
  113. runs-on: ubuntu-latest
  114. steps:
  115. - name: Checkout QMK Firmware
  116. uses: actions/checkout@v4
  117. - name: Download firmwares
  118. uses: actions/download-artifact@v5
  119. with:
  120. pattern: firmware-${{ inputs.keymap }}-*
  121. path: .
  122. merge-multiple: true
  123. - name: Upload all firmwares
  124. uses: actions/upload-artifact@v4
  125. with:
  126. name: firmware-${{ inputs.keymap }}
  127. if-no-files-found: ignore
  128. path: |
  129. *.bin
  130. *.hex
  131. *.uf2
  132. .build/failed.*
  133. .failed
  134. - name: Generate output logs
  135. run: |
  136. # Generate the step summary markdown
  137. ./util/ci/generate_failure_markdown.sh > $GITHUB_STEP_SUMMARY || true
  138. # Truncate to a maximum of 1MB to deal with GitHub workflow limit
  139. truncate --size='<960K' $GITHUB_STEP_SUMMARY || true
  140. - name: Delete temporary build artifacts
  141. uses: geekyeggo/delete-artifact@v5
  142. with:
  143. name: |
  144. firmware-${{ inputs.keymap }}-*
  145. targets-${{ inputs.keymap }}
  146. - name: 'CI Discord Notification'
  147. if: always() && !cancelled()
  148. working-directory: util/ci/
  149. env:
  150. DISCORD_WEBHOOK: ${{ secrets.CI_DISCORD_WEBHOOK }}
  151. run: |
  152. python3 -m pip install -r requirements.txt
  153. python3 ./discord-results.py --branch ${{ inputs.branch || github.ref_name }} --sha $(git rev-parse HEAD) --keymap ${{ inputs.keymap }} --url ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}