Skip to content

Commit

Permalink
ci: Introduce workflow Yocto operations/builds
Browse files Browse the repository at this point in the history
We include a workflow for checking yocto compliance using the poky
provided script and also a matrix workflow for building the CI supported
build configurations.

Signed-off-by: Andrei Gherzan <andrei.gherzan@huawei.com>
  • Loading branch information
Andrei Gherzan committed Feb 11, 2022
1 parent 8e44c32 commit a87d29d
Show file tree
Hide file tree
Showing 6 changed files with 245 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/docker-images/yocto-builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# SPDX-FileCopyrightText: Andrei Gherzan <andrei.gherzan@huawei.com>
#
# SPDX-License-Identifier: MIT

FROM ubuntu:20.04

ARG DEBIAN_FRONTEND="noninteractive"
RUN apt-get update -qq
RUN apt-get install -y eatmydata

# Yocto/OE build host dependencies
# Keep this in sync with
# https://git.yoctoproject.org/poky/tree/documentation/poky.yaml
RUN eatmydata apt-get install -qq -y \
gawk wget git diffstat unzip texinfo gcc build-essential chrpath \
socat cpio python3 python3-pip python3-pexpect xz-utils debianutils \
iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev \
pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool

# en_US.UTF-8 is required by the build system
RUN eatmydata apt-get install -qq -y locales \
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
&& locale-gen
ENV LANG en_US.utf8

RUN eatmydata apt-get clean && rm -rf /var/lib/apt/lists/*

# Have bash as shell
RUN echo "dash dash/sh boolean false" | debconf-set-selections \
&& DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash

# Run under normal user called 'ci'
RUN useradd --create-home --uid 1000 --shell /usr/bin/bash ci
USER ci
WORKDIR /home/ci

COPY ./yocto-builder/entrypoint-yocto-check-layer.sh /
COPY ./yocto-builder/entrypoint-build.sh /
COPY ./utils.sh /
16 changes: 16 additions & 0 deletions .github/workflows/docker-images/yocto-builder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!--
SPDX-FileCopyrightText: Andrei Gherzan <andrei.gherzan@huawei.com>
SPDX-License-Identifier: MIT
-->

# Docker image for builds

This defines the docker image for running Yocto/OE based operations/builds. It
privides multiples scripts for driving different operations.

## Configuration

The `entrypoint` scripts assumes at runtime that the repository to drive the
operation against is available under `/work`. This path is to be populated via
bind mounts when running the container.
55 changes: 55 additions & 0 deletions .github/workflows/docker-images/yocto-builder/entrypoint-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/sh

# SPDX-FileCopyrightText: Andrei Gherzan <andrei.gherzan@huawei.com>
#
# SPDX-License-Identifier: MIT

set -ex

# shellcheck disable=SC1091
. /utils.sh

META_RASPBERRYPI_PATH="/work"

[ -n "$BASE_REF" ] ||
error "Target branch is needed. Make sure that is set in BASE_REF."
[ -d "$META_RASPBERRYPI_PATH/.git" ] ||
error "Can't find a git checkout under $META_RASPBERRYPI_PATH ."
[ -n "$MACHINE" ] ||
error "Machine to be used for build not provided."
[ -n "$IMAGE" ] ||
error "Image to build not provided."

TEMP_DIR="$(mktemp -d)"
cd "$TEMP_DIR"

REPOS=" \
git://git.yoctoproject.org/poky.git \
"
for repo in $REPOS; do
log "Cloning $repo on branch $BASE_REF..."
git clone --depth 1 --branch "$BASE_REF" "$repo"
done

# shellcheck disable=SC1091,SC2240
. ./poky/oe-init-build-env build

# Build configuration
printf "\n------ ci ------\n" >> conf/local.conf
[ -z "$SSTATE_DIR" ] || echo SSTATE_DIR = \""$SSTATE_DIR"\" >> conf/local.conf
[ -z "$DL_DIR" ] || echo DL_DIR = \""$DL_DIR"\" >> conf/local.conf
[ -z "$DISTRO" ] || echo DISTRO = \""$DISTRO"\" >> conf/local.conf
{
echo BB_NUMBER_THREADS = \"6\"
echo PARALLEL_MAKE = \"-j 6\"
echo DISTRO_FEATURES:append = \" systemd\"
echo VIRTUAL-RUNTIME_init_manager = \"systemd\"
echo DISTRO_FEATURES_BACKFILL_CONSIDERED:append = \" sysvinit\"
echo VIRTUAL-RUNTIME_initscripts = \"systemd-compat-units\"
} >> conf/local.conf

# Add the BSP layer
bitbake-layers add-layer "$META_RASPBERRYPI_PATH"

# Fire!
MACHINE="$MACHINE" bitbake "$IMAGE"
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh

# SPDX-FileCopyrightText: Andrei Gherzan <andrei.gherzan@huawei.com>
#
# SPDX-License-Identifier: MIT

set -ex

# shellcheck disable=SC1091
. /utils.sh

GIT_REPO_PATH="/work"

[ -n "$BASE_REF" ] ||
error "Target branch is needed. Make sure that is set in BASE_REF."
[ -d "$GIT_REPO_PATH/.git" ] ||
error "Can't find a git checkout under $GIT_REPO_PATH ."

TEMP_DIR="$(mktemp -d)"
cd "$TEMP_DIR"

REPOS=" \
git://git.yoctoproject.org/poky.git \
"
for repo in $REPOS; do
log "Cloning $repo on branch $BASE_REF..."
git clone --depth 1 --branch "$BASE_REF" "$repo"
done

# shellcheck disable=SC1091,SC2240
. ./poky/oe-init-build-env build
yocto-check-layer --with-software-layer-signature-check --debug \
"$GIT_REPO_PATH"
65 changes: 65 additions & 0 deletions .github/workflows/yocto-builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# SPDX-FileCopyrightText: Andrei Gherzan <andrei.gherzan@huawei.com>
#
# SPDX-License-Identifier: MIT

name: Builds

on:
pull_request:

jobs:
build:
strategy:
fail-fast: true
matrix:
machine:
- raspberrypi
- raspberrypi0-2w-64
- raspberrypi0-2w
- raspberrypi0
- raspberrypi0-wifi
- raspberrypi2
- raspberrypi3-64
- raspberrypi3
- raspberrypi4-64
- raspberrypi4
- raspberrypi-cm3
- raspberrypi-cm
image: [core-image-base]
dl-dir: [/var/lib/ci/yocto/downloads]
sstate-dir: [/var/lib/ci/yocto/sstate]
distro: [poky]
runs-on: [self-hosted, Linux]
name: ${{ matrix.machine }}/${{ matrix.image }}/poky/systemd
steps:
- name: Checkout the code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build a temporary yocto-builder image
uses: ./.github/actions/docker-build
with:
docker_image: yocto-builder
id: ${{ github.event.number }}
- name: Build the image
run: |
docker run --rm \
-v "$GITHUB_WORKSPACE:/work:ro" \
-v ${{ matrix.sstate-dir }}:${{ matrix.sstate-dir }}:rw \
-v ${{ matrix.dl-dir }}:${{ matrix.dl-dir }}:rw \
--env "BASE_REF=$GITHUB_BASE_REF" \
--env "MACHINE=${{ matrix.machine }}" \
--env "DISTRO=${{ matrix.distro }}" \
--env "IMAGE=${{ matrix.image }}" \
--env "SSTATE_DIR=${{ matrix.sstate-dir }}" \
--env "DL_DIR=${{ matrix.dl-dir }}" \
"yocto-builder-${{ github.event.number }}" \
/entrypoint-build.sh
- name: Cleanup temporary docker image
uses: ./.github/actions/docker-clean-image
with:
docker_image: yocto-builder-${{ github.event.number }}
if: always()
- name: Cleanup dangling docker images
uses: ./.github/actions/docker-clean-dangling
if: always()
37 changes: 37 additions & 0 deletions .github/workflows/yocto-layer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-FileCopyrightText: Andrei Gherzan <andrei.gherzan@huawei.com>
#
# SPDX-License-Identifier: MIT

name: Yocto Compatible

on:
pull_request:

jobs:
yocto-check-layer:
name: Validate with yocto-check-layer
runs-on: [self-hosted, Linux]
steps:
- name: Checkout the code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build a temporary yocto-builder image
uses: ./.github/actions/docker-build
with:
docker_image: yocto-builder
id: ${{ github.event.number }}
- name: Run yocto-check-layer
run: |
docker run --rm -v "$GITHUB_WORKSPACE:/work:ro" \
--env "BASE_REF=$GITHUB_BASE_REF" \
"yocto-builder-${{ github.event.number }}" \
/entrypoint-yocto-check-layer.sh
- name: Cleanup temporary docker image
uses: ./.github/actions/docker-clean-image
with:
docker_image: yocto-builder-${{ github.event.number }}
if: always()
- name: Cleanup dangling docker images
uses: ./.github/actions/docker-clean-dangling
if: always()

0 comments on commit a87d29d

Please sign in to comment.