kernel.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. name: Build Kernel
  2. on:
  3. pull_request:
  4. paths:
  5. - '.github/workflows/check-kernel-patches.yml'
  6. - '.github/workflows/build.yml'
  7. - '.github/workflows/kernel.yml'
  8. - 'include/kernel*'
  9. - 'package/kernel/**'
  10. - 'target/linux/**'
  11. push:
  12. paths:
  13. - '.github/workflows/check-kernel-patches.yml'
  14. - '.github/workflows/build.yml'
  15. - '.github/workflows/kernel.yml'
  16. - 'include/kernel*'
  17. - 'package/kernel/**'
  18. - 'target/linux/**'
  19. permissions:
  20. contents: read
  21. concurrency:
  22. group: ${{ github.workflow }}-${{ github.ref }}
  23. cancel-in-progress: ${{ github.event_name == 'pull_request' }}
  24. jobs:
  25. determine_targets:
  26. name: Set targets
  27. runs-on: ubuntu-latest
  28. outputs:
  29. targets_subtargets: ${{ steps.find_targets.outputs.targets_subtargets }}
  30. targets: ${{ steps.find_targets.outputs.targets }}
  31. steps:
  32. - name: Checkout
  33. uses: actions/checkout@v3
  34. with:
  35. fetch-depth: 2
  36. - name: Get changed files
  37. id: changed-files
  38. uses: tj-actions/changed-files@v35
  39. - name: Set targets
  40. id: find_targets
  41. run: |
  42. ALL_TARGETS="$(perl ./scripts/dump-target-info.pl targets 2>/dev/null)"
  43. CHANGED_FILES="$(echo ${{ steps.changed-files.outputs.all_changed_files }} | tr ' ' '\n')"
  44. TARGETS_SUBTARGETS="$(echo "$ALL_TARGETS" | sort -u -t '/' -k1 | awk '{ print $1 }')"
  45. TARGETS="$(echo "$ALL_TARGETS" | sort -u -t '/' -k1,1 | awk '{ print $1 }')"
  46. # On testing non-specific target, skip testing each subtarget
  47. if echo "$CHANGED_FILES" | grep -v -q target/linux ||
  48. echo "$CHANGED_FILES" | grep -q target/linux/generic; then
  49. TARGETS_SUBTARGETS=$TARGETS
  50. fi
  51. JSON_TARGETS_SUBTARGETS='['
  52. FIRST=1
  53. for TARGET in $TARGETS_SUBTARGETS; do
  54. if echo "$CHANGED_FILES" | grep -v -q target/linux ||
  55. echo "$CHANGED_FILES" | grep -q target/linux/generic ||
  56. echo "$CHANGED_FILES" | grep -q $(echo $TARGET | cut -d "/" -f 1); then
  57. [[ $FIRST -ne 1 ]] && JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"','
  58. JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"'"'"${TARGET}"'"'
  59. FIRST=0
  60. fi
  61. done
  62. JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"']'
  63. JSON_TARGETS='['
  64. FIRST=1
  65. for TARGET in $TARGETS; do
  66. if echo "$CHANGED_FILES" | grep -v -q target/linux ||
  67. echo "$CHANGED_FILES" | grep -q target/linux/generic ||
  68. echo "$CHANGED_FILES" | grep -q $(echo $TARGET | cut -d "/" -f 1); then
  69. [[ $FIRST -ne 1 ]] && JSON_TARGETS="$JSON_TARGETS"','
  70. JSON_TARGETS="$JSON_TARGETS"'"'"${TARGET}"'"'
  71. FIRST=0
  72. fi
  73. done
  74. JSON_TARGETS="$JSON_TARGETS"']'
  75. echo -e "\n---- targets to build ----\n"
  76. echo "$JSON_TARGETS_SUBTARGETS"
  77. echo -e "\n---- targets to build ----\n"
  78. echo -e "\n---- targets to check patch ----\n"
  79. echo "$JSON_TARGETS"
  80. echo -e "\n---- targets to check patch ----\n"
  81. echo "targets_subtargets=$JSON_TARGETS_SUBTARGETS" >> $GITHUB_OUTPUT
  82. echo "targets=$JSON_TARGETS" >> $GITHUB_OUTPUT
  83. build:
  84. name: Build Kernel with external toolchain
  85. needs: determine_targets
  86. permissions:
  87. contents: read
  88. packages: read
  89. strategy:
  90. fail-fast: False
  91. matrix:
  92. target: ${{fromJson(needs.determine_targets.outputs.targets_subtargets)}}
  93. uses: ./.github/workflows/build.yml
  94. with:
  95. target: ${{ matrix.target }}
  96. build_kernel: true
  97. build_all_kmods: true
  98. check-kernel-patches:
  99. name: Check Kernel patches
  100. needs: determine_targets
  101. permissions:
  102. contents: read
  103. packages: read
  104. strategy:
  105. fail-fast: False
  106. matrix:
  107. target: ${{fromJson(needs.determine_targets.outputs.targets)}}
  108. uses: ./.github/workflows/check-kernel-patches.yml
  109. with:
  110. target: ${{ matrix.target }}