Add GitHub Action to build and test FANS #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test | |
# Builds FANS inside various docker containers and runs the tests. | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
pull_request: | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: ${{github.event_name == 'pull_request'}} | |
jobs: | |
build: | |
name: ${{ format('Ubuntu {0}, {1}', matrix.UBUNTU_VERSION, matrix.ARCH) }} | |
runs-on: ubuntu-latest | |
env: | |
FANS_DIR: /FANS | |
FANS_IMG: unistuttgartdae/fans-ci | |
FANS_CONTAINER: fans-ci | |
FANS_BUILD_DIR: build | |
strategy: | |
fail-fast: false | |
matrix: | |
ARCH: [amd64, arm64] | |
UBUNTU_VERSION: [noble, jammy, focal] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Create and start container | |
run: | | |
docker create \ | |
--name ${{ env.FANS_CONTAINER }} \ | |
--platform linux/${{ matrix.ARCH }} \ | |
-i -t \ | |
-u `id -u`:`id -g` \ | |
-v /etc/localtime:/etc/localtime:ro \ | |
-v /etc/timezone:/etc/timezone:ro \ | |
-v ${{ github.workspace }}:${{ env.FANS_DIR }} \ | |
-w ${{ env.FANS_DIR }} \ | |
${{ env.FANS_IMG }}:${{ matrix.UBUNTU_VERSION }} | |
docker start ${{ env.FANS_CONTAINER }} | |
- name: Generate build directory | |
run: | | |
docker exec \ | |
-w ${{ env.FANS_DIR }} \ | |
${{ env.FANS_CONTAINER }} \ | |
bash -c "mkdir -p ${{ env.FANS_BUILD_DIR }}" | |
- name: Configure | |
run: | | |
docker exec \ | |
-w ${{ env.FANS_DIR }}/${{ env.FANS_BUILD_DIR }} \ | |
${{ env.FANS_CONTAINER }} \ | |
bash -c " \ | |
cmake --version && \ | |
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .." | |
- uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: ${{ format('Ubuntu {0}, {1}', matrix.UBUNTU_VERSION, matrix.ARCH) }} CMakeCache | |
path: build/CMakeCache.txt | |
- uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: ${{ format('Ubuntu {0}, {1}', matrix.UBUNTU_VERSION, matrix.ARCH) }} CMakeLogs | |
path: 'build/CMakeFiles/*.log' | |
- uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: ${{ format('Ubuntu {0}, {1}', matrix.UBUNTU_VERSION, matrix.ARCH) }} CompileCommands | |
path: build/compile_commands.json | |
- name: Compile | |
run: | | |
docker exec \ | |
-w ${{ env.FANS_DIR }}/${{ env.FANS_BUILD_DIR }} \ | |
${{ env.FANS_CONTAINER }} \ | |
cmake --build . -j $(nproc) || cmake --build . -j1 | |
- name: Tests | |
run: | | |
docker exec \ | |
-w ${{ env.FANS_DIR }}/${{ env.FANS_BUILD_DIR }} \ | |
-e CTEST_OUTPUT_ON_FAILURE=1 \ | |
${{ env.FANS_CONTAINER }} \ | |
ctest | |
- uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: ${{ format('Ubuntu {0}, {1}', matrix.UBUNTU_VERSION, matrix.ARCH) }} CTest logs | |
path: build/Testing/Temporary/LastTest.log | |