Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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.sh

This file was deleted.

59 changes: 0 additions & 59 deletions .github/workflows/build_and_package.yaml

This file was deleted.

76 changes: 76 additions & 0 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
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}', matrix.UBUNTU_VERSION) }}
runs-on: ubuntu-latest
container: unistuttgartdae/fans-ci:${{ matrix.UBUNTU_VERSION }}
defaults:
run:
shell: "bash --login -eo pipefail {0}"
env:
FANS_BUILD_DIR: build
FANS_MPI_USER: fans
strategy:
fail-fast: false
matrix:
UBUNTU_VERSION: [noble, jammy, focal]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Generate build directory
run: mkdir -p ${{ env.FANS_BUILD_DIR }}

- name: Configure
working-directory: ${{ env.FANS_BUILD_DIR }}
run: |
cmake --version
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..

- uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ format('Ubuntu {0}', matrix.UBUNTU_VERSION) }} CMakeCache
path: ${{ env.FANS_BUILD_DIR }}/CMakeCache.txt
- uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ format('Ubuntu {0}', matrix.UBUNTU_VERSION) }} CMakeLogs
path: '${{ env.FANS_BUILD_DIR }}/CMakeFiles/*.log'
- uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ format('Ubuntu {0}', matrix.UBUNTU_VERSION) }} CompileCommands
path: ${{ env.FANS_BUILD_DIR }}/compile_commands.json

- name: Compile
working-directory: ${{ env.FANS_BUILD_DIR }}
run:
cmake --build . -j $(nproc) || cmake --build . -j1

- name: Adjust user rights
run: chown -R ${{ env.FANS_MPI_USER }} ${{ env.FANS_BUILD_DIR }}

- name: Tests
working-directory: ${{ env.FANS_BUILD_DIR }}
run: su -c "ctest" ${{ env.FANS_MPI_USER }}

- uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ format('Ubuntu {0}', matrix.UBUNTU_VERSION) }} CTest logs
path: ${{ env.FANS_BUILD_DIR }}/Testing/Temporary/LastTest.log
27 changes: 11 additions & 16 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
# to take effect)
ARG DEBIAN_FRONTEND=noninteractive
ARG UBUNTU_VERSION=noble
ARG USER=fans

################################################################################

FROM ubuntu:${UBUNTU_VERSION} AS fans_base
ARG DEBIAN_FRONTEND
ARG USER

# Context: https://askubuntu.com/questions/1513927/ubuntu-24-04-docker-images-now-includes-user-ubuntu-with-uid-gid-1000
RUN bash -c 'if id "ubuntu" &>/dev/null; then \
Expand All @@ -16,6 +18,9 @@ RUN bash -c 'if id "ubuntu" &>/dev/null; then \
echo "Deleted user ubuntu."; \
fi'

# Create a non-root user
RUN useradd -m -s /bin/bash ${USER}

################################################################################

FROM fans_base AS fans_ci
Expand Down Expand Up @@ -44,6 +49,8 @@ RUN apt-get update -qq && apt-get install -y --no-install-recommends \

FROM fans_ci AS fans_dev
ARG DEBIAN_FRONTEND
ARG USER
ARG FANS_venv=FANS_venv

RUN apt-get update -qq && apt-get install -y --no-install-recommends \
# Packages required for setting up the non-root user
Expand All @@ -63,32 +70,20 @@ RUN apt-get update -qq && apt-get install -y --no-install-recommends \
&& apt-get autoremove --purge -y \
&& rm -rf /var/lib/apt/lists/*

# Create a non-root user
ENV USER=develop
ENV UID=1000
ENV GID=100
ENV HOME=/home/${USER}
RUN adduser --disabled-password \
--gecos "Non-root user" \
--uid ${UID} \
--gid ${GID} \
--home ${HOME} \
${USER} \
#
&& echo ${USER} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USER} \
&& chmod 0440 /etc/sudoers.d/${USER}

# Create a python venv for test/h52xdmf.py script
USER ${USER}

ARG FANS_venv=FANS_venv
RUN python -m venv /home/${USER}/venvs/${FANS_venv} && \
echo "\nsource /home/${USER}/venvs/${FANS_venv}/bin/activate\n" >> /home/${USER}/.bashrc && \
. /home/${USER}/venvs/${FANS_venv}/bin/activate && \
python -m pip install --no-cache-dir h5py lxml

USER root

# Add fans user to sudoers
RUN echo ${USER} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USER} \
&& chmod 440 /etc/sudoers.d/${USER}

# Entrypoint script changes UID and GID to match given host UID and GID
COPY --chmod=755 docker/Dockerfile_user_env_entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
Expand Down