From fca55ad83bb54f33d5892763d5916aa9584f4df3 Mon Sep 17 00:00:00 2001 From: Ahnaf Tahmid Chowdhury Date: Mon, 11 Dec 2023 13:59:06 +0600 Subject: [PATCH] allow to chose building geant4 and dd from actions --- .github/actions/upstream-test/action.yml | 28 +++++++++-- .github/workflows/docker_publish.yml | 64 +++++++++++++++++------- .github/workflows/linux_build_test.yml | 11 ++-- CI/Dockerfile | 54 +++++++++++--------- 4 files changed, 106 insertions(+), 51 deletions(-) diff --git a/.github/actions/upstream-test/action.yml b/.github/actions/upstream-test/action.yml index 87aa5e1e8..d6b24f043 100644 --- a/.github/actions/upstream-test/action.yml +++ b/.github/actions/upstream-test/action.yml @@ -8,7 +8,7 @@ inputs: geant4_version: description: Version of Geant4 required: false - default: 11.1.2 + default: '' ubuntu_version: description: Underlying OS version required: false @@ -28,7 +28,7 @@ inputs: double_down_version: description: Version of Double Down required: false - default: v1.1.0 + default: '' runs: using: "composite" @@ -40,14 +40,34 @@ runs: username: ${{ github.repository_owner }} password: ${{ inputs.token }} + - name: Configure docker image tag + shell: bash + run: | + image_base_tag=ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ inputs.ubuntu_version }}-${{ inputs.compiler}}-hdf5_${{ inputs.hdf5_version}}-moab_${{ inputs.moab_version }} + if [[ -n "${{ inputs.geant4_version }}" ]]; then + image_base_tag=${image_base_tag}-geant4_${{ inputs.geant4_version }} + GEANT4=ON + else + GEANT4=OFF + fi + if [[ -n "${{ inputs.double_down_version }}" ]]; then + image_base_tag=${image_base_tag}-double_down_${{ inputs.double_down_version }} + DOUBLE_DOWN=ON + else + DOUBLE_DOWN=OFF + fi + echo "image_base_tag=${image_base_tag}" >> $GITHUB_ENV + echo "GEANT4=${GEANT4}" >> $GITHUB_ENV + echo "DOUBLE_DOWN=${DOUBLE_DOWN}" >> $GITHUB_ENV + - name: Installing Dependencies in Docker image uses: firehed/multistage-docker-build-action@v1 with: - repository: ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ inputs.ubuntu_version }}-${{ inputs.compiler}}-geant4_${{ inputs.geant_version }}-hdf5_${{ inputs.hdf5_version }}-moab_${{ inputs.moab_version }} + repository: ${{ env.image_base_tag }} stages: base, external_deps, hdf5, moab, dagmc server-stage: dagmc_test quiet: false parallel: true tag-latest-on-default: false dockerfile: CI/Dockerfile - build-args: COMPILER=${{ inputs.compiler }}, Geant4_VERSION=${{ inputs.geant4_version }}, UBUNTU_VERSION=${{ inputs.ubuntu_version }}, HDF5_VERSION=${{ inputs.hdf5_version }}, MOAB_VERSION=${{ inputs.moab_version }}, DOUBLE_DOWN_VERSION=${{ inputs.double_down_version }} + build-args: UBUNTU_VERSION=${{ inputs.ubuntu_version }}, COMPILER=${{ inputs.compiler }}, HDF5_VERSION=${{ inputs.hdf5_version }}, MOAB_VERSION=${{ inputs.moab_version }}, GEANT4=${{ env.GEANT4 }}, GEANT4_VERSION=${{ inputs.geant4_version }}, DOUBLE_DOWN=${{ env.DOUBLE_DOWN }}, DOUBLE_DOWN_VERSION=${{ inputs.double_down_version }} diff --git a/.github/workflows/docker_publish.yml b/.github/workflows/docker_publish.yml index 8f8db3455..b1d53c9b4 100644 --- a/.github/workflows/docker_publish.yml +++ b/.github/workflows/docker_publish.yml @@ -17,24 +17,24 @@ jobs: ubuntu_version : [ 20.04, 22.04, - ] + ] compiler : [ gcc, clang, - ] + ] hdf5_version : [ 1.10.4, ] moab_version : [ 5.3.0, ] - double_down_version : [ - v1.1.0, - ] geant4_version : [ 10.7.4, 11.1.2 ] + double_down_version : [ + + ] name: Installing Dependencies, Building DAGMC and running tests steps: @@ -57,17 +57,36 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + - name: Configure docker image tag and build arguments + run: | + image_base_tag=ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ matrix.ubuntu_version }}-${{ matrix.compiler}}-hdf5_${{ matrix.hdf5_version}}-moab_${{ matrix.moab_version }} + if [[ -n "${{ matrix.geant4_version }}" ]]; then + image_base_tag=${image_base_tag}-geant4_${{ matrix.geant4_version }} + GEANT4=ON + else + GEANT4=OFF + fi + if [[ -n "${{ matrix.double_down_version }}" ]]; then + image_base_tag=${image_base_tag}-double_down_${{ matrix.double_down_version }} + DOUBLE_DOWN=ON + else + DOUBLE_DOWN=OFF + fi + echo "image_base_tag=${image_base_tag}" >> "$GITHUB_ENV" + echo "GEANT4=${GEANT4}" >> "$GITHUB_ENV" + echo "DOUBLE_DOWN=${DOUBLE_DOWN}" >> "$GITHUB_ENV" + - name: Installing Dependencies in Docker image uses: firehed/multistage-docker-build-action@v1 with: - repository: ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ matrix.ubuntu_version }}-${{ matrix.compiler}}-geant4_${{ matrix.geant4_version }}-hdf5_${{ matrix.hdf5_version}}-moab_${{ matrix.moab_version }} + repository: $image_base_tag stages: base, external_deps, hdf5, moab, dagmc server-stage: dagmc_test quiet: false parallel: true - tag-latest-on-default: ${{ env.tag-latest-on-default }} + tag-latest-on-default: $tag-latest-on-default dockerfile: CI/Dockerfile - build-args: DOUBLE_DOWN_VERSION=${{ matrix.double_down_version}}, Geant4_VERSION=${{ matrix.geant4_version }}, COMPILER=${{ matrix.compiler }}, UBUNTU_VERSION=${{ matrix.ubuntu_version }}, HDF5_VERSION=${{ matrix.hdf5_version }}, MOAB_VERSION=${{ matrix.moab_version }} + build-args: UBUNTU_VERSION=${{ matrix.ubuntu_version }}, COMPILER=${{ matrix.compiler }}, HDF5_VERSION=${{ matrix.hdf5_version }}, MOAB_VERSION=${{ matrix.moab_version }}, GEANT4=$GEANT4, GEANT4_VERSION=${{ matrix.geant4_version }}, DOUBLE_DOWN=$DOUBLE_DOWN, DOUBLE_DOWN_VERSION=${{ matrix.double_down_version}} push_stable_ci_img: @@ -79,24 +98,24 @@ jobs: ubuntu_version : [ 20.04, 22.04, - ] + ] compiler : [ gcc, clang, - ] + ] hdf5_version : [ 1.10.4, ] moab_version : [ 5.3.0, ] - double_down_version : [ - v1.1.0, - ] geant4_version : [ 10.7.4, 11.1.2 ] + double_down_version : [ + + ] name: Pushing final images steps: @@ -108,21 +127,28 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Store image name + - name: Configure docker image tag if: ${{ github.repository_owner == 'svalinn' }} run: | - echo "image_base_tag=ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ matrix.ubuntu_version }}-${{ matrix.compiler }}-geant4_${{ matrix.geant4_version }}-hdf5_${{ matrix.hdf5_version }}-moab_${{ matrix.moab_version }}" >> "$GITHUB_ENV" + image_base_tag=ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ matrix.ubuntu_version }}-${{ matrix.compiler}}-hdf5_${{ matrix.hdf5_version}}-moab_${{ matrix.moab_version }} + if [[ -n "${{ matrix.geant4_version }}" ]]; then + image_base_tag=${image_base_tag}-geant4_${{ matrix.geant4_version }} + fi + if [[ -n "${{ matrix.double_down_version }}" ]]; then + image_base_tag=${image_base_tag}-double_down_${{ matrix.double_down_version }} + fi + echo "image_base_tag=${image_base_tag}" >> "$GITHUB_ENV" - name: Push Image as latest img if: ${{ github.repository_owner == 'svalinn' && github.ref == 'refs/heads/develop' }} uses: akhilerm/tag-push-action@v2.1.0 with: - src: ${{ env.image_base_tag }}/dagmc:latest - dst: ${{ env.image_base_tag }}:latest + src: $image_base_tag/dagmc:latest + dst: $image_base_tag:latest - name: Push Image as latest img if: ${{ github.repository_owner == 'svalinn' && github.ref == 'refs/heads/develop' }} uses: akhilerm/tag-push-action@v2.1.0 with: - src: ${{ env.image_base_tag }}:latest - dst: ${{ env.image_base_tag }}:stable + src: $image_base_tag:latest + dst: $image_base_tag:stable diff --git a/.github/workflows/linux_build_test.yml b/.github/workflows/linux_build_test.yml index 84c71875c..f66d72249 100644 --- a/.github/workflows/linux_build_test.yml +++ b/.github/workflows/linux_build_test.yml @@ -39,7 +39,7 @@ jobs: ubuntu_version : [ 20.04, 22.04, - ] + ] compiler : [ gcc, clang, @@ -53,9 +53,12 @@ jobs: geant_version : [ 10.7.4, ] + double_down_version : [ + + ] container: - image: ghcr.io/svalinn/dagmc-ci-ubuntu-${{ matrix.ubuntu_version }}-${{ matrix.compiler}}-geant4_${{ matrix.geant_version }}-hdf5_${{ matrix.hdf5_version}}-moab_${{ matrix.moab_version }}/moab:latest + image: ghcr.io/svalinn/dagmc-ci-ubuntu-${{ matrix.ubuntu_version }}-${{ matrix.compiler}}-hdf5_${{ matrix.hdf5_version}}-moab_${{ matrix.moab_version }}${{ matrix.geant_version != '' && '-geant4_' || '' }}${{ matrix.geant_version }}${{ matrix.double_down_version != '' && '-double_down_' || '' }}${{ matrix.double_down_version }}/moab:latest steps: - name: Checkout repository @@ -70,7 +73,7 @@ jobs: cd ./build git config --global --add safe.directory $GITHUB_WORKSPACE cmake ../ -DMOAB_DIR=${moab_install_dir} \ - -DBUILD_GEANT4=ON \ + -DBUILD_GEANT4=${{ matrix.geant_version != '' && 'ON' || 'OFF' }} \ -DGEANT4_DIR=${geant4_install_dir} \ -DBUILD_CI_TESTS=ON \ -DBUILD_MW_REG_TESTS=OFF \ @@ -80,7 +83,7 @@ jobs: -DCMAKE_CXX_COMPILER=${CXX} \ -DCMAKE_Fortran_COMPILER=gfortran \ -DCMAKE_INSTALL_PREFIX=${install_dir}/dagmc \ - -DDOUBLE_DOWN=ON \ + -DDOUBLE_DOWN=${{ matrix.double_down_version != '' && 'ON' || 'OFF' }} \ -DCMAKE_CXX_FLAGS="-Werror=reorder" \ -Ddd_ROOT=${double_down_install_dir} && \ make -j2 && \ diff --git a/CI/Dockerfile b/CI/Dockerfile index 467aa74ad..cc21eae2f 100644 --- a/CI/Dockerfile +++ b/CI/Dockerfile @@ -7,8 +7,10 @@ ARG UBUNTU_VERSION=22.04 ARG HDF5_VERSION=1.10.4 ARG EMBREE_VERSION=v4.0.1 -ARG Geant4_VERSION=11.1.2 +ARG GEANT4=ON +ARG GEANT4_VERSION=11.1.2 ARG MOAB_VERSION=5.3.0 +ARG DOUBLE_DOWN=ON ARG DOUBLE_DOWN_VERSION=v1.1.0 ARG CI_JOBS=4 @@ -29,25 +31,27 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # Install Build Dependencies RUN apt-get update --yes && \ apt-get install --yes \ - git \ - wget \ - autoconf \ - clang \ - cmake \ - g++ \ - gcc \ - gfortran \ - libhdf5-dev \ - libtool \ - libeigen3-dev\ - python3-numpy \ - python3 \ - python3-pip \ - python3-setuptools \ - python3-dev \ - libpython3-dev \ - software-properties-common && \ + git \ + wget \ + autoconf \ + clang \ + cmake \ + g++ \ + gcc \ + gfortran \ + libhdf5-dev \ + libtool \ + libeigen3-dev\ + python3-numpy \ + python3 \ + python3-pip \ + python3-setuptools \ + python3-dev \ + libpython3-dev \ + software-properties-common && \ apt-get clean && rm -rf /var/lib/apt/lists/* && \ + update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && \ + update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 10 && \ pip3 install "cython<3"; ARG build_dir @@ -69,7 +73,7 @@ ENV CXX=clang++ FROM compiler-${COMPILER} as external_deps # accessing gloabl ARGs in build stage -ARG Geant4_VERSION +ARG GEANT4_VERSION ARG EMBREE_VERSION ARG install_dir ARG build_dir @@ -77,14 +81,14 @@ ARG CI_JOBS ARG CXX ARG CC -ENV geant4_basename=geant4-v${Geant4_VERSION} +ENV geant4_basename=geant4-v${GEANT4_VERSION} ENV geant4_tarball=${geant4_basename}.tar.gz ENV geant4_build_dir=${build_dir}/geant4 ENV geant4_install_dir=${install_dir}/geant4 RUN mkdir -p ${geant4_build_dir}/build && \ cd ${geant4_build_dir} && \ - wget https://gitlab.cern.ch/geant4/geant4/-/archive/v${Geant4_VERSION}/${geant4_tarball} --no-check-certificate && \ + wget https://gitlab.cern.ch/geant4/geant4/-/archive/v${GEANT4_VERSION}/${geant4_tarball} --no-check-certificate && \ tar -xzf ${geant4_tarball} && \ cd build && \ cmake ../${geant4_basename} \ @@ -210,6 +214,8 @@ ARG install_dir ARG build_dir ARG CXX ARG CC +ARG GEANT4 +ARG DOUBLE_DOWN ENV dagmc_build_dir=${build_dir}/dagmc ENV dagmc_install_dir=${install_dir}/dagmc @@ -224,7 +230,7 @@ RUN mkdir -p ${dagmc_build_dir}/build && \ cd build && \ cmake ../ \ -DMOAB_DIR=${moab_install_dir} \ - -DBUILD_GEANT4=ON \ + -DBUILD_GEANT4=${GEANT4} \ -DGEANT4_DIR=${geant4_install_dir} \ -DBUILD_CI_TESTS=ON \ # reg tests disabled see issue https://github.com/svalinn/DAGMC/issues/858 @@ -235,7 +241,7 @@ RUN mkdir -p ${dagmc_build_dir}/build && \ -DCMAKE_CXX_COMPILER=${CXX} \ -DCMAKE_Fortran_COMPILER=gfortran \ -DCMAKE_INSTALL_PREFIX=${dagmc_install_dir} \ - -DDOUBLE_DOWN=ON \ + -DDOUBLE_DOWN=${DOUBLE_DOWN} \ -Ddd_ROOT=${double_down_install_dir} && \ make -j${CI_JOBS} && \ make install