label-kernel.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. # ci:kernel:x86:64 is going to trigger CI kernel check jobs for x86/64 target
  2. name: Build kernel and check patches for target specified in labels
  3. on:
  4. pull_request:
  5. types:
  6. - labeled
  7. jobs:
  8. set_target:
  9. if: startsWith(github.event.label.name, 'ci:kernel:')
  10. name: Set target
  11. runs-on: ubuntu-latest
  12. outputs:
  13. targets_subtargets: ${{ steps.set_target.outputs.targets_subtargets }}
  14. targets: ${{ steps.set_target.outputs.targets }}
  15. steps:
  16. - name: Checkout
  17. uses: actions/checkout@v3
  18. - name: Parse label
  19. id: parse_label
  20. env:
  21. CI_EVENT_LABEL_NAME: ${{ github.event.label.name }}
  22. run: |
  23. echo "$CI_EVENT_LABEL_NAME" | sed -n 's/ci:kernel:\([^:]*\):\([^:]*\):*\([^:]*\)$/target=\1/p' | tee --append $GITHUB_OUTPUT
  24. echo "$CI_EVENT_LABEL_NAME" | sed -n 's/ci:kernel:\([^:]*\):\([^:]*\):*\([^:]*\)$/subtarget=\2/p' | tee --append $GITHUB_OUTPUT
  25. echo "$CI_EVENT_LABEL_NAME" | sed -n 's/ci:kernel:\([^:]*\):\([^:]*\):*\([^:]*\)$/testing=\3/p' | tee --append $GITHUB_OUTPUT
  26. - name: Set targets
  27. id: set_target
  28. run: |
  29. ALL_TARGETS="$(perl ./scripts/dump-target-info.pl kernels 2>/dev/null)"
  30. TARGETS_SUBTARGETS="$(echo "$ALL_TARGETS" | sort -u -t '/' -k1)"
  31. TARGETS="$(echo "$ALL_TARGETS" | sort -u -t '/' -k1,1)"
  32. [ "${{ steps.parse_label.outputs.subtarget }}" = "first" ] && TARGETS_SUBTARGETS=$TARGETS
  33. JSON_TARGETS_SUBTARGETS='['
  34. FIRST=1
  35. while IFS= read -r line; do
  36. TARGET_SUBTARGET=$(echo $line | cut -d " " -f 1)
  37. TARGET=$(echo $TARGET_SUBTARGET | cut -d "/" -f 1)
  38. SUBTARGET=$(echo $TARGET_SUBTARGET | cut -d "/" -f 2)
  39. [ "${{ steps.parse_label.outputs.target }}" != "all" ] && [ "${{ steps.parse_label.outputs.target }}" != "$TARGET" ] && continue
  40. [ "${{ steps.parse_label.outputs.subtarget }}" != "all" ] && [ "${{ steps.parse_label.outputs.subtarget }}" != "first" ] &&
  41. [ "${{ steps.parse_label.outputs.subtarget }}" != $SUBTARGET ] && continue
  42. if [ "${{ steps.parse_label.outputs.testing }}" = "testing" ]; then
  43. TESTING_KERNEL_VER=$(echo $line | cut -d " " -f 3)
  44. [ -z "$TESTING_KERNEL_VER" ] && continue
  45. fi
  46. TUPLE='{"target":"'"$TARGET"'","subtarget":"'"$SUBTARGET"'","testing":"'"$TESTING_KERNEL_VER"'"}'
  47. [[ $FIRST -ne 1 ]] && JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"','
  48. JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS""$TUPLE"
  49. FIRST=0
  50. done <<< "$TARGETS_SUBTARGETS"
  51. JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"']'
  52. JSON_TARGETS='['
  53. FIRST=1
  54. while IFS= read -r line; do
  55. TARGET_SUBTARGET=$(echo $line | cut -d " " -f 1)
  56. TARGET=$(echo $TARGET_SUBTARGET | cut -d "/" -f 1)
  57. SUBTARGET=$(echo $TARGET_SUBTARGET | cut -d "/" -f 2)
  58. [ "${{ steps.parse_label.outputs.target }}" != "all" ] && [ "${{ steps.parse_label.outputs.target }}" != $TARGET ] && continue
  59. if [ "${{ steps.parse_label.outputs.testing }}" = "testing" ]; then
  60. TESTING_KERNEL_VER=$(echo $line | cut -d " " -f 3)
  61. [ -z "$TESTING_KERNEL_VER" ] && continue
  62. fi
  63. TUPLE='{"target":"'"$TARGET"'","subtarget":"'"$SUBTARGET"'","testing":"'"$TESTING_KERNEL_VER"'"}'
  64. [[ $FIRST -ne 1 ]] && JSON_TARGETS="$JSON_TARGETS"','
  65. JSON_TARGETS="$JSON_TARGETS""$TUPLE"
  66. FIRST=0
  67. done <<< "$TARGETS"
  68. JSON_TARGETS="$JSON_TARGETS"']'
  69. echo -e "\n---- targets to build ----\n"
  70. echo "$JSON_TARGETS_SUBTARGETS"
  71. echo -e "\n---- targets to build ----\n"
  72. echo -e "\n---- targets to check patch ----\n"
  73. echo "$JSON_TARGETS"
  74. echo -e "\n---- targets to check patch ----\n"
  75. echo "targets_subtargets=$JSON_TARGETS_SUBTARGETS" >> $GITHUB_OUTPUT
  76. echo "targets=$JSON_TARGETS" >> $GITHUB_OUTPUT
  77. build_kernel:
  78. name: Build Kernel with external toolchain
  79. needs: set_target
  80. permissions:
  81. contents: read
  82. packages: read
  83. actions: write
  84. uses: ./.github/workflows/build.yml
  85. strategy:
  86. fail-fast: False
  87. matrix:
  88. include: ${{fromJson(needs.set_target.outputs.targets_subtargets)}}
  89. with:
  90. container_name: toolchain
  91. target: ${{ matrix.target }}
  92. subtarget: ${{ matrix.subtarget }}
  93. testing: ${{ matrix.testing != '' && true }}
  94. build_kernel: true
  95. build_all_kmods: true
  96. check-kernel-patches:
  97. name: Check Kernel patches
  98. needs: set_target
  99. permissions:
  100. contents: read
  101. packages: read
  102. actions: write
  103. strategy:
  104. fail-fast: False
  105. matrix:
  106. include: ${{fromJson(needs.set_target.outputs.targets)}}
  107. uses: ./.github/workflows/check-kernel-patches.yml
  108. with:
  109. target: ${{ matrix.target }}
  110. subtarget: ${{ matrix.subtarget }}
  111. testing: ${{ matrix.testing != '' && true }}