check-kernel-patches.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. name: Refresh kernel for target
  2. on:
  3. workflow_call:
  4. inputs:
  5. target:
  6. required: true
  7. type: string
  8. testing:
  9. type: boolean
  10. use_openwrt_container:
  11. type: boolean
  12. default: true
  13. permissions:
  14. contents: read
  15. jobs:
  16. setup_build:
  17. name: Setup build
  18. runs-on: ubuntu-latest
  19. outputs:
  20. owner_lc: ${{ steps.lower_owner.outputs.owner_lc }}
  21. container_tag: ${{ steps.determine_tools_container.outputs.container_tag }}
  22. steps:
  23. - name: Set lower case owner name
  24. id: lower_owner
  25. run: |
  26. OWNER_LC=$(echo "${{ github.repository_owner }}" \
  27. | tr '[:upper:]' '[:lower:]')
  28. if [ ${{ inputs.use_openwrt_container }} == "true" ]; then
  29. OWNER_LC=openwrt
  30. fi
  31. echo "owner_lc=$OWNER_LC" >> $GITHUB_OUTPUT
  32. # Per branch tools container tag
  33. # By default stick to latest
  34. # For official test targetting openwrt stable branch
  35. # Get the branch or parse the tag and push dedicated tools containers
  36. # For local test to use the correct container for stable release testing
  37. # you need to use for the branch name a prefix of openwrt-[0-9][0-9].[0-9][0-9]-
  38. - name: Determine tools container tag
  39. id: determine_tools_container
  40. run: |
  41. CONTAINER_TAG=latest
  42. if [ -n "${{ github.base_ref }}" ]; then
  43. if echo "${{ github.base_ref }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
  44. CONTAINER_TAG="${{ github.base_ref }}"
  45. fi
  46. elif [ ${{ github.ref_type }} == "branch" ]; then
  47. if echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
  48. CONTAINER_TAG=${{ github.ref_name }}
  49. elif echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]-'; then
  50. CONTAINER_TAG="$(echo ${{ github.ref_name }} | sed 's/^\(openwrt-[0-9][0-9]\.[0-9][0-9]\)-.*/\1/')"
  51. fi
  52. elif [ ${{ github.ref_type }} == "tag" ]; then
  53. if echo "${{ github.ref_name }}" | grep -q -E '^v[0-9][0-9]\.[0-9][0-9]\..+'; then
  54. CONTAINER_TAG=openwrt-"$(echo ${{ github.ref_name }} | sed 's/^v\([0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
  55. fi
  56. fi
  57. echo "Tools container to use tools:$CONTAINER_TAG"
  58. echo "container_tag=$CONTAINER_TAG" >> $GITHUB_OUTPUT
  59. check-patch:
  60. name: Check Kernel patches
  61. needs: setup_build
  62. runs-on: ubuntu-latest
  63. container: ghcr.io/${{ needs.setup_build.outputs.owner_lc }}/tools:${{ needs.setup_build.outputs.container_tag }}
  64. permissions:
  65. contents: read
  66. packages: read
  67. steps:
  68. - name: Checkout master directory
  69. uses: actions/checkout@v3
  70. with:
  71. path: openwrt
  72. - name: Fix permission
  73. run: |
  74. chown -R buildbot:buildbot openwrt
  75. - name: Initialization environment
  76. run: |
  77. TARGET=$(echo ${{ inputs.target }} | cut -d "/" -f 1)
  78. SUBTARGET=$(echo ${{ inputs.target }} | cut -d "/" -f 2)
  79. echo "TARGET=$TARGET" >> "$GITHUB_ENV"
  80. echo "SUBTARGET=$SUBTARGET" >> "$GITHUB_ENV"
  81. - name: Prepare prebuilt tools
  82. shell: su buildbot -c "sh -e {0}"
  83. working-directory: openwrt
  84. run: |
  85. mkdir -p staging_dir build_dir
  86. ln -sf /prebuilt_tools/staging_dir/host staging_dir/host
  87. ln -sf /prebuilt_tools/build_dir/host build_dir/host
  88. ./scripts/ext-tools.sh --refresh
  89. - name: Configure testing kernel
  90. if: inputs.testing == true
  91. shell: su buildbot -c "sh -e {0}"
  92. working-directory: openwrt
  93. run: |
  94. echo CONFIG_TESTING_KERNEL=y >> .config
  95. - name: Configure system
  96. shell: su buildbot -c "sh -e {0}"
  97. working-directory: openwrt
  98. run: |
  99. echo CONFIG_ALL_KMODS=y >> .config
  100. echo CONFIG_DEVEL=y >> .config
  101. echo CONFIG_AUTOREMOVE=y >> .config
  102. echo CONFIG_CCACHE=y >> .config
  103. echo "CONFIG_TARGET_${{ env.TARGET }}=y" >> .config
  104. echo "CONFIG_TARGET_${{ env.TARGET }}_${{ env.SUBTARGET }}=y" >> .config
  105. make defconfig
  106. - name: Build tools
  107. shell: su buildbot -c "sh -e {0}"
  108. working-directory: openwrt
  109. run: make tools/quilt/compile -j$(nproc) BUILD_LOG=1 || ret=$? .github/workflows/scripts/show_build_failures.sh
  110. - name: Refresh Kernel patches
  111. shell: su buildbot -c "sh -e {0}"
  112. working-directory: openwrt
  113. run: |
  114. make target/linux/refresh V=s
  115. . .github/workflows/scripts/ci_helpers.sh
  116. if git diff --name-only --exit-code; then
  117. success "Kernel patches for ${{ env.TARGET }}/${{ env.SUBTARGET }} seems ok"
  118. else
  119. err "Kernel patches for ${{ env.TARGET }}/${{ env.SUBTARGET }} require refresh. (run 'make target/linux/refresh' and force push this pr)"
  120. exit 1
  121. fi