Skip to content

Commit

Permalink
Build a development image on release (#14)
Browse files Browse the repository at this point in the history
* Bump release action to v2

* Add development image container file

* Update CI/CD to build development image

* Fix aldebaran binaries extraction script path

* Specify shell in code blocks

* Check if patchelf is installed

* Update image used for CI/CD

* Remove toolchain after install

* Fix architecture name

* Build and release devimage in separate job

* Fix missing prefix

* Update containerfile to download toolchain

* Set arch only to x86_64 for now

* Fix container name

* Hardcode version for now

* Get architecture from within container build

* Add label and clean up apt cache

* Bump QEMU setup action

* Let image build run on github infrastructure

* Fix checkout path and tag

* Specify architectures as amd64 and arm64

* Fix registry

* Allow job to write packages

* Build image only on release

* Move naosdk containerfile to subdirectory

* Use second job as release action

* Use a two-stage build process

* Do not hardcode architecture in symlink

* Checkout repository before downloading artifacts

* Free up disk space in github runner

* Rename jobs

---------

Co-authored-by: Julian Schuler <[email protected]>
  • Loading branch information
julianschuler and julianschuler authored Jun 21, 2024
1 parent 1dfa88c commit 11e4218
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 17 deletions.
64 changes: 55 additions & 9 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: CI/CD
on: push
jobs:
cicd:
name: CI/CD
build:
name: Build
runs-on:
- self-hosted
- v3
- yocto
container:
image: ghcr.io/hulks/yocto_release
image: ghcr.io/hulks/meta-nao-cicd
options: --user=1000:1000
steps:
- name: Checkout repository
Expand All @@ -20,20 +20,66 @@ jobs:
run: kas checkout meta-nao/kas/base.yml:meta-nao/kas/hulks.yml
- name: Populate aldebaran_binaries.tar.gz
run: mkdir -p meta-nao/meta/recipes-support/aldebaran/aldebaran-binaries/ && cp /aldebaran_binaries.tar.gz meta-nao/meta/recipes-support/aldebaran/aldebaran-binaries/
- name: Build image
- name: Build NAO image
run: kas build --target nao-image --cmd build meta-nao/kas/base.yml:meta-nao/kas/hulks.yml
- name: Build SDK (x86_64)
run: kas build --target nao-image --cmd populate_sdk meta-nao/kas/base.yml:meta-nao/kas/hulks.yml
- name: Build SDK (aarch64)
run: kas build --target nao-image --cmd populate_sdk meta-nao/kas/base.yml:meta-nao/kas/hulks.yml:meta-nao/kas/aarch64.yml
- name: Release
uses: softprops/action-gh-release@v1
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: startsWith(github.ref, 'refs/tags/')
with:
name: HULKs-OS ${{ github.ref_name }}
body: Flashable image containing HULKs-OS ${{ github.ref_name }} and the corresponding SDK with the toolchain and other tools targeting HULKs-OS, for instructions see https://hulks.de/hulk/setup/overview/
files: |
name: all
path: |
build/tmp/deploy/images/nao-v6/nao-image-HULKs-OS-${{ github.ref_name }}.ext3.gz.opn
build/tmp/deploy/sdk/HULKs-OS-x86_64-toolchain-${{ github.ref_name }}.sh
build/tmp/deploy/sdk/HULKs-OS-aarch64-toolchain-${{ github.ref_name }}.sh
release:
name: Release
if: startsWith(github.ref, 'refs/tags/')
env:
version: ${{ github.ref_name }}
needs: build
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Free up disk space
run: sudo rm -rf /usr/local/lib/android
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: all
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Build development image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: naosdk
tags: ${{ env.version }} ${{ github.sha }}
archs: amd64, arm64
containerfiles: ./naosdk/Containerfile
build-args: version=${{ env.version }}
- name: Push development image to ghcr.io
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ghcr.io/hulks
username: ${{ github.actor }}
password: ${{ github.token }}
- uses: softprops/action-gh-release@v2
with:
name: HULKs-OS ${{ github.ref_name }}
body: Flashable image containing HULKs-OS ${{ github.ref_name }} and the corresponding SDK with the toolchain and other tools targeting HULKs-OS, for instructions see https://hulks.de/hulk/setup/overview/
files: |
images/nao-v6/nao-image-HULKs-OS-${{ github.ref_name }}.ext3.gz.opn
sdk/HULKs-OS-x86_64-toolchain-${{ github.ref_name }}.sh
sdk/HULKs-OS-aarch64-toolchain-${{ github.ref_name }}.sh
fail_on_unmatched_files: true
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ As this is a very first attempt with the Yocto project and image construction fo
3. *meta-nao* ships multiple `kas-project.yml` project description file. This file defines the project structure *kas* has to setup for the Yocto build phase.
Clone the *meta-nao* repository into some directory used for the Yocto build e.g. `worktree/meta-nao`.

```
```sh
git clone [email protected]:hulks/meta-nao worktree/meta-nao
```

4. The Nao V6 uses *LoLA* and *HAL* for the communication with the chestboard. All these binaries and libraries necessary to operate the Nao properly are shipped with the `.opn` robocupper image and **not** included in this repository. To acquire the necessary binaries the `meta-nao/recipes-support/aldebaran/extract_binaries.sh` script is used. This script fetches all binaries from inside the robocupper image and collects them in an archive for the upcoming build phase. To generate the archive containing the aldebaran binaries run:

```
cd meta-nao/recipes-support/aldebaran/
```sh
cd meta/recipes-support/aldebaran/
mkdir -p aldebaran-binaries
./extract_binaries.sh -o aldebaran-binaries/aldebaran_binaries.tar.gz nao-x86-firmware-249_20190503_203829_robocupper.opn
```
Expand All @@ -31,7 +31,7 @@ The script references the original robocupper image shipped by softbank. Contact

5. Execute *kas* from inside the `worktree` directory referencing the project description files to enter the build environment

```
```sh
./kas-container shell meta-nao/kas/base.yml:meta-nao/kas/hulks.yml
```

Expand All @@ -52,15 +52,15 @@ If your container shell does not work as expected, you might have to set your `T

6. Build a nao image. The Yocto project uses *BitBake* for task execution. Call the following build command from inside the *kas* container shell:

```
```sh
bitbake nao-image
```

This generates and executes all necessary tasks and targets to construct a proper `.opn` file. This build phase might take several hours depending on the performance of your build machine and your internet connection. *BitBake* uses a very elaborated caching strategy to speed up following builds of targets. Thus small changes afterwards can only take a few minutes.

7. Fetch and deploy the image. After *BitBake* ran all tasks up to `nao-opn` a new `.opn` file is generated in `worktree/build/tmp/deploy/images/nao-v6/nao-image-HULKs-OS-[VERSION].ext3.gz.opn`. To setup a flash stick run:

```
```sh
dd if=image_path.opn of=/dev/sdb bs=4M status=progress oflag=sync
```

Expand All @@ -87,7 +87,7 @@ The Yocto project contains tasks to build a proper SDK to use for development. T

1. Enter the build container

```
```sh
./kas-container -d shell meta-nao/kas/base.yml:meta-nao/kas/hulks.yml
```

Expand Down
2 changes: 1 addition & 1 deletion meta/recipes-support/aldebaran/extract_binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ if [ $# -lt 1 ]; then
exit 1
fi

for TOOL in "pigz" "guestmount"; do
for TOOL in "pigz" "guestmount" "patchelf"; do
hash "${TOOL}" 2>/dev/null || { echo >&2 "${TOOL} is not installed!"; exit 1; }
done

Expand Down
19 changes: 19 additions & 0 deletions naosdk/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM debian AS build

LABEL org.opencontainers.image.source https://github.com/hulks/meta-nao

RUN apt-get update && apt-get install --no-install-recommends --yes \
file \
python3 \
xz-utils \
zstd \
&& rm --recursive --force /var/lib/apt/lists/*

ARG version
COPY --chmod=744 sdk/HULKs-OS-*.sh /opt/
RUN /opt/HULKs-OS-$(uname -m)-toolchain-${version}.sh -d /naosdk

FROM busybox
COPY --from=build /naosdk /naosdk
RUN ln -s /naosdk/sysroots/$(uname -m)-naosdk-linux/bin/bash /bin/bash
RUN echo . /naosdk/environment-setup-corei7-64-aldebaran-linux >> /root/.bashrc

0 comments on commit 11e4218

Please sign in to comment.