kernel.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. TUPLE='{"target":"'"$(echo $TARGET | cut -d "/" -f 1)"'","subtarget":"'"$(echo $TARGET | cut -d "/" -f 2)"'"}'
  58. [[ $FIRST -ne 1 ]] && JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"','
  59. JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS""$TUPLE"
  60. FIRST=0
  61. fi
  62. done
  63. JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"']'
  64. JSON_TARGETS='['
  65. FIRST=1
  66. for TARGET in $TARGETS; do
  67. if echo "$CHANGED_FILES" | grep -v -q target/linux ||
  68. echo "$CHANGED_FILES" | grep -q target/linux/generic ||
  69. echo "$CHANGED_FILES" | grep -q $(echo $TARGET | cut -d "/" -f 1); then
  70. TUPLE='{"target":"'"$(echo $TARGET | cut -d "/" -f 1)"'","subtarget":"'"$(echo $TARGET | cut -d "/" -f 2)"'"}'
  71. [[ $FIRST -ne 1 ]] && JSON_TARGETS="$JSON_TARGETS"','
  72. JSON_TARGETS="$JSON_TARGETS""$TUPLE"
  73. FIRST=0
  74. fi
  75. done
  76. JSON_TARGETS="$JSON_TARGETS"']'
  77. echo -e "\n---- targets to build ----\n"
  78. echo "$JSON_TARGETS_SUBTARGETS"
  79. echo -e "\n---- targets to build ----\n"
  80. echo -e "\n---- targets to check patch ----\n"
  81. echo "$JSON_TARGETS"
  82. echo -e "\n---- targets to check patch ----\n"
  83. echo "targets_subtargets=$JSON_TARGETS_SUBTARGETS" >> $GITHUB_OUTPUT
  84. echo "targets=$JSON_TARGETS" >> $GITHUB_OUTPUT
  85. build:
  86. name: Build Kernel with external toolchain
  87. needs: determine_targets
  88. permissions:
  89. contents: read
  90. packages: read
  91. strategy:
  92. fail-fast: False
  93. matrix:
  94. include: ${{fromJson(needs.determine_targets.outputs.targets_subtargets)}}
  95. uses: ./.github/workflows/build.yml
  96. with:
  97. container_name: toolchain
  98. target: ${{ matrix.target }}
  99. subtarget: ${{ matrix.subtarget }}
  100. build_kernel: true
  101. build_all_kmods: true
  102. check-kernel-patches:
  103. name: Check Kernel patches
  104. needs: determine_targets
  105. permissions:
  106. contents: read
  107. packages: read
  108. strategy:
  109. fail-fast: False
  110. matrix:
  111. include: ${{fromJson(needs.determine_targets.outputs.targets)}}
  112. uses: ./.github/workflows/check-kernel-patches.yml
  113. with:
  114. target: ${{ matrix.target }}
  115. subtarget: ${{ matrix.subtarget }}