ci_build_major_branch.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. name: CI Build Major Branch
  2. permissions:
  3. contents: read
  4. actions: write
  5. on:
  6. push:
  7. branches: [master, develop, xap]
  8. workflow_dispatch:
  9. inputs:
  10. branch:
  11. type: choice
  12. description: "Branch to build"
  13. options: [master, develop, xap]
  14. env:
  15. # https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration#usage-limits
  16. # We've decreased it from 20 to 15 to allow for other GHA to run unimpeded
  17. CONCURRENT_JOBS: 15
  18. # Ensure we only have one build running at a time, cancelling any active builds if a new commit is pushed to the respective branch
  19. concurrency:
  20. group: ci_build-${{ github.event.inputs.branch || github.ref_name }}
  21. cancel-in-progress: true
  22. jobs:
  23. determine_concurrency:
  24. name: "Determine concurrency"
  25. if: github.repository == 'qmk/qmk_firmware'
  26. runs-on: ubuntu-latest
  27. container: ghcr.io/qmk/qmk_cli
  28. outputs:
  29. keymaps: ${{ steps.generate_slice_length.outputs.keymaps }}
  30. slice_length: ${{ steps.generate_slice_length.outputs.slice_length }}
  31. steps:
  32. - name: Disable safe.directory check
  33. run: |
  34. git config --global --add safe.directory '*'
  35. - name: Checkout QMK Firmware
  36. uses: actions/checkout@v7
  37. - name: Install dependencies
  38. run: pip3 install -r requirements-dev.txt
  39. - name: Determine concurrency
  40. id: generate_slice_length
  41. shell: 'bash {0}'
  42. run: |
  43. targets=()
  44. target_count=0
  45. for target in "default" "xap"; do
  46. count=$(qmk find -km $target 2>/dev/null | wc -l)
  47. if [ $count -gt 0 ]; then
  48. target_count=$(($target_count + $count))
  49. targets+=($target)
  50. fi
  51. done
  52. keymaps=$(jq -c -n '$ARGS.positional' --args "${targets[@]}")
  53. slice_length=$((target_count / ($CONCURRENT_JOBS - 1))) # Err on the side of caution
  54. echo "keymaps=$keymaps" >> $GITHUB_OUTPUT
  55. echo "slice_length=$slice_length" >> $GITHUB_OUTPUT
  56. build_targets:
  57. name: "Compile keymap ${{ matrix.keymap }}"
  58. needs: determine_concurrency
  59. strategy:
  60. fail-fast: false
  61. matrix:
  62. keymap: ${{ fromJson(needs.determine_concurrency.outputs.keymaps) }}
  63. uses: ./.github/workflows/ci_build_major_branch_keymap.yml
  64. with:
  65. branch: ${{ inputs.branch || github.ref_name }}
  66. keymap: ${{ matrix.keymap }}
  67. slice_length: ${{ needs.determine_concurrency.outputs.slice_length }}
  68. secrets: inherit
  69. rollup_tasks:
  70. name: "Consolidation"
  71. needs: build_targets
  72. runs-on: ubuntu-latest
  73. steps:
  74. - name: Disable safe.directory check
  75. run: |
  76. git config --global --add safe.directory '*'
  77. - name: Checkout QMK Firmware
  78. uses: actions/checkout@v7
  79. with:
  80. fetch-depth: 0
  81. - name: Download firmwares
  82. uses: actions/download-artifact@v8
  83. with:
  84. pattern: firmware-*
  85. path: .
  86. merge-multiple: true
  87. - name: Generate index page
  88. run: |
  89. python3 -m pip install -r ./util/ci/requirements.txt
  90. ./util/ci/index_generator.py > index.html
  91. ./util/ci/firmware_list_generator.py > firmware_list.json
  92. - name: Upload to https://ci.qmk.fm/${{ inputs.branch || github.ref_name }}/${{ github.sha }}
  93. uses: jakejarvis/s3-sync-action@master
  94. with:
  95. args: --acl public-read --follow-symlinks --delete --exclude '*' --include 'index.html' --include 'firmware_list.json' --include '*.hex' --include '*.bin' --include '*.uf2'
  96. env:
  97. AWS_S3_BUCKET: ${{ vars.CI_QMK_FM_SPACES_BUCKET }}
  98. AWS_ACCESS_KEY_ID: ${{ secrets.CI_QMK_FM_SPACES_KEY }}
  99. AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_QMK_FM_SPACES_SECRET }}
  100. AWS_REGION: ${{ vars.CI_QMK_FM_SPACES_REGION }}
  101. AWS_S3_ENDPOINT: ${{ vars.CI_QMK_FM_SPACES_ENDPOINT }}
  102. SOURCE_DIR: .
  103. DEST_DIR: ${{ inputs.branch || github.ref_name }}/${{ github.sha }}
  104. - name: Upload to https://ci.qmk.fm/${{ inputs.branch || github.ref_name }}/latest
  105. uses: jakejarvis/s3-sync-action@master
  106. with:
  107. args: --acl public-read --follow-symlinks --delete --exclude '*' --include 'index.html' --include 'firmware_list.json' --include '*.hex' --include '*.bin' --include '*.uf2'
  108. env:
  109. AWS_S3_BUCKET: ${{ vars.CI_QMK_FM_SPACES_BUCKET }}
  110. AWS_ACCESS_KEY_ID: ${{ secrets.CI_QMK_FM_SPACES_KEY }}
  111. AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_QMK_FM_SPACES_SECRET }}
  112. AWS_REGION: ${{ vars.CI_QMK_FM_SPACES_REGION }}
  113. AWS_S3_ENDPOINT: ${{ vars.CI_QMK_FM_SPACES_ENDPOINT }}
  114. SOURCE_DIR: .
  115. DEST_DIR: ${{ inputs.branch || github.ref_name }}/latest
  116. - name: Fail build if needed
  117. run: |
  118. # Exit with failure if the compilation stage failed
  119. [ ! -e .failed ] || exit 1