diff --git a/.github/workflows/build-and-test-macos.yml b/.github/workflows/build-and-test-macos.yml index 1196a3455..e5958e86d 100644 --- a/.github/workflows/build-and-test-macos.yml +++ b/.github/workflows/build-and-test-macos.yml @@ -32,20 +32,6 @@ jobs: gcov: llvm-gcov, python: ['3.8', '3.9', '3.10', '3.11', '3.12'], vtk: '9.3.1' - }, - { - base: "ubuntu-22.04", - compiler: { cc: gcc-11, cxx: g++-11 }, - gcov: gcov, - python: ['3.8', '3.9', '3.10', '3.11', '3.12'], - vtk: '9.3.0' - }, - { - base: "ubuntu-24.04", - compiler: { cc: gcc-13, cxx: g++-13 }, - gcov: gcov, - python: ['3.8', '3.9', '3.10', '3.11', '3.12'], - vtk: '9.3.1' } ] runs-on: ${{ matrix.host.base }} diff --git a/.github/workflows/pushbasedockerimage_ubuntu_24.04-gcc_13-vtk_9.3.1-py_3.8.yml b/.github/workflows/pushbasedockerimage_ubuntu_24.04-gcc_13-vtk_9.3.1-py_3.8.yml new file mode 100644 index 000000000..59c47b5d3 --- /dev/null +++ b/.github/workflows/pushbasedockerimage_ubuntu_24.04-gcc_13-vtk_9.3.1-py_3.8.yml @@ -0,0 +1,68 @@ +name: Build & push base Docker image (add ubuntu_24.04-gcc_12-vtk_9.3.1-py_3.8 image) + +on: + push: + branches: + - 97-add-more-environments-to-test-in-ci + +jobs: + push_to_registry: + name: Build & Push + runs-on: ubuntu-latest + env: + DOCKER_REPOSITORY: lifflander1/vt + strategy: + matrix: + image: [ ubuntu_24.04-gcc_13-vtk_9.3.1-py_3.8 ] + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Extract build configuration + run: | + IFS='_-' read -r -a CONFIG <<< "${{ matrix.image }}" + echo "BASE_IMAGE=${CONFIG[0]}:${CONFIG[1]}" >> $GITHUB_ENV + echo "CC=${CONFIG[2]}-${CONFIG[3]}" >> $GITHUB_ENV + if [[ "${CONFIG[2]}" == "gcc" ]]; then + echo "CXX=g++-${CONFIG[3]}" >> $GITHUB_ENV + echo "GCOV=gcov-${CONFIG[3]}" >> $GITHUB_ENV + elif [[ "${CONFIG[2]}" == "clang" ]]; then + echo "CXX=clang++-${CONFIG[3]}" >> $GITHUB_ENV + echo "GCOV=gcov" >> $GITHUB_ENV + else + exit 1 + fi + echo "VTK_VERSION=${CONFIG[5]}" >> $GITHUB_ENV + echo "PYTHON_VERSION=${CONFIG[7]}" >> $GITHUB_ENV + echo "DOCKER_TAG=${{ matrix.image }}" >> $GITHUB_ENV + + - name: Build configuration + run: | + echo "Base image: $BASE_IMAGE" + echo "C Compiler: $CC" + echo "CXX Compiler: $CXX" + echo "GCOV: $GCOV" + echo "VTK: $VTK_VERSION" + echo "Python: $PYTHON_VERSION" + echo "Docker tag: $DOCKER_TAG" + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Build and push to Docker Hub + uses: docker/build-push-action@v6 + with: + context: . + build-args: | + BASE_IMAGE=${{ env.BASE_IMAGE }} + CC=${{ env.CC }} + CXX=${{ env.CXX }} + GCOV=${{ env.GCOV }} + VTK_VERSION=${{ env.VTK_VERSION }} + PYTHON_VERSION=${{ env.PYTHON_VERSION }} + file: ci/docker/make-base-ubuntu.dockerfile + push: true + tags: "${{ env.DOCKER_REPOSITORY }}:${{ env.DOCKER_TAG }}" diff --git a/ci/docker/make-base-ubuntu.dockerfile b/ci/docker/make-base-ubuntu.dockerfile index 5f26f009b..f988fcaf0 100644 --- a/ci/docker/make-base-ubuntu.dockerfile +++ b/ci/docker/make-base-ubuntu.dockerfile @@ -13,6 +13,12 @@ ARG CC=gcc-11 ARG CXX=g++-11 ARG GCOV=gcov-11 +# Copy scripts +RUN mkdir -p /opt/scripts +COPY ci/setup_mesa.sh /opt/scripts/setup_mesa.sh +COPY ci/vtk_build.sh /opt/scripts/vtk_build.sh +COPY ci/xvfb_run.sh /opt/scripts/xvfb_run.sh + ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update -y -q && \ apt-get install -y -q --no-install-recommends \ @@ -39,17 +45,15 @@ RUN apt-get update -y -q && \ pkg-config \ libncurses5-dev \ m4 \ - libgl1-mesa-dev \ - libglu1-mesa-dev \ - mesa-common-dev \ - libosmesa6-dev \ perl \ curl \ xvfb \ - lcov \ - && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* + lcov + +RUN bash /opt/scripts/setup_mesa.sh +RUN bash /opt/scripts/xvfb_run.sh "echo $(glxinfo | grep 'OpenGL version')" + +RUN apt-get clean && rm -rf /var/lib/apt/lists/* # Share environment variables for use in images based on this. ENV CC=/usr/bin/$CC @@ -83,8 +87,6 @@ RUN mkdir -p /opt/src/vtk RUN git clone --recursive --branch v${VTK_VERSION} https://gitlab.kitware.com/vtk/vtk.git /opt/src/vtk # Build VTK -RUN mkdir -p /opt/scripts -COPY ci/vtk_build.sh /opt/scripts/vtk_build.sh RUN VTK_DIR=${VTK_DIR} bash /opt/scripts/vtk_build.sh RUN echo "Base creation success" diff --git a/ci/setup_mesa.sh b/ci/setup_mesa.sh new file mode 100644 index 000000000..88e8012da --- /dev/null +++ b/ci/setup_mesa.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# This script installs Mesa libraries and utilities + +. /etc/lsb-release + +# Ubuntu 24.04 FIX. +# Error: MESA: error: ZINK: vkCreateInstance failed (VK_ERROR_INCOMPATIBLE_DRIVER) +if [ "$DISTRIB_RELEASE" == "24.04" ]; then + echo "FIX: Using latest MESA drivers (dev) for Ubuntu 24.04 to fix MESA errors !" + add-apt-repository ppa:oibaf/graphics-drivers -y + apt update +fi + +apt install -y -q --no-install-recommends \ + libgl1-mesa-dev \ + libglu1-mesa-dev \ + mesa-common-dev \ + libosmesa6-dev \ + mesa-utils diff --git a/ci/xvbf_openglversion.sh b/ci/xvbf_openglversion.sh new file mode 100644 index 000000000..ed8e1b0ad --- /dev/null +++ b/ci/xvbf_openglversion.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# This script run glxinfo | grep OpenGL version" in Xbfb + +DISPLAY_0=$(echo $DISPLAY) +bash ci/xvfb_start.sh :99 +export DISPLAY=:99 + +glxinfo | grep "OpenGL version" +sudo add-apt-repository ppa:oibaf/graphics-drivers -y +sudo apt update +sudo apt upgrade +glxinfo | grep "OpenGL version" + +# Restore display (none) +bash ci/xvfb_stop.sh :99 +export DISPLAY=DISPLAY_0 diff --git a/ci/xvfb_run.sh b/ci/xvfb_run.sh new file mode 100755 index 000000000..ded27a735 --- /dev/null +++ b/ci/xvfb_run.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# This script runs a command using Xvfb + +DISPLAY_0=$(echo $DISPLAY) + +XVFB_DISPLAY=":99" + +echo "Starting X Virtual Frame Buffer ($XVFB_DISPLAY)..." +Xvfb $XVFB_DISPLAY -screen 0 1024x768x24 -nolisten tcp > /dev/null 2>&1 & +sleep 1 + +DISPLAY=$XVFB_DISPLAY $1 + +echo "Stopping X Virtual Frame Buffer ($XVFB_DISPLAY)..." +pkill Xvfb +rm -rf /tmp/.X11-unix/X${XVFB_DISPLAY:1} + +export DISPLAY=$DISPLAY_0 +