Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub actions #61

Merged
merged 23 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
949c644
Add test stage to Dockerfile
ll-nick Oct 25, 2024
20cc048
Add unit test workflow
ll-nick Oct 25, 2024
4958b1f
Use WORKDIR to simplify Dockerfile
ll-nick Nov 6, 2024
bb3c191
Add unittest stage to demo/Dockerfile
ll-nick Nov 6, 2024
fd8ee1d
Extend unit test workflow by demo unit tests
ll-nick Nov 6, 2024
ad82353
Add version tag to devel image as well
ll-nick Nov 6, 2024
1097664
Switch to docker-compose for GitHub actions
ll-nick Nov 6, 2024
9c41d0d
Fix unit test failure caused by changes on main
ll-nick Nov 7, 2024
f135a9a
Run unit test workflow on pushes to any branch
ll-nick Nov 7, 2024
b7b0184
Add workflow action to build and release pacman demo image
ll-nick Nov 7, 2024
04998e5
Add workflow action to build and push tutorial docker image
ll-nick Nov 7, 2024
a419619
Switch back to pure docker builds to keep docker compose files clean
ll-nick Nov 7, 2024
97b75e4
Remove build instruction from docker compose files
ll-nick Nov 11, 2024
0e6327b
Add workflow to create a new version and release on merge to main
ll-nick Nov 11, 2024
cb002dc
Update installation section of README
ll-nick Nov 12, 2024
f8b2d51
Copy additional files required by unit test pipeline into docker image
ll-nick Nov 12, 2024
89d6066
Add docker stage to build release package
ll-nick Nov 14, 2024
274f4ca
Add some comments to structure the main Dockerfile
ll-nick Nov 14, 2024
dca4f8a
Add Docker stages to test release packages
ll-nick Nov 14, 2024
369d007
Add workflow to run tests against released version
ll-nick Nov 14, 2024
3b93de6
Move building of docker images into release workflow
ll-nick Nov 14, 2024
5ffeaf7
Fix docker build stage
ll-nick Nov 14, 2024
3d38df2
Build arbitration graphs base image using current repo state
ll-nick Nov 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions .github/workflows/build-and-push-docker.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
name: Bump version, create and test release, and push Docker images
on:
pull_request:
types:
- closed
branches:
- main

jobs:
compute-version:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
new_tag: ${{ steps.bump_version.outputs.new_tag }}
steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Read version from file
run: |
# Read the version from the version file, only store the number (without the 'v')
INITIAL_VERSION=$(source version && echo ${VERSION#v})
echo "Current version: $INITIAL_VERSION"
echo "INITIAL_VERSION=${INITIAL_VERSION}" >> $GITHUB_ENV

- name: Bump version
id: bump_version
uses: anothrNick/github-tag-action@v1
env:
DEFAULT_BUMP: minor
DRY_RUN: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INITIAL_VERSION: ${{ env.INITIAL_VERSION }}
WITH_V: true


update-version-file:
needs: compute-version
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.DEPLOY_KEY }}

- name: Update version file with new version
run: |
echo "New version: ${{ needs.compute-version.outputs.new_tag }}"
echo "VERSION=${{ needs.compute-version.outputs.new_tag }}" > version
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git add version
git commit -m "chore: update version file to ${{ needs.compute-version.outputs.new_tag }}"
git push

- name: Push new tag
run: |
git tag ${{ needs.compute-version.outputs.new_tag }}
git push origin ${{ needs.compute-version.outputs.new_tag }}


create-release:
needs: [compute-version, update-version-file]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out the repository and pull the new tag
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.compute-version.outputs.new_tag }}

- name: Build release packages
uses: docker/build-push-action@v6
with:
context: .
push: false
tags: |
release_builder
target: release

- name: Copy release packages
run: |
mkdir -p /tmp/artifacts/
docker run --rm -v /tmp/artifacts:/tmp/artifacts release_builder cp -r /release /tmp/artifacts/

- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "/tmp/artifacts/release/*"
tag: ${{ needs.compute-version.outputs.new_tag }}
body: ${{ github.event.pull_request.body }}

build-and-run-release-tests:
needs: [compute-version, create-release]
runs-on: ubuntu-latest
steps:
- name: Build release core test Docker image
uses: docker/build-push-action@v6
with:
build-args: |
RELEASE_DOWNLOAD_URL=https://github.com/KIT-MRT/arbitration_graphs/releases/download/${{ needs.compute-version.outputs.new_tag }}
push: false
tags: release_tester_core
target: release_test_core

- name: Run core unit tests with/against released version
run: |
docker run --rm release_tester_core

- name: Build release gui test Docker image
uses: docker/build-push-action@v6
with:
build-args: |
RELEASE_DOWNLOAD_URL=https://github.com/KIT-MRT/arbitration_graphs/releases/download/${{ needs.compute-version.outputs.new_tag }}
push: false
tags: release_tester_gui
target: release_test_gui

- name: Run gui unit tests with/against released version
run: |
docker run --rm release_tester_gui

build-and-push-images:
needs: [compute-version, build-and-run-release-tests]
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: 'linux/amd64,linux/arm64,linux/arm/v7'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

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

- name: Build and push core library Docker image
uses: docker/build-push-action@v6
with:
push: true
tags: |
ghcr.io/kit-mrt/arbitration_graphs:latest
ghcr.io/kit-mrt/arbitration_graphs:${{ needs.compute-version.outputs.new_tag }}
target: install

- name: Build and push Pacman demo Docker image
uses: docker/build-push-action@v6
with:
build-args: |
VERSION=${{ needs.compute-version.outputs.new_tag }}
context: demo
file: demo/Dockerfile
push: true
tags: |
ghcr.io/kit-mrt/arbitration_graphs_pacman_demo:latest
ghcr.io/kit-mrt/arbitration_graphs_pacman_demo:${{ needs.compute-version.outputs.new_tag }}
target: demo

- name: Build and push Pacman tutorial Docker image
uses: docker/build-push-action@v6
with:
build-args: |
VERSION=${{ needs.compute-version.outputs.new_tag }}
context: demo
file: demo/Dockerfile
push: true
tags: |
ghcr.io/kit-mrt/arbitration_graphs_pacman_tutorial:latest
ghcr.io/kit-mrt/arbitration_graphs_pacman_tutorial:${{ needs.compute-version.outputs.new_tag }}
target: tutorial

53 changes: 53 additions & 0 deletions .github/workflows/run-unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Run unit tests

on:
push:

jobs:
build-and-run-unit-tests:
runs-on: ubuntu-latest

steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Read version from file
run: |
cat version >> $GITHUB_ENV

- name: Build and core library Docker image using current repo state
uses: docker/build-push-action@v6
with:
push: false
tags: |
ghcr.io/kit-mrt/arbitration_graphs:${{ env.VERSION }}
target: install

- name: Build core library unit test Docker image
uses: docker/build-push-action@v6
with:
push: false
tags: |
ghcr.io/kit-mrt/arbitration_graphs_tests:${{ env.VERSION }}
target: unit_test

- name: Run library unit tests
run: |
docker run --rm ghcr.io/kit-mrt/arbitration_graphs_tests:${{ env.VERSION }}

- name: Build Pacman demo unit test Docker image
uses: docker/build-push-action@v6
with:
build-args: |
VERSION=${{ env.VERSION }}
context: demo
file: demo/Dockerfile
push: false
tags: |
ghcr.io/kit-mrt/arbitration_graphs_pacman_demo_tests:latest
ghcr.io/kit-mrt/arbitration_graphs_pacman_demo_tests:${{ env.VERSION }}
target: unit_test

- name: Run demo unit tests
run: |
docker run --rm ghcr.io/kit-mrt/arbitration_graphs_pacman_demo_tests:${{ env.VERSION }}
Loading