CI: build: make kernel build configurable
[openwrt/staging/hauke.git] / .github / workflows / kernel.yml
index f7e5d542b4250117f39e4bb64842393911274a35..d886002ed1641411f777a02db68fe1cb7499c938 100644 (file)
@@ -3,8 +3,24 @@ name: Build Kernel
 on:
   pull_request:
     paths:
-      - 'include/kernel-*'
+      - '.github/workflows/check-kernel-patches.yml'
+      - '.github/workflows/build.yml'
+      - '.github/workflows/kernel.yml'
+      - 'include/kernel*'
       - 'package/kernel/**'
+      - 'target/linux/generic/**'
+  push:
+    paths:
+      - '.github/workflows/check-kernel-patches.yml'
+      - '.github/workflows/build.yml'
+      - '.github/workflows/kernel.yml'
+      - 'include/kernel*'
+      - 'package/kernel/**'
+      - 'target/linux/generic/**'
+
+permissions:
+  contents: read
+
 jobs:
   determine_targets:
     name: Set targets
@@ -14,7 +30,7 @@ jobs:
 
     steps:
       - name: Checkout
-        uses: actions/checkout@v2
+        uses: actions/checkout@v3
 
       - name: Set targets
         id: find_targets
@@ -36,86 +52,35 @@ jobs:
            echo "$JSON"
            echo -e "\n---- targets ----\n"
 
-           echo "::set-output name=target::$JSON"
+           echo "target=$JSON" >> $GITHUB_OUTPUT
 
   build:
     name: Build Kernel with external toolchain
     needs: determine_targets
-    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      packages: read
     strategy:
        fail-fast: False
        matrix:
          target: ${{fromJson(needs.determine_targets.outputs.target)}}
+    uses: ./.github/workflows/build.yml
+    with:
+      target: ${{ matrix.target }}
+      build_kernel: true
+      build_all_kmods: true
+
+  check-kernel-patches:
+    name: Check Kernel patches
+    needs: determine_targets
+    permissions:
+      contents: read
+      packages: read
+    strategy:
+       fail-fast: False
+       matrix:
+         target: ${{fromJson(needs.determine_targets.outputs.target)}}
+    uses: ./.github/workflows/check-kernel-patches.yml
+    with:
+      target: ${{ matrix.target }}
 
-    container: registry.gitlab.com/openwrt/buildbot/buildworker-3.4.1
-
-    steps:
-      - name: Checkout master directory
-        uses: actions/checkout@v2
-        with:
-          path: openwrt
-
-      - name: Fix permission
-        run: |
-          chown -R buildbot:buildbot openwrt
-
-      - name: Initialization environment
-        run: |
-          TARGET=$(echo ${{ matrix.target }} | cut -d "/" -f 1)
-          SUBTARGET=$(echo ${{ matrix.target }} | cut -d "/" -f 2)
-          echo "TARGET=$TARGET" >> "$GITHUB_ENV"
-          echo "SUBTARGET=$SUBTARGET" >> "$GITHUB_ENV"
-
-      - name: Update & Install feeds
-        shell: su buildbot -c "sh -e {0}"
-        working-directory: openwrt
-        run: |
-          ./scripts/feeds update -a
-          ./scripts/feeds install -a
-
-      - name: Parse toolchain file
-        working-directory: openwrt
-        run: |
-          TOOLCHAIN_FILE=$(curl "https://downloads.openwrt.org/snapshots/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/sha256sums" \
-            | sed -n -e 's/.*\(openwrt-toolchain.*\).tar.xz/\1/p')
-
-          echo "TOOLCHAIN_FILE=$TOOLCHAIN_FILE" >> "$GITHUB_ENV"
-
-      - name: Download external toolchain
-        shell: su buildbot -c "sh -e {0}"
-        working-directory: openwrt
-        run: |
-          wget -O - https://downloads.openwrt.org/snapshots/targets/${{ env.TARGET }}/${{ env.SUBTARGET }}/${TOOLCHAIN_FILE}.tar.xz \
-            | tar --xz -xf -
-
-      - name: Configure external toolchain
-        shell: su buildbot -c "sh -e {0}"
-        working-directory: openwrt
-        run: |
-          ./scripts/ext-toolchain.sh \
-            --toolchain ${{ env.TOOLCHAIN_FILE }}/toolchain-* \
-            --config ${{ env.TARGET }}/${{ env.SUBTARGET }}
-
-          make defconfig
-
-      - name: Build tools
-        shell: su buildbot -c "sh -e {0}"
-        working-directory: openwrt
-        run: make tools/install -j$(nproc) BUILD_LOG=1
-
-      - name: Build toolchain
-        shell: su buildbot -c "sh -e {0}"
-        working-directory: openwrt
-        run: make toolchain/install -j$(nproc) BUILD_LOG=1
-
-      - name: Build Kernel
-        shell: su buildbot -c "sh -e {0}"
-        working-directory: openwrt
-        run: make target/compile -j$(nproc) BUILD_LOG=1
-
-      - name: Upload logs
-        if: failure()
-        uses: actions/upload-artifact@v2
-        with:
-          name: ${{ env.TARGET }}-${{ env.SUBTARGET }}-logs
-          path: "openwrt/logs"