CI: rework build workflow to have split target and subtarget directly
Instead of referring to a redundant job and ENV variables, rework build workflow to accept and require split target and subtarget and use them directly from inputs. Rework each user and pass a JSON of tuple to matrix include with each target/subtarget combination to test. Special notice this doesn't use the github actions matrix combination feature but reference each specific tuple of target and subtarget to test. Just a cleanup no behaviour change intended. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
This commit is contained in:
		
							
								
								
									
										32
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										32
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							| @@ -8,6 +8,9 @@ on: | |||||||
|       target: |       target: | ||||||
|         required: true |         required: true | ||||||
|         type: string |         type: string | ||||||
|  |       subtarget: | ||||||
|  |         required: true | ||||||
|  |         type: string | ||||||
|       testing: |       testing: | ||||||
|         type: boolean |         type: boolean | ||||||
|       build_toolchain: |       build_toolchain: | ||||||
| @@ -50,7 +53,7 @@ permissions: | |||||||
|  |  | ||||||
| jobs: | jobs: | ||||||
|   setup_build: |   setup_build: | ||||||
|     name: Setup build ${{ inputs.target }} |     name: Setup build ${{ inputs.target }}/${{ inputs.subtarget }} | ||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
|     outputs: |     outputs: | ||||||
|       owner_lc: ${{ steps.lower_owner.outputs.owner_lc }} |       owner_lc: ${{ steps.lower_owner.outputs.owner_lc }} | ||||||
| @@ -109,7 +112,7 @@ jobs: | |||||||
|           echo "container_tag=$CONTAINER_TAG" >> $GITHUB_OUTPUT |           echo "container_tag=$CONTAINER_TAG" >> $GITHUB_OUTPUT | ||||||
|  |  | ||||||
|   build: |   build: | ||||||
|     name: Build ${{ inputs.target }} |     name: Build ${{ inputs.target }}/${{ inputs.subtarget }} | ||||||
|     needs: setup_build |     needs: setup_build | ||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
|  |  | ||||||
| @@ -157,13 +160,6 @@ jobs: | |||||||
|         run: | |         run: | | ||||||
|           chown -R buildbot:buildbot openwrt |           chown -R buildbot:buildbot openwrt | ||||||
|  |  | ||||||
|       - name: Initialization environment |  | ||||||
|         run: | |  | ||||||
|           TARGET=$(echo ${{ inputs.target }} | cut -d "/" -f 1) |  | ||||||
|           SUBTARGET=$(echo ${{ inputs.target }} | cut -d "/" -f 2) |  | ||||||
|           echo "TARGET=$TARGET" >> "$GITHUB_ENV" |  | ||||||
|           echo "SUBTARGET=$SUBTARGET" >> "$GITHUB_ENV" |  | ||||||
|  |  | ||||||
|       - name: Prepare prebuilt tools |       - name: Prepare prebuilt tools | ||||||
|         shell: su buildbot -c "sh -e {0}" |         shell: su buildbot -c "sh -e {0}" | ||||||
|         working-directory: openwrt |         working-directory: openwrt | ||||||
| @@ -213,7 +209,7 @@ jobs: | |||||||
|             fi |             fi | ||||||
|           fi |           fi | ||||||
|  |  | ||||||
|           SUMS_FILE="https://downloads.cdn.openwrt.org/$TOOLCHAIN_PATH/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/sha256sums" |           SUMS_FILE="https://downloads.cdn.openwrt.org/$TOOLCHAIN_PATH/targets/${{ inputs.target }}/${{ inputs.subtarget }}/sha256sums" | ||||||
|           if curl $SUMS_FILE | grep -q ".*openwrt-toolchain.*tar.xz"; then |           if curl $SUMS_FILE | grep -q ".*openwrt-toolchain.*tar.xz"; then | ||||||
|             TOOLCHAIN_STRING="$( curl $SUMS_FILE | grep ".*openwrt-toolchain.*tar.xz")" |             TOOLCHAIN_STRING="$( curl $SUMS_FILE | grep ".*openwrt-toolchain.*tar.xz")" | ||||||
|             TOOLCHAIN_FILE=$(echo "$TOOLCHAIN_STRING" | sed -n -e 's/.*\(openwrt-toolchain.*\).tar.xz/\1/p') |             TOOLCHAIN_FILE=$(echo "$TOOLCHAIN_STRING" | sed -n -e 's/.*\(openwrt-toolchain.*\).tar.xz/\1/p') | ||||||
| @@ -235,16 +231,16 @@ jobs: | |||||||
|         uses: actions/cache@v3 |         uses: actions/cache@v3 | ||||||
|         with: |         with: | ||||||
|           path: openwrt/.ccache |           path: openwrt/.ccache | ||||||
|           key: ccache-kernel-${{ env.TARGET }}/${{ env.SUBTARGET }}-${{ needs.setup_build.outputs.ccache_hash }} |           key: ccache-kernel-${{ inputs.target }}/${{ inputs.subtarget }}-${{ needs.setup_build.outputs.ccache_hash }} | ||||||
|           restore-keys: | |           restore-keys: | | ||||||
|             ccache-kernel-${{ env.TARGET }}/${{ env.SUBTARGET }}- |             ccache-kernel-${{ inputs.target }}/${{ inputs.subtarget }}- | ||||||
|  |  | ||||||
|       - name: Download external toolchain/sdk |       - name: Download external toolchain/sdk | ||||||
|         if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type != 'internal' |         if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type != 'internal' | ||||||
|         shell: su buildbot -c "sh -e {0}" |         shell: su buildbot -c "sh -e {0}" | ||||||
|         working-directory: openwrt |         working-directory: openwrt | ||||||
|         run: | |         run: | | ||||||
|           wget -O - https://downloads.cdn.openwrt.org/${{ env.TOOLCHAIN_PATH }}/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/${{ env.TOOLCHAIN_FILE }}.tar.xz \ |           wget -O - https://downloads.cdn.openwrt.org/${{ env.TOOLCHAIN_PATH }}/targets/${{ inputs.target }}/${{ inputs.subtarget }}/${{ env.TOOLCHAIN_FILE }}.tar.xz \ | ||||||
|             | tar --xz -xf - |             | tar --xz -xf - | ||||||
|  |  | ||||||
|       - name: Configure testing kernel |       - name: Configure testing kernel | ||||||
| @@ -289,7 +285,7 @@ jobs: | |||||||
|           ./scripts/ext-toolchain.sh \ |           ./scripts/ext-toolchain.sh \ | ||||||
|             --toolchain ${{ env.TOOLCHAIN_FILE }}/toolchain-* \ |             --toolchain ${{ env.TOOLCHAIN_FILE }}/toolchain-* \ | ||||||
|             --overwrite-config \ |             --overwrite-config \ | ||||||
|             --config ${{ env.TARGET }}/${{ env.SUBTARGET }} |             --config ${{ inputs.target }}/${{ inputs.subtarget }} | ||||||
|  |  | ||||||
|       - name: Adapt external sdk to external toolchain format |       - name: Adapt external sdk to external toolchain format | ||||||
|         if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type == 'external_sdk' |         if: inputs.build_toolchain == false && steps.parse-toolchain.outputs.toolchain-type == 'external_sdk' | ||||||
| @@ -331,7 +327,7 @@ jobs: | |||||||
|           ./scripts/ext-toolchain.sh \ |           ./scripts/ext-toolchain.sh \ | ||||||
|             --toolchain ${{ env.TOOLCHAIN_FILE }}/staging_dir/toolchain-* \ |             --toolchain ${{ env.TOOLCHAIN_FILE }}/staging_dir/toolchain-* \ | ||||||
|             --overwrite-config \ |             --overwrite-config \ | ||||||
|             --config ${{ env.TARGET }}/${{ env.SUBTARGET }} |             --config ${{ inputs.target }}/${{ inputs.subtarget }} | ||||||
|  |  | ||||||
|       - name: Configure internal toolchain |       - name: Configure internal toolchain | ||||||
|         if: inputs.build_toolchain == true || steps.parse-toolchain.outputs.toolchain-type == 'internal' |         if: inputs.build_toolchain == true || steps.parse-toolchain.outputs.toolchain-type == 'internal' | ||||||
| @@ -342,8 +338,8 @@ jobs: | |||||||
|           echo CONFIG_AUTOREMOVE=y >> .config |           echo CONFIG_AUTOREMOVE=y >> .config | ||||||
|           echo CONFIG_CCACHE=y >> .config |           echo CONFIG_CCACHE=y >> .config | ||||||
|  |  | ||||||
|           echo "CONFIG_TARGET_${{ env.TARGET }}=y" >> .config |           echo "CONFIG_TARGET_${{ inputs.target }}=y" >> .config | ||||||
|           echo "CONFIG_TARGET_${{ env.TARGET }}_${{ env.SUBTARGET }}=y" >> .config |           echo "CONFIG_TARGET_${{ inputs.target }}_${{ inputs.subtarget }}=y" >> .config | ||||||
|  |  | ||||||
|           make defconfig |           make defconfig | ||||||
|  |  | ||||||
| @@ -435,5 +431,5 @@ jobs: | |||||||
|         if: failure() |         if: failure() | ||||||
|         uses: actions/upload-artifact@v3 |         uses: actions/upload-artifact@v3 | ||||||
|         with: |         with: | ||||||
|           name: ${{ env.TARGET }}-${{ env.SUBTARGET }}-logs |           name: ${{ inputs.target }}-${{ inputs.subtarget }}-logs | ||||||
|           path: "openwrt/logs" |           path: "openwrt/logs" | ||||||
|   | |||||||
							
								
								
									
										26
									
								
								.github/workflows/check-kernel-patches.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										26
									
								
								.github/workflows/check-kernel-patches.yml
									
									
									
									
										vendored
									
									
								
							| @@ -6,6 +6,9 @@ on: | |||||||
|       target: |       target: | ||||||
|         required: true |         required: true | ||||||
|         type: string |         type: string | ||||||
|  |       subtarget: | ||||||
|  |         required: true | ||||||
|  |         type: string | ||||||
|       testing: |       testing: | ||||||
|         type: boolean |         type: boolean | ||||||
|       use_openwrt_container: |       use_openwrt_container: | ||||||
| @@ -85,13 +88,6 @@ jobs: | |||||||
|         run: | |         run: | | ||||||
|           chown -R buildbot:buildbot openwrt |           chown -R buildbot:buildbot openwrt | ||||||
|  |  | ||||||
|       - name: Initialization environment |  | ||||||
|         run: | |  | ||||||
|           TARGET=$(echo ${{ inputs.target }} | cut -d "/" -f 1) |  | ||||||
|           SUBTARGET=$(echo ${{ inputs.target }} | cut -d "/" -f 2) |  | ||||||
|           echo "TARGET=$TARGET" >> "$GITHUB_ENV" |  | ||||||
|           echo "SUBTARGET=$SUBTARGET" >> "$GITHUB_ENV" |  | ||||||
|  |  | ||||||
|       - name: Prepare prebuilt tools |       - name: Prepare prebuilt tools | ||||||
|         shell: su buildbot -c "sh -e {0}" |         shell: su buildbot -c "sh -e {0}" | ||||||
|         working-directory: openwrt |         working-directory: openwrt | ||||||
| @@ -118,8 +114,8 @@ jobs: | |||||||
|           echo CONFIG_AUTOREMOVE=y >> .config |           echo CONFIG_AUTOREMOVE=y >> .config | ||||||
|           echo CONFIG_CCACHE=y >> .config |           echo CONFIG_CCACHE=y >> .config | ||||||
|  |  | ||||||
|           echo "CONFIG_TARGET_${{ env.TARGET }}=y" >> .config |           echo "CONFIG_TARGET_${{ inputs.target }}=y" >> .config | ||||||
|           echo "CONFIG_TARGET_${{ env.TARGET }}_${{ env.SUBTARGET }}=y" >> .config |           echo "CONFIG_TARGET_${{ inputs.target }}_${{ inputs.subtarget }}=y" >> .config | ||||||
|  |  | ||||||
|           make defconfig |           make defconfig | ||||||
|  |  | ||||||
| @@ -140,13 +136,13 @@ jobs: | |||||||
|           . .github/workflows/scripts/ci_helpers.sh |           . .github/workflows/scripts/ci_helpers.sh | ||||||
|  |  | ||||||
|           if git diff --name-only --exit-code; then |           if git diff --name-only --exit-code; then | ||||||
|             success "Kernel patches for ${{ env.TARGET }}/${{ env.SUBTARGET }} seems ok" |             success "Kernel patches for ${{ inputs.target }}/${{ inputs.subtarget }} seems ok" | ||||||
|           else |           else | ||||||
|             err "Kernel patches for ${{ env.TARGET }}/${{ env.SUBTARGET }} require refresh. (run 'make target/linux/refresh' and force push this pr)" |             err "Kernel patches for ${{ inputs.target }}/${{ inputs.subtarget }} require refresh. (run 'make target/linux/refresh' and force push this pr)" | ||||||
|             err "You can also check the provided artifacts with the refreshed patch from this CI run." |             err "You can also check the provided artifacts with the refreshed patch from this CI run." | ||||||
|             mkdir ${{ env.TARGET }}-${{ env.SUBTARGET }}-refreshed |             mkdir ${{ inputs.target }}-${{ inputs.subtarget }}-refreshed | ||||||
|             for f in $(git diff --name-only); do |             for f in $(git diff --name-only); do | ||||||
|               cp --parents $f ${{ env.TARGET }}-${{ env.SUBTARGET }}-refreshed/ |               cp --parents $f ${{ inputs.target }}-${{ inputs.subtarget }}-refreshed/ | ||||||
|             done |             done | ||||||
|             exit 1 |             exit 1 | ||||||
|           fi |           fi | ||||||
| @@ -155,5 +151,5 @@ jobs: | |||||||
|         if: failure() |         if: failure() | ||||||
|         uses: actions/upload-artifact@v3 |         uses: actions/upload-artifact@v3 | ||||||
|         with: |         with: | ||||||
|           name: ${{ env.TARGET }}-${{ env.SUBTARGET }}-refreshed |           name: ${{ inputs.target }}-${{ inputs.subtarget }}-refreshed | ||||||
|           path: openwrt/${{ env.TARGET }}-${{ env.SUBTARGET }}-refreshed |           path: openwrt/${{ inputs.target }}-${{ inputs.subtarget }}-refreshed | ||||||
|   | |||||||
							
								
								
									
										3
									
								
								.github/workflows/coverity.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.github/workflows/coverity.yml
									
									
									
									
										vendored
									
									
								
							| @@ -17,7 +17,8 @@ jobs: | |||||||
|       packages: read |       packages: read | ||||||
|     uses: ./.github/workflows/build.yml |     uses: ./.github/workflows/build.yml | ||||||
|     with: |     with: | ||||||
|       target: x86/64 |       target: x86 | ||||||
|  |       subtarget: 64 | ||||||
|       build_full: true |       build_full: true | ||||||
|       include_feeds: true |       include_feeds: true | ||||||
|       coverity_compiler_template_list: >- |       coverity_compiler_template_list: >- | ||||||
|   | |||||||
							
								
								
									
										12
									
								
								.github/workflows/kernel.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								.github/workflows/kernel.yml
									
									
									
									
										vendored
									
									
								
							| @@ -64,8 +64,9 @@ jobs: | |||||||
|             if echo "$CHANGED_FILES" | grep -v -q target/linux || |             if echo "$CHANGED_FILES" | grep -v -q target/linux || | ||||||
|               echo "$CHANGED_FILES" | grep -q target/linux/generic || |               echo "$CHANGED_FILES" | grep -q target/linux/generic || | ||||||
|               echo "$CHANGED_FILES" | grep -q $(echo $TARGET | cut -d "/" -f 1); then |               echo "$CHANGED_FILES" | grep -q $(echo $TARGET | cut -d "/" -f 1); then | ||||||
|  |               TUPLE='{"target":"'"$(echo $TARGET | cut -d "/" -f 1)"'","subtarget":"'"$(echo $TARGET | cut -d "/" -f 2)"'"}' | ||||||
|               [[ $FIRST -ne 1 ]] && JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"',' |               [[ $FIRST -ne 1 ]] && JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"',' | ||||||
|               JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"'"'"${TARGET}"'"' |               JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS""$TUPLE" | ||||||
|               FIRST=0 |               FIRST=0 | ||||||
|             fi |             fi | ||||||
|           done |           done | ||||||
| @@ -77,8 +78,9 @@ jobs: | |||||||
|             if echo "$CHANGED_FILES" | grep -v -q target/linux || |             if echo "$CHANGED_FILES" | grep -v -q target/linux || | ||||||
|               echo "$CHANGED_FILES" | grep -q target/linux/generic || |               echo "$CHANGED_FILES" | grep -q target/linux/generic || | ||||||
|               echo "$CHANGED_FILES" | grep -q $(echo $TARGET | cut -d "/" -f 1); then |               echo "$CHANGED_FILES" | grep -q $(echo $TARGET | cut -d "/" -f 1); then | ||||||
|  |               TUPLE='{"target":"'"$(echo $TARGET | cut -d "/" -f 1)"'","subtarget":"'"$(echo $TARGET | cut -d "/" -f 2)"'"}' | ||||||
|               [[ $FIRST -ne 1 ]] && JSON_TARGETS="$JSON_TARGETS"',' |               [[ $FIRST -ne 1 ]] && JSON_TARGETS="$JSON_TARGETS"',' | ||||||
|               JSON_TARGETS="$JSON_TARGETS"'"'"${TARGET}"'"' |               JSON_TARGETS="$JSON_TARGETS""$TUPLE" | ||||||
|               FIRST=0 |               FIRST=0 | ||||||
|             fi |             fi | ||||||
|           done |           done | ||||||
| @@ -104,10 +106,11 @@ jobs: | |||||||
|     strategy: |     strategy: | ||||||
|        fail-fast: False |        fail-fast: False | ||||||
|        matrix: |        matrix: | ||||||
|          target: ${{fromJson(needs.determine_targets.outputs.targets_subtargets)}} |          include: ${{fromJson(needs.determine_targets.outputs.targets_subtargets)}} | ||||||
|     uses: ./.github/workflows/build.yml |     uses: ./.github/workflows/build.yml | ||||||
|     with: |     with: | ||||||
|       target: ${{ matrix.target }} |       target: ${{ matrix.target }} | ||||||
|  |       subtarget: ${{ matrix.subtarget }} | ||||||
|       build_kernel: true |       build_kernel: true | ||||||
|       build_all_kmods: true |       build_all_kmods: true | ||||||
|  |  | ||||||
| @@ -120,8 +123,9 @@ jobs: | |||||||
|     strategy: |     strategy: | ||||||
|        fail-fast: False |        fail-fast: False | ||||||
|        matrix: |        matrix: | ||||||
|          target: ${{fromJson(needs.determine_targets.outputs.targets)}} |          include: ${{fromJson(needs.determine_targets.outputs.targets)}} | ||||||
|     uses: ./.github/workflows/check-kernel-patches.yml |     uses: ./.github/workflows/check-kernel-patches.yml | ||||||
|     with: |     with: | ||||||
|       target: ${{ matrix.target }} |       target: ${{ matrix.target }} | ||||||
|  |       subtarget: ${{ matrix.subtarget }} | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										7
									
								
								.github/workflows/packages.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								.github/workflows/packages.yml
									
									
									
									
										vendored
									
									
								
							| @@ -37,11 +37,14 @@ jobs: | |||||||
|       fail-fast: False |       fail-fast: False | ||||||
|       matrix: |       matrix: | ||||||
|         include: |         include: | ||||||
|           - target: malta/be |           - target: malta | ||||||
|           - target: x86/64 |             subtarget: be | ||||||
|  |           - target: x86 | ||||||
|  |             subtarget: 64 | ||||||
|     uses: ./.github/workflows/build.yml |     uses: ./.github/workflows/build.yml | ||||||
|     with: |     with: | ||||||
|       target: ${{ matrix.target }} |       target: ${{ matrix.target }} | ||||||
|  |       subtarget: ${{ matrix.subtarget }} | ||||||
|       build_kernel: true |       build_kernel: true | ||||||
|       build_all_kmods: true |       build_all_kmods: true | ||||||
|       build_all_modules: true |       build_all_modules: true | ||||||
|   | |||||||
							
								
								
									
										6
									
								
								.github/workflows/toolchain.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.github/workflows/toolchain.yml
									
									
									
									
										vendored
									
									
								
							| @@ -40,8 +40,9 @@ jobs: | |||||||
|           JSON='[' |           JSON='[' | ||||||
|           FIRST=1 |           FIRST=1 | ||||||
|           for TARGET in $TARGETS; do |           for TARGET in $TARGETS; do | ||||||
|  |             TUPLE='{"target":"'"$(echo $TARGET | cut -d "/" -f 1)"'","subtarget":"'"$(echo $TARGET | cut -d "/" -f 2)"'"}' | ||||||
|             [[ $FIRST -ne 1 ]] && JSON="$JSON"',' |             [[ $FIRST -ne 1 ]] && JSON="$JSON"',' | ||||||
|             JSON="$JSON"'"'"${TARGET}"'"' |             JSON="$JSON""$TUPLE" | ||||||
|             FIRST=0 |             FIRST=0 | ||||||
|           done |           done | ||||||
|           JSON="$JSON"']' |           JSON="$JSON"']' | ||||||
| @@ -61,8 +62,9 @@ jobs: | |||||||
|     strategy: |     strategy: | ||||||
|        fail-fast: False |        fail-fast: False | ||||||
|        matrix: |        matrix: | ||||||
|          target: ${{fromJson(needs.determine_targets.outputs.target)}} |          include: ${{fromJson(needs.determine_targets.outputs.target)}} | ||||||
|     uses: ./.github/workflows/build.yml |     uses: ./.github/workflows/build.yml | ||||||
|     with: |     with: | ||||||
|       target: ${{ matrix.target }} |       target: ${{ matrix.target }} | ||||||
|  |       subtarget: ${{ matrix.subtarget }} | ||||||
|       build_toolchain: true |       build_toolchain: true | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Christian Marangi
					Christian Marangi