kernel.yml 4.4 KB

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