From 506385cfadea57527ef459f704264d6fe26b0a80 Mon Sep 17 00:00:00 2001 From: Ylarod Date: Mon, 8 Jan 2024 09:54:14 +0800 Subject: [PATCH] ci: build less wsa image in pr (#1273) --- .github/workflows/build-kernel-a12.yml | 7 +- .github/workflows/build-kernel-a13.yml | 7 +- .github/workflows/build-kernel-a14.yml | 7 +- .github/workflows/build-kernel-arcvm.yml | 2 +- .github/workflows/build-kernel-wsa.yml | 140 +++-------------------- .github/workflows/wsa-kernel.yml | 135 ++++++++++++++++++++++ 6 files changed, 166 insertions(+), 132 deletions(-) create mode 100644 .github/workflows/wsa-kernel.yml diff --git a/.github/workflows/build-kernel-a12.yml b/.github/workflows/build-kernel-a12.yml index b3d0f6f9ff1e..30d777c7fafd 100644 --- a/.github/workflows/build-kernel-a12.yml +++ b/.github/workflows/build-kernel-a12.yml @@ -1,7 +1,7 @@ name: Build Kernel - Android 12 on: push: - branches: ["main", "ci"] + branches: ["main", "ci", "checkci"] paths: - ".github/workflows/build-kernel-a12.yml" - ".github/workflows/gki-kernel.yml" @@ -17,7 +17,7 @@ on: workflow_call: jobs: build-kernel: - if: github.event_name != 'pull_request' + if: github.event_name != 'pull_request' && github.ref != 'refs/heads/checkci' strategy: matrix: include: @@ -53,6 +53,7 @@ jobs: tag: android12-5.10-${{ matrix.os_patch_level }} os_patch_level: ${{ matrix.os_patch_level }} patch_path: "5.10" + upload-artifacts: needs: build-kernel runs-on: ubuntu-latest @@ -124,7 +125,7 @@ jobs: path: Image-android12*/*.img.gz check-build-kernel: - if: github.event_name == 'pull_request' && !github.event.pull_request.draft + if: (github.event_name == 'pull_request' && !github.event.pull_request.draft) || github.ref == 'refs/heads/checkci' uses: ./.github/workflows/gki-kernel.yml with: version: android12-5.10 diff --git a/.github/workflows/build-kernel-a13.yml b/.github/workflows/build-kernel-a13.yml index a27c6f821379..7026e25e4b94 100644 --- a/.github/workflows/build-kernel-a13.yml +++ b/.github/workflows/build-kernel-a13.yml @@ -1,7 +1,7 @@ name: Build Kernel - Android 13 on: push: - branches: ["main", "ci"] + branches: ["main", "ci", "checkci"] paths: - ".github/workflows/build-kernel-a13.yml" - ".github/workflows/gki-kernel.yml" @@ -17,7 +17,7 @@ on: workflow_call: jobs: build-kernel: - if: github.event_name != 'pull_request' + if: github.event_name != 'pull_request' && github.ref != 'refs/heads/checkci' strategy: matrix: include: @@ -80,6 +80,7 @@ jobs: tag: android13-${{ matrix.version }}-${{ matrix.os_patch_level }} os_patch_level: ${{ matrix.os_patch_level }} patch_path: ${{ matrix.version }} + upload-artifacts: needs: build-kernel runs-on: ubuntu-latest @@ -151,7 +152,7 @@ jobs: path: Image-android13*/*.img.gz check-build-kernel: - if: github.event_name == 'pull_request' && !github.event.pull_request.draft + if: (github.event_name == 'pull_request' && !github.event.pull_request.draft) || github.ref == 'refs/heads/checkci' strategy: matrix: include: diff --git a/.github/workflows/build-kernel-a14.yml b/.github/workflows/build-kernel-a14.yml index e03fea074e85..36a19605234a 100644 --- a/.github/workflows/build-kernel-a14.yml +++ b/.github/workflows/build-kernel-a14.yml @@ -1,7 +1,7 @@ name: Build Kernel - Android 14 on: push: - branches: ["main", "ci"] + branches: ["main", "ci", "checkci"] paths: - ".github/workflows/build-kernel-a14.yml" - ".github/workflows/gki-kernel.yml" @@ -17,7 +17,7 @@ on: workflow_call: jobs: build-kernel: - if: github.event_name != 'pull_request' + if: github.event_name != 'pull_request' && github.ref != 'refs/heads/checkci' strategy: matrix: include: @@ -44,6 +44,7 @@ jobs: tag: android14-${{ matrix.version }}-${{ matrix.os_patch_level }} os_patch_level: ${{ matrix.os_patch_level }} patch_path: ${{ matrix.version }} + upload-artifacts: needs: build-kernel runs-on: ubuntu-latest @@ -115,7 +116,7 @@ jobs: path: Image-android14*/*.img.gz check-build-kernel: - if: github.event_name == 'pull_request' && !github.event.pull_request.draft + if: (github.event_name == 'pull_request' && !github.event.pull_request.draft) || github.ref == 'refs/heads/checkci' strategy: matrix: include: diff --git a/.github/workflows/build-kernel-arcvm.yml b/.github/workflows/build-kernel-arcvm.yml index 048d2dfdff59..50da5f67cf4f 100644 --- a/.github/workflows/build-kernel-arcvm.yml +++ b/.github/workflows/build-kernel-arcvm.yml @@ -1,7 +1,7 @@ name: Build Kernel - ChromeOS ARCVM on: push: - branches: ["main"] + branches: ["main", "ci", "checkci"] paths: - ".github/workflows/build-kernel-arcvm.yml" - "kernel/**" diff --git a/.github/workflows/build-kernel-wsa.yml b/.github/workflows/build-kernel-wsa.yml index 94d1f1b57059..9a313de9a1db 100644 --- a/.github/workflows/build-kernel-wsa.yml +++ b/.github/workflows/build-kernel-wsa.yml @@ -1,142 +1,38 @@ name: Build Kernel - WSA on: push: - branches: ["main"] + branches: ["main", "ci", "checkci"] paths: - ".github/workflows/build-kernel-wsa.yml" + - ".github/workflows/wsa-kernel.yml" - "kernel/**" pull_request: branches: ["main"] paths: - ".github/workflows/build-kernel-wsa.yml" + - ".github/workflows/wsa-kernel.yml" - "kernel/**" workflow_call: workflow_dispatch: jobs: build: - if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && !github.event.pull_request.draft) + if: github.event_name != 'pull_request' && github.ref != 'refs/heads/checkci' strategy: matrix: arch: [x86_64, arm64] version: ["5.15.94.2", "5.15.104.1", "5.15.104.2", "5.15.104.3", "5.15.104.4"] - - name: Build WSA-Kernel-${{ matrix.version }}-${{ matrix.arch }} - runs-on: ubuntu-20.04 - env: - CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion" - CCACHE_NOHASHDIR: "true" - CCACHE_HARDLINK: "true" - - steps: - - name: Install Build Tools - uses: awalsh128/cache-apt-pkgs-action@v1 - with: - packages: bc bison build-essential flex libelf-dev binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu gzip ccache - version: 1.0 - - - name: Cache LLVM - id: cache-llvm - uses: actions/cache@v3 - with: - path: ./llvm - key: llvm-12.0.1 - - - name: Setup LLVM - uses: KyleMayes/install-llvm-action@v1 - with: - version: "12.0.1" - force-version: true - ubuntu-version: "16.04" - cached: ${{ steps.cache-llvm.outputs.cache-hit }} - - - name: Checkout KernelSU - uses: actions/checkout@v4 - with: - path: KernelSU - fetch-depth: 0 - - - name: Setup kernel source - uses: actions/checkout@v4 - with: - repository: microsoft/WSA-Linux-Kernel - ref: android-lts/latte-2/${{ matrix.version }} - path: WSA-Linux-Kernel - - - name: Setup Ccache - uses: hendrikmuhs/ccache-action@v1.2 - with: - key: WSA-Kernel-${{ matrix.version }}-${{ matrix.arch }} - save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - max-size: 2G - - - name: Setup KernelSU - working-directory: WSA-Linux-Kernel - run: | - echo "[+] KernelSU setup" - KERNEL_ROOT=$GITHUB_WORKSPACE/WSA-Linux-Kernel - echo "[+] KERNEL_ROOT: $KERNEL_ROOT" - echo "[+] Copy KernelSU driver to $KERNEL_ROOT/drivers" - ln -sf $GITHUB_WORKSPACE/KernelSU/kernel $KERNEL_ROOT/drivers/kernelsu - echo "[+] Add KernelSU driver to Makefile" - DRIVER_MAKEFILE=$KERNEL_ROOT/drivers/Makefile - grep -q "kernelsu" $DRIVER_MAKEFILE || echo "obj-y += kernelsu/" >> $DRIVER_MAKEFILE - echo "[+] Apply KernelSU patches" - cd $KERNEL_ROOT && git apply $GITHUB_WORKSPACE/KernelSU/.github/patches/5.15/*.patch - echo "[+] KernelSU setup done." - cd $GITHUB_WORKSPACE/KernelSU - VERSION=$(($(git rev-list --count HEAD) + 10200)) - echo "VERSION: $VERSION" - echo "kernelsu_version=$VERSION" >> $GITHUB_ENV - - - name: Build Kernel - working-directory: WSA-Linux-Kernel - run: | - if [ ! -z ${{ vars.EXPECTED_SIZE }} ] && [ ! -z ${{ vars.EXPECTED_HASH }} ]; then - export KSU_EXPECTED_SIZE=${{ vars.EXPECTED_SIZE }} - export KSU_EXPECTED_HASH=${{ vars.EXPECTED_HASH }} - fi - declare -A ARCH_MAP=(["x86_64"]="x64" ["arm64"]="arm64") - cp configs/wsa/config-wsa-${ARCH_MAP[${{ matrix.arch }}]} .config - make olddefconfig - declare -A FILE_NAME=(["x86_64"]="bzImage" ["arm64"]="Image") - make -j`nproc` LLVM=1 ARCH=${{ matrix.arch }} $(if [ "${{ matrix.arch }}" == "arm64" ]; then echo CROSS_COMPILE=aarch64-linux-gnu; fi) ${FILE_NAME[${{ matrix.arch }}]} CCACHE="/usr/bin/ccache" - declare -A ARCH_MAP_FILE=(["x86_64"]="x86" ["arm64"]="arm64") - echo "file_path=WSA-Linux-Kernel/arch/${ARCH_MAP_FILE[${{ matrix.arch }}]}/boot/${FILE_NAME[${{ matrix.arch }}]}" >> $GITHUB_ENV - - - name: Upload kernel-${{ matrix.arch }}-${{ matrix.version }} - uses: actions/upload-artifact@v4 - with: - name: kernel-WSA-${{ matrix.arch }}-${{ matrix.version }} - path: "${{ env.file_path }}" - - - name: Bot session cache - if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.ref_type == 'tag' - id: bot_session_cache - uses: actions/cache@v3 - with: - path: scripts/ksubot.session - key: ${{ runner.os }}-bot-session - - - name: Post to Telegram - if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.ref_type == 'tag' - env: - CHAT_ID: ${{ secrets.CHAT_ID }} - BOT_TOKEN: ${{ secrets.BOT_TOKEN }} - MESSAGE_THREAD_ID: ${{ secrets.MESSAGE_THREAD_ID }} - COMMIT_MESSAGE: ${{ github.event.head_commit.message }} - COMMIT_URL: ${{ github.event.head_commit.url }} - RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - run: | - TITLE=kernel-${{ matrix.arch }}-WSA-${{ matrix.version }} - echo "[+] title: $TITLE" - export TITLE - export VERSION="${{ env.kernelsu_version }}" - echo "[+] Compress images" - gzip -n -f -9 "${{ env.file_path }}" - echo "[+] Image to upload" - ls -l "${{ env.file_path }}.gz" - if [ -n "${{ secrets.BOT_TOKEN }}" ]; then - pip3 install telethon==1.31.1 - python3 "$GITHUB_WORKSPACE/KernelSU/scripts/ksubot.py" "${{ env.file_path }}.gz" - fi + uses: ./.github/workflows/wsa-kernel.yml + with: + arch: ${{ matrix.arch }} + version: ${{ matrix.version }} + + check_build: + if: (github.event_name == 'pull_request' && !github.event.pull_request.draft) || github.ref == 'refs/heads/checkci' + uses: ./.github/workflows/wsa-kernel.yml + strategy: + matrix: + arch: [x86_64, arm64] + with: + arch: ${{ matrix.arch }} + version: "5.15.104.4" \ No newline at end of file diff --git a/.github/workflows/wsa-kernel.yml b/.github/workflows/wsa-kernel.yml new file mode 100644 index 000000000000..98ea96edb81f --- /dev/null +++ b/.github/workflows/wsa-kernel.yml @@ -0,0 +1,135 @@ +name: Build Kernel - WSA +on: + workflow_call: + inputs: + arch: + required: true + type: string + description: > + Build arch: x86_64 / arm64 + version: + required: true + type: string + description: > + Build version +jobs: + build: + name: Build WSA-Kernel-${{ inputs.version }}-${{ inputs.arch }} + runs-on: ubuntu-20.04 + env: + CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion" + CCACHE_NOHASHDIR: "true" + CCACHE_HARDLINK: "true" + + steps: + - name: Install Build Tools + uses: awalsh128/cache-apt-pkgs-action@v1 + with: + packages: bc bison build-essential flex libelf-dev binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu gzip ccache + version: 1.0 + + - name: Cache LLVM + id: cache-llvm + uses: actions/cache@v3 + with: + path: ./llvm + key: llvm-12.0.1 + + - name: Setup LLVM + uses: KyleMayes/install-llvm-action@v1 + with: + version: "12.0.1" + force-version: true + ubuntu-version: "16.04" + cached: ${{ steps.cache-llvm.outputs.cache-hit }} + + - name: Checkout KernelSU + uses: actions/checkout@v4 + with: + path: KernelSU + fetch-depth: 0 + + - name: Setup kernel source + uses: actions/checkout@v4 + with: + repository: microsoft/WSA-Linux-Kernel + ref: android-lts/latte-2/${{ inputs.version }} + path: WSA-Linux-Kernel + + - name: Setup Ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: WSA-Kernel-${{ inputs.version }}-${{ inputs.arch }} + save: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + max-size: 2G + + - name: Setup KernelSU + working-directory: WSA-Linux-Kernel + run: | + echo "[+] KernelSU setup" + KERNEL_ROOT=$GITHUB_WORKSPACE/WSA-Linux-Kernel + echo "[+] KERNEL_ROOT: $KERNEL_ROOT" + echo "[+] Copy KernelSU driver to $KERNEL_ROOT/drivers" + ln -sf $GITHUB_WORKSPACE/KernelSU/kernel $KERNEL_ROOT/drivers/kernelsu + echo "[+] Add KernelSU driver to Makefile" + DRIVER_MAKEFILE=$KERNEL_ROOT/drivers/Makefile + grep -q "kernelsu" $DRIVER_MAKEFILE || echo "obj-y += kernelsu/" >> $DRIVER_MAKEFILE + echo "[+] Apply KernelSU patches" + cd $KERNEL_ROOT && git apply $GITHUB_WORKSPACE/KernelSU/.github/patches/5.15/*.patch + echo "[+] KernelSU setup done." + cd $GITHUB_WORKSPACE/KernelSU + VERSION=$(($(git rev-list --count HEAD) + 10200)) + echo "VERSION: $VERSION" + echo "kernelsu_version=$VERSION" >> $GITHUB_ENV + + - name: Build Kernel + working-directory: WSA-Linux-Kernel + run: | + if [ ! -z ${{ vars.EXPECTED_SIZE }} ] && [ ! -z ${{ vars.EXPECTED_HASH }} ]; then + export KSU_EXPECTED_SIZE=${{ vars.EXPECTED_SIZE }} + export KSU_EXPECTED_HASH=${{ vars.EXPECTED_HASH }} + fi + declare -A ARCH_MAP=(["x86_64"]="x64" ["arm64"]="arm64") + cp configs/wsa/config-wsa-${ARCH_MAP[${{ inputs.arch }}]} .config + make olddefconfig + declare -A FILE_NAME=(["x86_64"]="bzImage" ["arm64"]="Image") + make -j`nproc` LLVM=1 ARCH=${{ inputs.arch }} $(if [ "${{ inputs.arch }}" == "arm64" ]; then echo CROSS_COMPILE=aarch64-linux-gnu; fi) ${FILE_NAME[${{ inputs.arch }}]} CCACHE="/usr/bin/ccache" + declare -A ARCH_MAP_FILE=(["x86_64"]="x86" ["arm64"]="arm64") + echo "file_path=WSA-Linux-Kernel/arch/${ARCH_MAP_FILE[${{ inputs.arch }}]}/boot/${FILE_NAME[${{ inputs.arch }}]}" >> $GITHUB_ENV + + - name: Upload kernel-${{ inputs.arch }}-${{ inputs.version }} + uses: actions/upload-artifact@v4 + with: + name: kernel-WSA-${{ inputs.arch }}-${{ inputs.version }} + path: "${{ env.file_path }}" + + - name: Bot session cache + if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.ref_type == 'tag' + id: bot_session_cache + uses: actions/cache@v3 + with: + path: scripts/ksubot.session + key: ${{ runner.os }}-bot-session + + - name: Post to Telegram + if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.ref_type == 'tag' + env: + CHAT_ID: ${{ secrets.CHAT_ID }} + BOT_TOKEN: ${{ secrets.BOT_TOKEN }} + MESSAGE_THREAD_ID: ${{ secrets.MESSAGE_THREAD_ID }} + COMMIT_MESSAGE: ${{ github.event.head_commit.message }} + COMMIT_URL: ${{ github.event.head_commit.url }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + TITLE=kernel-${{ inputs.arch }}-WSA-${{ inputs.version }} + echo "[+] title: $TITLE" + export TITLE + export VERSION="${{ env.kernelsu_version }}" + echo "[+] Compress images" + gzip -n -f -9 "${{ env.file_path }}" + echo "[+] Image to upload" + ls -l "${{ env.file_path }}.gz" + if [ -n "${{ secrets.BOT_TOKEN }}" ]; then + pip3 install telethon==1.31.1 + python3 "$GITHUB_WORKSPACE/KernelSU/scripts/ksubot.py" "${{ env.file_path }}.gz" + fi