Skip to content

Commit

Permalink
Add github-based CI build
Browse files Browse the repository at this point in the history
  • Loading branch information
anikinmd authored and mdanikin committed Aug 26, 2024
1 parent 68d1896 commit 9881c0a
Show file tree
Hide file tree
Showing 5 changed files with 217 additions and 2 deletions.
184 changes: 184 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
name: build

on:
push:
branches: [ "kirkstone-imx8m" ]
pull_request:
branches: [ "kirkstone-imx8m" ]
schedule:
- cron: "0 0 * * 5"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
prepare_container:
runs-on: self-hosted
outputs:
uid: ${{ steps.uid_step.outputs.userid }}
gid: ${{ steps.uid_step.outputs.groupid }}
steps:
- uses: actions/checkout@v4

- name: Get user id/group
id: uid_step
run: |
echo "userid=$(id -u)" >> "$GITHUB_OUTPUT"
echo "groupid=$(id -g)" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-config: /etc/docker/cibuilder.toml

- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: ciserver.ci:5000
username: ${{ secrets.CI_CACHE_REGISTRY_LOGIN }}
password: ${{ secrets.CI_CACHE_REGISTRY_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./docker
push: true
tags: ciserver.ci:5000/${{ github.repository_id }}:latest
cache-from: type=registry,ref=ciserver.ci:5000/${{ github.repository_id }}:cache
cache-to: type=registry,ref=ciserver.ci:5000/${{ github.repository_id }}:cache,mode=max
file: docker/Dockerfile
build-args: |
PUID=${{ steps.uid_step.outputs.userid }}
PGID=${{ steps.uid_step.outputs.groupid }}
build_images:
needs: prepare_container
runs-on: self-hosted
container:
image: ciserver.ci:5000/${{ github.repository_id }}:latest
credentials:
username: ${{ secrets.CI_CACHE_REGISTRY_LOGIN }}
password: ${{ secrets.CI_CACHE_REGISTRY_PASSWORD }}
options: --user "${{ needs.prepare_container.outputs.uid }}:${{ needs.prepare_container.outputs.gid }}"
outputs:
build_tag: ${{ steps.tag_step.outputs.build_tag }}
steps:
- name: Checkout dependencies
run: |
repo init -u https://github.com/SolidRun/meta-solidrun-arm-imx8 \
-b ${{ github.head_ref }}\
-m sr-imx-5.15.71-2.2.0.xml
repo sync
rm -rf sources/meta-solidrun-arm-imx8
- name: Checkout layer sources
uses: actions/checkout@v4
with:
path: sources/meta-solidrun-arm-imx8

- name: Get build tag
id: tag_step
run: |
build_tag=$(date +%Y-%m-%d)_$(cd sources/meta-solidrun-arm-imx8; git rev-parse --short HEAD)
echo "build_tag=$build_tag" >> "$GITHUB_OUTPUT"
- name: Create cache dir
run: mkdir -p buildcache

- name: Fetch cache from server
uses: tespkg/actions-cache/restore@v1
with:
endpoint: ciserver.ci
port: 9000
insecure: true
accessKey: ${{ secrets.CI_CACHE_MINIO_ACCESS }}
secretKey: ${{ secrets.CI_CACHE_MINIO_SECRET }}
bucket: cicache
use-fallback: false
key: ${{ github.repository }}
path: |
buildcache
- name: Build
shell: bash
run: |
WORKDIR=$(pwd)
DISTRO=fsl-imx-xwayland MACHINE=imx8mpsolidrun EULA=1 source imx-setup-release.sh -b build-xwayland-imx8mpsolidrun
export CACHE_DIR="$WORKDIR/buildcache"
export BB_ENV_PASSTHROUGH_ADDITIONS="$BB_ENV_PASSTHROUGH_ADDITIONS CACHE_DIR"
echo "require conf/include/ci.conf" >> conf/local.conf
cat conf/local.conf
bitbake core-image-minimal imx-image-full imx-hailo-demo-image --runall=fetch
bitbake core-image-minimal imx-image-full imx-hailo-demo-image -k
- name: Update cache on the server
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
uses: tespkg/actions-cache/save@v1
with:
endpoint: ciserver.ci
port: 9000
insecure: true
accessKey: ${{ secrets.CI_CACHE_MINIO_ACCESS }}
secretKey: ${{ secrets.CI_CACHE_MINIO_SECRET }}
bucket: cicache
use-fallback: false
key: ${{ github.repository }}
path: |
buildcache
- name: Copy deploy artifacts
shell: bash
run: |
mkdir deploy
BUILD_PATH=build-xwayland-imx8mpsolidrun/tmp/deploy/images/imx8mpsolidrun
cp $BUILD_PATH/core-image-minimal-imx8mpsolidrun.wic.zst deploy/
cp $BUILD_PATH/core-image-minimal-imx8mpsolidrun.wic.bmap deploy/
cp $BUILD_PATH/imx-image-full-imx8mpsolidrun.wic.zst deploy/
cp $BUILD_PATH/imx-image-full-imx8mpsolidrun.wic.bmap deploy/
cp $BUILD_PATH/imx-hailo-demo-image-imx8mpsolidrun.wic.zst deploy/
cp $BUILD_PATH/imx-hailo-demo-image-imx8mpsolidrun.wic.bmap deploy/
- name: Deploy to the local minio storage
uses: yakubique/[email protected]
with:
endpoint: http://ciserver.ci:9000
insecure: true
access_key: ${{ secrets.CI_CACHE_MINIO_ACCESS }}
secret_key: ${{ secrets.CI_CACHE_MINIO_SECRET }}
bucket: cipublish
source: ./deploy
target: "/${{ github.repository_id }}/${{ steps.tag_step.outputs.build_tag }}"
recursive: true

publish_images:
needs: build_images
runs-on: self-hosted
if: github.event_name == 'push'
steps:
- name: Download an artifacts from MinIO
uses: yakubique/[email protected]
with:
endpoint: http://ciserver.ci:9000
insecure: true
access_key: ${{ secrets.CI_CACHE_MINIO_ACCESS }}
secret_key: ${{ secrets.CI_CACHE_MINIO_SECRET }}
bucket: cipublish
source: "/${{ github.repository_id }}/${{ needs.build_images.outputs.build_tag }}/"
target: "."
recursive: true

- name: Assign a build tag
run: |
mkdir -p s3
tar cJf s3/solidrun-imx8_${{ needs.build_images.outputs.build_tag }}.tar.xz \
-C deploy/ .
- name: Upload to S3
uses: shallwefootball/[email protected]
with:
aws_key_id: ${{ secrets.IMAGES_S3_ACCESS }}
aws_secret_access_key: ${{ secrets.IMAGES_S3_SECRET }}
aws_bucket: ${{ secrets.IMAGES_S3_BUCKET }}
endpoint: ${{ secrets.IMAGES_S3_HOST }}
source_dir: s3
destination_dir: IMX8/imx8mp_yocto_kirkstone-5.15.71-2.2.0/${{ needs.build_images.outputs.build_tag }}
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"python.autoComplete.extraPaths": [
"${workspaceFolder}/sources/poky/bitbake/lib",
"${workspaceFolder}/sources/poky/meta/lib"
],
"files.associations": {
"*.conf": "bitbake",
"*.inc": "bitbake"
}
}
14 changes: 14 additions & 0 deletions conf/include/ci.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CACHE_DIR ??= "${TOPDIR}"

BB_GENERATE_MIRROR_TARBALLS = "1"
BB_GIT_SHALLOW ?= "1"
BB_GIT_SHALLOW_DEPTH ?= "1"

DL_DIR = "${CACHE_DIR}/downloads"
SSTATE_DIR = "${CACHE_DIR}/sstate-cache"
CCACHE_TOP_DIR = "${CACHE_DIR}/ccache"

INHERIT += "ccache"
INHERIT += "rm_work"

LICENSE_FLAGS_ACCEPTED += "commercial_ffmpeg"
9 changes: 8 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN apt-get update
RUN apt-get install -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 \
python3-subunit mesa-common-dev zstd liblz4-tool file locales
python3-subunit mesa-common-dev zstd liblz4-tool file locales curl


RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
Expand All @@ -15,6 +15,9 @@ RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \

ENV LANG en_US.UTF-8

RUN curl https://storage.googleapis.com/git-repo-downloads/repo > /usr/local/bin/repo
RUN chmod a+rx /usr/local/bin/repo

# You can set the container's root password here. Use this only locally since this
# is clearly a security issue.
RUN echo "root:root" | chpasswd
Expand All @@ -25,6 +28,10 @@ ARG PGID=1000

RUN groupadd -g ${PGID} ${USERNAME} && useradd -u ${PUID} -g ${USERNAME} -d /home/${USERNAME} ${USERNAME} && mkdir /home/${USERNAME} && chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}

RUN git config --add --system user.email "[email protected]"
RUN git config --add --system user.name "Build Container"
RUN git config --add --system http.version HTTP/1.1

COPY .bashrc /home/${USERNAME}/.bashrc

USER ${USERNAME}
Expand Down
2 changes: 1 addition & 1 deletion sr-imx-5.15.71-2.2.0.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<project name="meta-timesys" path="sources/meta-timesys" remote="Timesys" revision="d1ad27bfacc937048e7f9084b17f4d7c917d2004" upstream="master"/>
<project name="meta-virtualization" path="sources/meta-virtualization" remote="yocto" revision="9d056f957b42e31f1c2c5bad0af1ab6c84b53ee6" upstream="kirkstone"/>
<project name="poky" path="sources/poky" remote="yocto" revision="f53ab3a2ff206a130cdc843839dd0ea5ec4ad02f" upstream="kirkstone"/>
<project name="meta-hailo" path="sources/meta-hailo" remote="hailo-ai" revision="7c1fbd2e312b04dae53accf5ff8fe77d1e52e488" upstream="kirkstone"/>
<project name="meta-hailo" path="sources/meta-hailo" remote="hailo-ai" revision="c093ed15914abd456afd6d81ced6e6b2b77e180e" upstream="kirkstone"/>
<project name="meta-mender" path="sources/meta-mender" remote="mender" revision="eb5b14577295ec3a15d3b21602ac4607a0cb3ad8" upstream="kirkstone"/>
<project name="meta-solidrun-arm-imx8" path="sources/meta-solidrun-arm-imx8" remote="solidrun" revision="kirkstone-imx8m">
<linkfile dest="imx-setup-release.sh" src="setup.sh"/>
Expand Down

0 comments on commit 9881c0a

Please sign in to comment.