* [PATCH 1/1] Add GitHub CI
2023-05-04 8:58 [PATCH 0/1] GitHub actions for barebox Sascha Hauer
@ 2023-05-04 8:58 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2023-05-04 8:58 UTC (permalink / raw)
To: Barebox List
This adds the necessary bits and pieces to build and test barebox with
GitHub actions.
Currently barebox is build tested in all architectures and all
defconfigs. Additionally labgrid-pytest runs for architectures we have
Qemu support for.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
.github/workflows/container.yml | 32 ++++++++
.github/workflows/test-defconfigs.yml | 44 +++++++++++
.github/workflows/test-labgrid-pytest.yml | 70 ++++++++++++++++++
test/Containerfile | 89 +++++++++++++++++++++++
test/generate-dummy-fw.sh | 62 ++++++++++++++++
test/kconfig/disable_size_check.kconf | 1 +
test/kconfig/disable_target_tools.kconf | 5 ++
test/kconfig/enable_self_test.kconf | 5 ++
8 files changed, 308 insertions(+)
create mode 100644 .github/workflows/container.yml
create mode 100644 .github/workflows/test-defconfigs.yml
create mode 100644 .github/workflows/test-labgrid-pytest.yml
create mode 100644 test/Containerfile
create mode 100755 test/generate-dummy-fw.sh
create mode 100644 test/kconfig/disable_size_check.kconf
create mode 100644 test/kconfig/disable_target_tools.kconf
create mode 100644 test/kconfig/enable_self_test.kconf
diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml
new file mode 100644
index 0000000000..434745ae61
--- /dev/null
+++ b/.github/workflows/container.yml
@@ -0,0 +1,32 @@
+name: build ci container
+
+on:
+ push:
+ branches:
+ - 'master'
+ - 'ci'
+ paths:
+ - 'test/Containerfile'
+ workflow_dispatch: {}
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - id: build-image
+ uses: redhat-actions/buildah-build@v2
+ with:
+ image: barebox-ci
+ tags: latest
+ dockerfiles: |
+ ./test/Containerfile
+ - id: push-to-github
+ uses: redhat-actions/push-to-registry@v2
+ with:
+ image: ${{ steps.build-image.outputs.image }}
+ tags: ${{ steps.build-image.outputs.tags }}
+ registry: ghcr.io/${{ github.repository }}
+ username: ${{ github.actor }}
+ password: ${{ github.token }}
+ - run: echo "Image pushed to ${{ steps.push-to-github.outputs.registry-paths }}"
diff --git a/.github/workflows/test-defconfigs.yml b/.github/workflows/test-defconfigs.yml
new file mode 100644
index 0000000000..108e54d289
--- /dev/null
+++ b/.github/workflows/test-defconfigs.yml
@@ -0,0 +1,44 @@
+name: build all defconfigs
+
+on: [push, pull_request]
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ container:
+ image: ghcr.io/barebox/barebox/barebox-ci:latest
+ # allow mounting and devtmpfs in the container
+ options: --user=root --privileged -v /dev:/dev
+
+ strategy:
+ matrix:
+ arch: [mips, powerpc, riscv, sandbox, x86 ]
+ regex: ["*"]
+ include:
+ - arch: arm
+ regex: "[a-b]*"
+ - arch: arm
+ regex: "[c-m]*"
+ - arch: arm
+ regex: "[n-q]*"
+ - arch: arm
+ regex: "[r-z]*"
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Build
+ run: |
+ export ARCH=${{matrix.arch}}
+
+ export CROSS_COMPILE_arm=/opt/gcc-12.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-
+ export CROSS_COMPILE_arm64=/opt/gcc-12.2.0-nolibc/aarch64-linux/bin/aarch64-linux-
+ export CROSS_COMPILE_mips=/opt/gcc-12.2.0-nolibc/mips-linux/bin/mips-linux-
+ export CROSS_COMPILE_powerpc=/opt/gcc-12.2.0-nolibc/powerpc-linux/bin/powerpc-linux-
+ export CROSS_COMPILE_riscv=/opt/gcc-12.2.0-nolibc/riscv32-linux/bin/riscv32-linux-
+
+ ./test/generate-dummy-fw.sh
+
+ ./MAKEALL -O build-${{matrix.arch}} -k test/kconfig/disable_size_check.kconf \
+ -k test/kconfig/disable_target_tools.kconf -e '${{matrix.regex}}'
diff --git a/.github/workflows/test-labgrid-pytest.yml b/.github/workflows/test-labgrid-pytest.yml
new file mode 100644
index 0000000000..2c74150066
--- /dev/null
+++ b/.github/workflows/test-labgrid-pytest.yml
@@ -0,0 +1,70 @@
+name: test images with labgrid-pytest
+
+on: [push, pull_request]
+
+jobs:
+ labgrid-pytest:
+ runs-on: ubuntu-latest
+ container:
+ image: ghcr.io/barebox/barebox/barebox-ci:latest
+ # allow mounting and devtmpfs in the container
+ options: --user=root --privileged -v /dev:/dev
+
+ strategy:
+ matrix:
+
+ include:
+ - ARCH: arm
+ lgenv: 'test/arm/*@multi_v7_defconfig.yaml'
+ defconfig: multi_v7_defconfig
+
+ - ARCH: arm
+ lgenv: test/arm/multi_v8_defconfig.yaml
+ defconfig: multi_v8_defconfig
+
+ - ARCH: mips
+ lgenv: test/mips/qemu-malta_defconfig.yaml
+ defconfig: qemu-malta_defconfig
+
+ - ARCH: x86
+ lgenv: test/x86/efi_defconfig.yaml
+ defconfig: efi_defconfig
+
+ - ARCH: riscv
+ lgenv: test/riscv/qemu@virt32_defconfig.yaml
+ defconfig: virt32_defconfig
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Build
+ run: |
+ export ARCH=${{matrix.arch}}
+
+ export CROSS_COMPILE_arm=/opt/gcc-12.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-
+ export CROSS_COMPILE_arm64=/opt/gcc-12.2.0-nolibc/aarch64-linux/bin/aarch64-linux-
+ export CROSS_COMPILE_mips=/opt/gcc-12.2.0-nolibc/mips-linux/bin/mips-linux-
+ export CROSS_COMPILE_powerpc=/opt/gcc-12.2.0-nolibc/powerpc-linux/bin/powerpc-linux-
+ export CROSS_COMPILE_riscv=/opt/gcc-12.2.0-nolibc/riscv32-linux/bin/riscv32-linux-
+
+ ./test/generate-dummy-fw.sh
+
+ ./MAKEALL -O build-${{matrix.arch}} -k test/kconfig/enable_self_test.kconf \
+ -k test/kconfig/disable_target_tools.kconf ${{matrix.defconfig}}
+
+ if [ ${{matrix.arch}} = "x86" ]; then
+ cp /usr/share/ovmf/OVMF.fd build-${{matrix.arch}}
+ fi
+
+ if [ ${{matrix.arch}} = "riscv" ]; then
+ cp /usr/share/qemu/opensbi-riscv32-generic-fw_dynamic.bin build-${{matrix.arch}}
+ fi
+ - name: labgrid-pytest
+ run: |
+ export KBUILD_OUTPUT=build-${{matrix.arch}}
+
+ for i in ${{matrix.lgenv}}; do
+ echo "Testing $i"
+ labgrid-pytest --lg-env $i test/py --verbosity=1 --lg-log
+ done
diff --git a/test/Containerfile b/test/Containerfile
new file mode 100644
index 0000000000..8c9502c0a1
--- /dev/null
+++ b/test/Containerfile
@@ -0,0 +1,89 @@
+# SPDX-License-Identifier: GPL-2.0+
+# This Containerfile is used to build an image containing basic stuff to be used
+# to build barebox and run our test suites.
+
+FROM debian:bullseye
+MAINTAINER Sascha Hauer <s.hauer@pengutronix.de>
+LABEL Description="This image is for building and testing barebox inside a container"
+
+# Make sure apt is happy
+ENV DEBIAN_FRONTEND=noninteractive
+
+# Update and install things from apt now
+RUN apt-get update && apt-get install -y \
+ automake \
+ autopoint \
+ bc \
+ binutils-dev \
+ bison \
+ build-essential \
+ coreutils \
+ cpio \
+ cppcheck \
+ curl \
+ erofs-utils \
+ expect \
+ flex \
+ gawk \
+ gdisk \
+ git \
+ imagemagick \
+ libc6-i386 \
+ libgit2-dev \
+ libguestfs-tools \
+ liblz4-tool \
+ libseccomp-dev \
+ libssl-dev \
+ libtool \
+ libudev-dev \
+ libusb-1.0-0-dev \
+ lzma-alone \
+ lzop \
+ mount \
+ openssl \
+ pkg-config \
+ rpm2cpio \
+ util-linux \
+ uuid-dev \
+ zip \
+ wget \
+ qemu-system-arm \
+ qemu-system-misc \
+ qemu-system-mips \
+ qemu-system-x86 \
+ qemu-system-common \
+ ovmf \
+ python3 \
+ python3-pip \
+ python3-virtualenv \
+ python3-setuptools \
+ virtualenv \
+ microcom \
+ sudo \
+ libyaml-tiny-perl \
+ libyaml-libyaml-perl \
+ && rm -rf /var/lib/apt/lists/*
+
+# Manually install the kernel.org Crosstool based toolchains for gcc-12.2.0
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-aarch64-linux.tar.xz | tar -C /opt -xJ
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-arm-linux-gnueabi.tar.xz | tar -C /opt -xJ
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-i386-linux.tar.xz | tar -C /opt -xJ
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-mips-linux.tar.xz | tar -C /opt -xJ
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-powerpc-linux.tar.xz | tar -C /opt -xJ
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-riscv64-linux.tar.xz | tar -C /opt -xJ
+RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/12.2.0/x86_64-gcc-12.2.0-nolibc-riscv32-linux.tar.xz | tar -C /opt -xJ
+
+RUN wget "https://github.com/qemu/qemu/blob/v5.2.0/pc-bios/opensbi-riscv32-generic-fw_dynamic.bin?raw=true" -O /usr/share/qemu/opensbi-riscv32-generic-fw_dynamic.bin
+
+# Create our user/group
+RUN useradd -m -U barebox
+RUN echo barebox ALL=NOPASSWD: ALL > /etc/sudoers.d/barebox
+
+# install labgrid
+RUN cd /tmp && \
+ git clone --depth 1 -b v23.0 https://github.com/labgrid-project/labgrid && \
+ cd labgrid && \
+ pip3 install . && \
+ ln -s $(which pytest) /usr/local/bin/labgrid-pytest;
+
+USER barebox:barebox
diff --git a/test/generate-dummy-fw.sh b/test/generate-dummy-fw.sh
new file mode 100755
index 0000000000..5005197891
--- /dev/null
+++ b/test/generate-dummy-fw.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+#
+# Generate dummy firmware files for compile tests
+#
+
+FW_NXP_LPDDR4="
+ firmware/lpddr4_pmu_train_1d_dmem.bin
+ firmware/lpddr4_pmu_train_1d_imem.bin
+ firmware/lpddr4_pmu_train_2d_dmem.bin
+ firmware/lpddr4_pmu_train_2d_imem.bin
+"
+
+FW_NXP_DDR4="
+ firmware/ddr4_dmem_1d.bin
+ firmware/ddr4_dmem_2d.bin
+ firmware/ddr4_imem_1d.bin
+ firmware/ddr4_imem_2d.bin
+"
+
+FW_BL31="
+ firmware/imx8mm-bl31.bin
+ firmware/imx8mn-bl31.bin
+ firmware/imx8mp-bl31.bin
+ firmware/imx8mq-bl31.bin
+ firmware/rk3568-bl31.bin
+"
+
+FW_ROCKCHIP_SDRAM_INIT="
+ arch/arm/boards/pine64-quartz64/sdram-init.bin
+ arch/arm/boards/radxa-rock3/sdram-init.bin
+ arch/arm/boards/rockchip-rk3568-bpi-r2pro/sdram-init.bin
+ arch/arm/boards/rockchip-rk3568-evb/sdram-init.bin
+"
+
+FW_MVEBU_BINARY0="
+ arch/arm/boards/globalscale-mirabox/binary.0
+ arch/arm/boards/lenovo-ix4-300d/binary.0
+ arch/arm/boards/marvell-armada-xp-db/binary.0
+ arch/arm/boards/marvell-armada-xp-gp/binary.0
+ arch/arm/boards/netgear-rn104/binary.0
+ arch/arm/boards/netgear-rn2120/binary.0
+ arch/arm/boards/plathome-openblocks-ax3/binary.0
+ arch/arm/boards/turris-omnia/binary.0
+"
+
+FW_NXP_LAYERSCAPE="
+ firmware/fsl_fman_ucode_ls1046_r1.0_106_4_18.bin
+ firmware/ppa-ls1046a.bin
+"
+
+FW="
+ $FW_NXP_LPDDR4
+ $FW_NXP_DDR4
+ $FW_BL31
+ $FW_ROCKCHIP_SDRAM_INIT
+ $FW_MVEBU_BINARY0
+ $FW_NXP_LAYERSCAPE
+"
+
+for i in $FW; do
+ echo "Dummy firmware generated for $i" > $i
+done
diff --git a/test/kconfig/disable_size_check.kconf b/test/kconfig/disable_size_check.kconf
new file mode 100644
index 0000000000..3819f8a32c
--- /dev/null
+++ b/test/kconfig/disable_size_check.kconf
@@ -0,0 +1 @@
+CONFIG_BAREBOX_MAX_IMAGE_SIZE=0xffffffff
diff --git a/test/kconfig/disable_target_tools.kconf b/test/kconfig/disable_target_tools.kconf
new file mode 100644
index 0000000000..55cb99b891
--- /dev/null
+++ b/test/kconfig/disable_target_tools.kconf
@@ -0,0 +1,5 @@
+# CONFIG_IMD_TARGET is not set
+# CONFIG_KERNEL_INSTALL_TARGET is not set
+# CONFIG_BAREBOXENV_TARGET is not set
+# CONFIG_BAREBOXCRC32_TARGET is not set
+# CONFIG_MVEBU_KWBOOT_TARGET is not set
diff --git a/test/kconfig/enable_self_test.kconf b/test/kconfig/enable_self_test.kconf
new file mode 100644
index 0000000000..f5cd7821b9
--- /dev/null
+++ b/test/kconfig/enable_self_test.kconf
@@ -0,0 +1,5 @@
+CONFIG_SELFTEST_ENABLE_ALL=y
+CONFIG_TEST=y
+CONFIG_CMD_SELFTEST=y
+CONFIG_SELFTEST=y
+
--
2.39.2
^ permalink raw reply [flat|nested] 2+ messages in thread