From 69850dff0d60057881ead03972dfe80e9c7fd10d Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Mon, 6 May 2024 16:28:04 +0200 Subject: [PATCH 1/4] CI: reusable_build: add support for uploading compiled images Add support for uploading compiled images if build_full is triggered. This is in preparation for testing the images in QEMU if supported. Signed-off-by: Christian Marangi --- .github/workflows/reusable_build.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/reusable_build.yml b/.github/workflows/reusable_build.yml index d22542d1..463ba0fb 100644 --- a/.github/workflows/reusable_build.yml +++ b/.github/workflows/reusable_build.yml @@ -59,6 +59,8 @@ on: type: boolean upload_external_toolchain: type: boolean + upload_images: + type: boolean use_ccache_cache: type: boolean default: true @@ -739,3 +741,12 @@ jobs: name: ${{ inputs.target }}-${{ inputs.subtarget }}-external-toolchain path: openwrt/bin/targets/${{ inputs.target }}/${{ inputs.subtarget }}/${{ steps.get-toolchain-name.outputs.toolchain-name }} retention-days: 1 + + - name: Upload compiled images + if: inputs.build_full == true && inputs.upload_images == true + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.target }}-${{ inputs.subtarget }}${{ inputs.testing == true && '-testing' || '' }}-images + path: | + openwrt/bin/targets/${{ inputs.target }}/${{ inputs.subtarget }}/openwrt-${{ inputs.target }}-${{ inputs.subtarget }}-* + retention-days: 1 From 0caf7ac58308c8cfa4d0e5ed897d53aea3f9a8ac Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Mon, 6 May 2024 17:05:26 +0200 Subject: [PATCH 2/4] CI: reusable_test-image: introduce reusable test-image workflow Introduce reusable test-image workflow. Currently only QEMU is supported. This assume it's run after an artifact is uploaded by other workflow. Signed-off-by: Christian Marangi --- .github/workflows/reusable_test-image.yml | 63 +++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/reusable_test-image.yml diff --git a/.github/workflows/reusable_test-image.yml b/.github/workflows/reusable_test-image.yml new file mode 100644 index 00000000..3cfce12a --- /dev/null +++ b/.github/workflows/reusable_test-image.yml @@ -0,0 +1,63 @@ +name: Test Image + +on: + workflow_call: + inputs: + target: + required: true + type: string + subtarget: + required: true + type: string + testing: + type: boolean + image: + required: true + type: string + use_qemu: + type: boolean + qemu_target: + type: string + qemu_bin: + type: string + +jobs: + test: + name: Test image ${{ inputs.target }}/${{ inputs.subtarget }} + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + repository: aparcar/openwrt-tests + + - name: Install dependencies + run: | + sudo apt install python3-pip + + - name: Install QEMU dependency + if: inputs.use_qemu == true + run: | + sudo apt install qemu-system-${{ inputs.qemu_target }} + + - name: Install test project dependencies + run: | + pip3 install poetry + poetry install + + - name: Download compiled images from build job + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.target }}-${{ inputs.subtarget }}${{ inputs.testing == true && '-testing' || '' }}-images + + - name: Run test with QEMU + if: inputs.use_qemu == true + run: | + export LG_QEMU_BIN=qemu-system-${{ inputs.qemu_bin || inputs.qemu_target }} + + poetry run pytest \ + --lg-env tests/qemu.yaml \ + --target ${{ inputs.target }}-${{ inputs.subtarget }} \ + --firmware "$(pwd)"/${{ inputs.image }} + From f936dfac77b641004cef628c845872d4114fd70b Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Mon, 6 May 2024 17:12:53 +0200 Subject: [PATCH 3/4] CI: packages: enable testing with QEMU Add additional job to enable testing with QEMU using the new reusable_test-image workflow. Signed-off-by: Christian Marangi --- .github/workflows/packages.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 7e4fa948..cfdd2818 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -44,10 +44,38 @@ jobs: build_all_kmods: true build_all_modules: true build_full: true + upload_images: true ccache_type: packages upload_ccache_cache: ${{ github.repository_owner == 'openwrt' }} check_packages_list: ${{ needs.determine_changed_packages.outputs.changed_packages }} + test: + name: Test with QEMU + needs: build + strategy: + fail-fast: False + matrix: + include: + - target: malta + subtarget: be + image: openwrt-malta-be-vmlinux-initramfs.elf + use_qemu: true + qemu_target: mips + - target: x86 + subtarget: 64 + image: openwrt-x86-64-generic-squashfs-combined.img + use_qemu: true + qemu_target: x86 + qemu_bin: x86_64 + uses: ./.github/workflows/reusable_test-image.yml + with: + target: ${{ matrix.target }} + subtarget: ${{ matrix.subtarget }} + image: ${{ matrix.image }} + use_qemu: ${{ matrix.use_qemu }} + qemu_target: ${{ matrix.qemu_target }} + qemu_bin: ${{ matrix.qemu_bin || '' }} + upload-ccache-cache-in-s3: if: github.event_name == 'push' && github.repository_owner == 'openwrt' name: Upload ccache cache to s3 From 92d33d6b7adf48f2603c122521ceda77d07ff018 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Mon, 6 May 2024 18:11:20 +0200 Subject: [PATCH 4/4] CI: reusable_test-image: extract .gz image if needed Some images are compressed with .gz format, extract them to correctly use them. Signed-off-by: Christian Marangi --- .github/workflows/reusable_test-image.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/reusable_test-image.yml b/.github/workflows/reusable_test-image.yml index 3cfce12a..9c27c4e0 100644 --- a/.github/workflows/reusable_test-image.yml +++ b/.github/workflows/reusable_test-image.yml @@ -50,6 +50,13 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{ inputs.target }}-${{ inputs.subtarget }}${{ inputs.testing == true && '-testing' || '' }}-images + + - name: Extract image if needed + run: | + # gunzip return 2 for warning hence we need to reset + if [ -f "${{ inputs.image }}.gz" ]; then + gunzip -q ${{ inputs.image }}.gz || true + fi - name: Run test with QEMU if: inputs.use_qemu == true