ci_build_major_branch.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. name: CI Build Major Branch
  2. permissions:
  3. contents: read
  4. actions: write
  5. on:
  6. push:
  7. branches: [master, develop]
  8. workflow_dispatch:
  9. inputs:
  10. branch:
  11. type: choice
  12. description: "Branch to build"
  13. options: [master, develop]
  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. slice_length: ${{ steps.generate_slice_length.outputs.slice_length }}
  30. steps:
  31. - name: Install prerequisites
  32. run: |
  33. apt-get update
  34. apt-get install -y jq
  35. - name: Disable safe.directory check
  36. run: |
  37. git config --global --add safe.directory '*'
  38. - name: Checkout QMK Firmware
  39. uses: actions/checkout@v4
  40. - name: Determine concurrency
  41. id: generate_slice_length
  42. run: |
  43. target_count=$( {
  44. qmk find -km default 2>/dev/null
  45. qmk find -km via 2>/dev/null
  46. } | sort | uniq | wc -l)
  47. slice_length=$((target_count / ($CONCURRENT_JOBS - 1))) # Err on the side of caution as we're splitting default and via
  48. echo "slice_length=$slice_length" >> $GITHUB_OUTPUT
  49. build_targets:
  50. name: "Compile keymap ${{ matrix.keymap }}"
  51. needs: determine_concurrency
  52. strategy:
  53. fail-fast: false
  54. matrix:
  55. keymap: [default, via]
  56. uses: ./.github/workflows/ci_build_major_branch_keymap.yml
  57. with:
  58. branch: ${{ inputs.branch || github.ref_name }}
  59. keymap: ${{ matrix.keymap }}
  60. slice_length: ${{ needs.determine_concurrency.outputs.slice_length }}
  61. secrets: inherit
  62. rollup_tasks:
  63. name: "Consolidation"
  64. needs: build_targets
  65. runs-on: ubuntu-latest
  66. steps:
  67. - name: Download firmwares
  68. uses: actions/download-artifact@v4
  69. with:
  70. pattern: firmware-*
  71. path: firmwares
  72. merge-multiple: true
  73. - name: Upload to https://ci.qmk.fm/${{ inputs.branch || github.ref_name }}/${{ github.sha }}
  74. uses: jakejarvis/s3-sync-action@master
  75. with:
  76. args: --acl public-read --follow-symlinks --delete
  77. env:
  78. AWS_S3_BUCKET: ${{ vars.CI_QMK_FM_SPACES_BUCKET }}
  79. AWS_ACCESS_KEY_ID: ${{ secrets.CI_QMK_FM_SPACES_KEY }}
  80. AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_QMK_FM_SPACES_SECRET }}
  81. AWS_REGION: ${{ vars.CI_QMK_FM_SPACES_REGION }}
  82. AWS_S3_ENDPOINT: ${{ vars.CI_QMK_FM_SPACES_ENDPOINT }}
  83. SOURCE_DIR: firmwares
  84. DEST_DIR: ${{ inputs.branch || github.ref_name }}/${{ github.sha }}
  85. - name: Upload to https://ci.qmk.fm/${{ inputs.branch || github.ref_name }}/latest
  86. uses: jakejarvis/s3-sync-action@master
  87. with:
  88. args: --acl public-read --follow-symlinks --delete
  89. env:
  90. AWS_S3_BUCKET: ${{ vars.CI_QMK_FM_SPACES_BUCKET }}
  91. AWS_ACCESS_KEY_ID: ${{ secrets.CI_QMK_FM_SPACES_KEY }}
  92. AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_QMK_FM_SPACES_SECRET }}
  93. AWS_REGION: ${{ vars.CI_QMK_FM_SPACES_REGION }}
  94. AWS_S3_ENDPOINT: ${{ vars.CI_QMK_FM_SPACES_ENDPOINT }}
  95. SOURCE_DIR: firmwares
  96. DEST_DIR: ${{ inputs.branch || github.ref_name }}/latest
  97. - name: Check if failure marker file exists
  98. id: check_failure_marker
  99. uses: andstor/file-existence-action@v3
  100. with:
  101. files: firmwares/.failed
  102. - name: Fail build if needed
  103. if: steps.check_failure_marker.outputs.files_exists == 'true'
  104. run: |
  105. # Exit with failure if the compilation stage failed
  106. exit 1