Skip to content

Add CTest test cases from existing tests (run_tests.sh) #7

Add CTest test cases from existing tests (run_tests.sh)

Add CTest test cases from existing tests (run_tests.sh) #7

Workflow file for this run

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
FANS_MPI_UID: 1000
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 }} \
--interactive \
--volume .:${{ 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: ${{ env.FANS_BUILD_DIR }}/CMakeCache.txt
- uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ format('Ubuntu {0}, {1}', matrix.UBUNTU_VERSION, matrix.ARCH) }} CMakeLogs
path: '${{ env.FANS_BUILD_DIR }}/CMakeFiles/*.log'
- uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ format('Ubuntu {0}, {1}', matrix.UBUNTU_VERSION, matrix.ARCH) }} CompileCommands
path: ${{ env.FANS_BUILD_DIR }}/compile_commands.json
- name: Compile
run: |
docker exec \
-w ${{ env.FANS_DIR }}/${{ env.FANS_BUILD_DIR }} \
${{ env.FANS_CONTAINER }} \
bash -c ' \
cmake --build . -j $(nproc) || cmake --build . -j1 \
'
- name: Adjust user rights
run: |
docker exec \
-w ${{ env.FANS_DIR }} \
${{ env.FANS_CONTAINER }} \
bash -c ' \
chown -R ${{ env.FANS_MPI_UID }} ${{ env.FANS_BUILD_DIR }}
'
- name: Tests
run: |
docker exec \
-w ${{ env.FANS_DIR }}/${{ env.FANS_BUILD_DIR }} \
-u ${{ env.FANS_MPI_UID }} \
-e CTEST_OUTPUT_ON_FAILURE=1 \
${{ env.FANS_CONTAINER }} \
bash -c ' \
ctest
'
- uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ format('Ubuntu {0}, {1}', matrix.UBUNTU_VERSION, matrix.ARCH) }} CTest logs
path: ${{ env.FANS_BUILD_DIR }}/Testing/Temporary/LastTest.log