Skip to content

Commit

Permalink
Add CI workflows for main branch and tags (#20)
Browse files Browse the repository at this point in the history
* update container registry and name in scripts and config
* remove elbe files and tests, no longer used
* add workflow for main branch, with robot tests and log upload
* add automated workflow to publish on tagging
* review finding: use yq, not awk

---------

Co-authored-by: Anton Jahn <[email protected]>
  • Loading branch information
antonjahn and Anton Jahn authored Nov 8, 2024
1 parent e882121 commit ff87d31
Show file tree
Hide file tree
Showing 35 changed files with 139 additions and 1,110 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/main-build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build and test image

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
- run: pip install -r requirements.txt

- run: env
- run: ./builder/build_container
- run: ./tests/run_tests

- uses: actions/upload-artifact@v4
if: always()
with:
name: robot-test-log
path: tests/log.html
40 changes: 40 additions & 0 deletions .github/workflows/publish-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Automated build, test and publish image for tag

on:
push:
tags: ["v*.*.*"]

jobs:
build-test-publish:
runs-on: ubuntu-latest

steps:
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout Repository
uses: actions/checkout@v4

- name: Compare version and tag name
run: |
VERSION=$(yq -r .Version configuration/build_config.yaml)
TAG_NAME=$(echo "${{ github.ref_name }}" | sed 's/refs\/tags\///')
if [ "${VERSION}" != "${TAG_NAME}" ]; then
echo "Version in build_config.yaml (${VERSION}) does not match tag name (${TAG_NAME})"
exit 1
fi
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
- run: pip install -r requirements.txt

- run: ./builder/build_container
- run: ./tests/run_tests
- run: ./builder/publish_container
12 changes: 5 additions & 7 deletions builder/export_container
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ echo "RUNNER: ${RUNNER}"

GIT_ROOT=$(git rev-parse --show-toplevel)

if [ -z "$1" ]; then
VERSION=$(cat ${GIT_ROOT}/configuration/build_config.yaml | grep Version: | awk -F " " '{print $2}')
else
VERSION=$1
fi
VERSION=${1:-$(yq -r .Version ${GIT_ROOT}/configuration/build_config.yaml)}
CONTAINER_NAME=$(yq -r '.["Base-Name"]' ${GIT_ROOT}/configuration/build_config.yaml)
REPO_NAME=$(yq -r .Repository ${GIT_ROOT}/configuration/build_config.yaml)

echo "Exporting dev container ${VERSION}"

Expand All @@ -27,7 +25,7 @@ echo "Exporting the container ${NAME}..."

set -e

$RUNNER run --name "${NAME}" "linux.elektrobit.com/ebcl/sdk_vscode:${VERSION}"
$RUNNER export "${NAME}" | xz > "ebcl_dev_container_${VERSION}.tar.xz"
$RUNNER run --name "${NAME}" "${REPO_NAME}/${CONTAINER_NAME}:${VERSION}"
$RUNNER export "${NAME}" | xz -T0 >"${CONTAINER_NAME}_${VERSION}.tar.xz"
$RUNNER stop "${NAME}"
$RUNNER rm "${NAME}"
19 changes: 19 additions & 0 deletions builder/publish_container
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

if [ -z $RUNNER ]; then
# docker or podman
RUNNER="docker"
fi

echo "RUNNER: ${RUNNER}"

GIT_ROOT=$(git rev-parse --show-toplevel)

VERSION=${1:-$(yq -r .Version ${GIT_ROOT}/configuration/build_config.yaml)}
CONTAINER_NAME=$(yq -r '.["Base-Name"]' ${GIT_ROOT}/configuration/build_config.yaml)
REPO_NAME=$(yq -r .Repository ${GIT_ROOT}/configuration/build_config.yaml)

echo "Publishing dev container ${VERSION}"

set -e
$RUNNER push "${REPO_NAME}/${CONTAINER_NAME}:${VERSION}"
4 changes: 2 additions & 2 deletions configuration/build_config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Base-Name: sdk
Repository: linux.elektrobit.com/ebcl
Base-Name: ebcl_dev_container
Repository: ghcr.io/elektrobit
Base-Container: ubuntu:22.04
Version: v1.3.10
Layers:
Expand Down
2 changes: 1 addition & 1 deletion layers/appdev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG CONTAINER_USER="ebcl"

USER root

# install elbe dependencies
# install dependencies
ENV DEBIAN_FRONTEND noninteractive
RUN apt -y install libjsoncpp-dev

Expand Down
62 changes: 0 additions & 62 deletions layers/elbe/Dockerfile

This file was deleted.

6 changes: 0 additions & 6 deletions layers/elbe/README.md

This file was deleted.

158 changes: 0 additions & 158 deletions layers/elbe/config/elbe/source.xml

This file was deleted.

Loading

0 comments on commit ff87d31

Please sign in to comment.