Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
693a2df9fThis file is pinned to the selected release. Download the original to open it in your design tool.
name: Unit Tests
on:
workflow_run:
workflows: ["Build Docker"]
types:
- completed
branches:
- main
- 'feature/*'
jobs:
unit-tests:
name: Unit Tests (${{ matrix.name }})
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
strategy:
fail-fast: false
matrix:
include:
- name: Business Logic
make_target: test_biz
- name: Device
make_target: test_dev
- name: Driver
make_target: test_drv
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ${{ github.event.workflow_run.head_repository.full_name }}
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 0
- name: Set up Docker Compose
uses: docker/setup-compose-action@v1
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull Docker Image
run: |
docker pull ghcr.io/robertgawron/hardwaredatalogger:${{ github.event.workflow_run.head_sha }}
docker tag ghcr.io/robertgawron/hardwaredatalogger:${{ github.event.workflow_run.head_sha }} hardwaredatalogger:latest
- name: Run Docker Compose
env:
DOCKER_IMAGE: ghcr.io/robertgawron/hardwaredatalogger:${{ github.event.workflow_run.head_sha }}
run: |
docker compose -f docker-compose.yml up -d
- name: Run Unit Tests
run: |
# 1. cd to workspace
# 2. ensure build dir exists
# 3. run cmake (once per container)
# 4. run the specific make target from the matrix
docker compose -f docker-compose.yml exec -T dev bash -c "cd /workspace && mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug .. && make ${{ matrix.make_target }}"
- name: Clean up Docker containers
if: always()
run: |
docker compose -f docker-compose.yml down