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