diff --git a/.github/workflows/call-test.yml b/.github/workflows/call-test.yml new file mode 100644 index 0000000..3a20551 --- /dev/null +++ b/.github/workflows/call-test.yml @@ -0,0 +1,65 @@ +name: Test + +on: + pull_request: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + pre-test: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + need_to_run: ${{ steps.set-matrix.outputs.need_to_run }} + + steps: + - name: generate matrix from PR body + id: set-matrix + env: + RAW_BODY: ${{ github.event.pull_request.body }} + run: | + RESULT=`echo $RAW_BODY | grep -o '\- \[x\] .*$' | sed 's/- \[x\] //' | awk 'BEGIN{printf "["}{printf "\"%s\", ", $0}END{printf "\b\b]"}'` + echo "matrix=$RESULT" >> $GITHUB_OUTPUT + if [ $(echo $RESULT | wc -L) -gt 6 ]; then + echo "need_to_run=true" >> $GITHUB_OUTPUT + else + echo "need_to_run=false" >> $GITHUB_OUTPUT + fi + + test: + runs-on: ubuntu-latest + needs: pre-test + if: ${{ needs.pre-test.outputs.need_to_run == 'true' }} + strategy: + fail-fast: true + matrix: + target-arch: ${{ fromJSON(needs.pre-test.outputs.matrix) }} + + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Update kernel submodules + if: ${{ startsWith(matrix.target-arch, 'kernel') }} + run: git submodule update --init kernel + + - name: Update buildroot submodules + if: ${{ startsWith(matrix.target-arch, 'kernel') }} + run: git submodule update --init buildroot + + - name: Install deps + run: sudo apt-get install -y build-essential flex bison libssl-dev libelf-dev bc + + - name: Install kernel arm64 deps + if: ${{ matrix.target-arch == 'kernel-arm64' }} + run: sudo apt-get install -y gcc-aarch64-linux-gnu + + - name: Defconfig + run: make defconfig-${{ matrix.target-arch }} + + - name: Build + run: make build-${{ matrix.target-arch }} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1b9e489..e69de29 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,62 +0,0 @@ -name: Test - -on: - pull_request: - types: - labeled - -# concurrency: -# group: ${{ github.workflow }}-${{ github.ref }} -# cancel-in-progress: true - -jobs: - pre-test: - runs-on: ubuntu-latest - # outputs: - # target: ${{ steps.set-target.outputs.target }} - # arch: ${{ steps.set-arch.outputs.arch }} - - steps: - - id: set-target - run: | - echo ${{ github.event.label.name }} - - run: | - echo ${{ join(github.event.pull_request.labels) }} - - run: | - echo ${{ toJSON(github.event.pull_request) }} - - run: | - echo ${{ toJSON(github) }} - - # test: - # runs-on: ubuntu-latest - # needs: pre-test - # strategy: - # fail-fast: true - # matrix: - # target: ${{ fromJSON(needs.pre-test.outputs.target) }} - # arch: ${{ fromJSON(needs.pre-test.outputs.arch) }} - - # steps: - # - name: Checkout - # uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - # - name: Update kernel submodules - # if: ${{ matrix.target == 'kernel'}} - # run: git submodule update --init kernel - - # - name: Update buildroot submodules - # if: ${{ matrix.target != 'kernel'}} - # run: git submodule update --init buildroot - - # - name: Install deps - # run: sudo apt-get install -y build-essential flex bison libssl-dev libelf-dev bc - - # - name: Install kernel arm64 deps - # if: ${{ matrix.target == 'kernel' && matrix.arch == 'arm64'}} - # run: sudo apt-get install -y gcc-aarch64-linux-gnu - - # - name: Defconfig - # run: make defconfig-${{ matrix.target }}-${{ matrix.arch }} - - # - name: Build - # run: make build-${{ matrix.target }}-${{ matrix.arch }} \ No newline at end of file