diff --git a/.github/workflows/docker_publish.yml b/.github/workflows/docker_publish.yml index 18c03c4576..1203060fea 100644 --- a/.github/workflows/docker_publish.yml +++ b/.github/workflows/docker_publish.yml @@ -25,17 +25,17 @@ jobs: uses: actions/checkout@v3 - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v2 - name: Log in to the Container registry - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and Export Dockerfile_0_base - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: file: CI/Dockerfile target: base @@ -57,10 +57,10 @@ jobs: steps: - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v2 - name: Log in to the Container registry - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} @@ -70,7 +70,7 @@ jobs: uses: actions/checkout@v3 - name: Build and push Dockerfile_1_housekeeping - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: file: CI/Dockerfile_1_housekeeping context: . @@ -102,10 +102,10 @@ jobs: name: Ubuntu ${{ matrix.ubuntu_versions }} + ${{ matrix.compiler }} hdf5 ${{ matrix.hdf5_versions }} steps: - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v2 - name: Log in to the Container registry - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.repository_owner }} @@ -115,7 +115,7 @@ jobs: uses: actions/checkout@v3 - name: Build and push Dockerfile_1_external_deps - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: file: CI/Dockerfile target: external_deps @@ -129,7 +129,7 @@ jobs: tags: ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ matrix.ubuntu_versions }}-${{ matrix.compiler}}-ext:ci_testing - name: Build and export Dockerfile_2_hdf5 - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: file: CI/Dockerfile target: hdf5 @@ -163,19 +163,18 @@ jobs: 1.10.4, ] moab_versions : [ - 5.4.0, + 5.3.0, develop, master, ] name: Ubuntu ${{ matrix.ubuntu_versions }} + ${{ matrix.compiler }} hdf5 ${{ matrix.hdf5_versions }} + Moab ${{ matrix.moab_versions }} - steps: - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v2 - name: Log in to the Container registry - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.repository_owner }} @@ -185,7 +184,7 @@ jobs: uses: actions/checkout@v3 - name: Build and push Dockerfile_3_moab - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: file: CI/Dockerfile target: moab @@ -231,8 +230,8 @@ jobs: run: | cd $GITHUB_WORKSPACE /bin/bash "CI/scripts/housekeeping.sh" - - test_img: + + build-test-dagmc-img: needs: [build-moab-img] runs-on: ubuntu-latest env: @@ -257,43 +256,63 @@ jobs: develop, master, ] - container: ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ matrix.ubuntu_versions }}-${{ matrix.compiler}}-ext-hdf5_${{ matrix.hdf5_versions}}-moab_${{ matrix.moab_versions }}:ci_testing + static_exe : [ + OFF, + ON, + ] - name: Installing and Testing DAGMC - steps: - - name: Checkout repository - uses: actions/checkout@v3 + name: Installing DAGMC + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Log in to the Container registry + uses: docker/login-action@v2 with: - submodules: recursive + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Setup - run: | - git config --global --add safe.directory ${GITHUB_WORKSPACE} - git config --global --add safe.directory /github/home/ - git config --global --add safe.directory /github/home/.cache - git config --global --add safe.directory /github/home/.cache/pip - git config --global --add safe.directory /github/home/.cache/pip/http - echo "MOAB_VERSION=${{ matrix.moab_versions }}" >> $GITHUB_ENV - echo "COMPILER=${{ matrix.compiler }}" >> $GITHUB_ENV - echo "HDF5_VERSION=${{ matrix.hdf5_versions }}" >> $GITHUB_ENV - echo "REPO_SLUG=${GITHUB_REPOSITORY}" >> $GITHUB_ENV - echo "PULL_REQUEST=$(echo $GITHUB_REF | cut -d"/" -f3)" >> $GITHUB_ENV - echo "DOUBLE_DOWN="OFF"" >> $GITHUB_ENV - ln -s $GITHUB_WORKSPACE /root/build_dir/DAGMC + - name: Checkout repository + uses: actions/checkout@v3 - - name: Install DAGMC - run: | - cd $GITHUB_WORKSPACE - /bin/bash "CI/scripts/install.sh" + - name: Install DAGMC in Docker image + uses: docker/build-push-action@v3 + with: + file: CI/Dockerfile + target: dagmc + context: . + push: false + build-args: | + OWNER=${{ github.repository_owner }} + TAG=ci_testing + UBUNTU_VERSION=${{ matrix.ubuntu_versions }} + COMPILER=${{ matrix.compiler }} + HDF5=${{ matrix.hdf5_versions }} + MOAB=${{ matrix.moab_versions }} + build_mw_reg_tests=ON + tags: ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ matrix.ubuntu_versions }}-${{ matrix.compiler}}-ext-hdf5_${{ matrix.hdf5_versions}}-moab_${{ matrix.moab_versions }}-dagmc:ci_testing - - name: Run DAGMC Test - run: | - cd $GITHUB_WORKSPACE - /bin/bash "CI/scripts/tests.sh" + - name: Test DAGMC in Docker image + uses: docker/build-push-action@v3 + with: + file: CI/Dockerfile + target: dagmc_test + context: . + push: false + build-args: | + OWNER=${{ github.repository_owner }} + TAG=ci_testing + UBUNTU_VERSION=${{ matrix.ubuntu_versions }} + COMPILER=${{ matrix.compiler }} + HDF5=${{ matrix.hdf5_versions }} + MOAB=${{ matrix.moab_versions }} + build_mw_reg_tests=ON + tags: ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ matrix.ubuntu_versions }}-${{ matrix.compiler}}-ext-hdf5_${{ matrix.hdf5_versions}}-moab_${{ matrix.moab_versions }}-dagmc-test:ci_testing pushing_housekeeping_stable_img: if: ${{ github.repository_owner == 'svalinn' }} - needs: [test_img] + needs: [build-test-dagmc-img] runs-on: ubuntu-latest env: hdf5_versions: 1.10.4 @@ -305,30 +324,30 @@ jobs: name: Housekeeping':' latest -> stable steps: - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v2 - name: Log in to the Container registry - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Push Image as stable img - uses: akhilerm/tag-push-action@v1.0.0 + uses: akhilerm/tag-push-action@v2.1.0 with: src: ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ matrix.ubuntu_versions }}-housekeeping:ci_testing dst: ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ matrix.ubuntu_versions }}-housekeeping:stable - name: Push Image as latest img - uses: akhilerm/tag-push-action@v1.0.0 + uses: akhilerm/tag-push-action@v2.1.0 with: src: ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ matrix.ubuntu_versions }}-housekeeping:ci_testing dst: ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ matrix.ubuntu_versions }}-housekeeping:latest pushing_test_stable_img: if: ${{ github.repository_owner == 'svalinn' }} - needs: [test_img] + needs: [build-test-dagmc-img] runs-on: ubuntu-latest env: hdf5_versions: 1.10.4 @@ -357,23 +376,23 @@ jobs: steps: - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v2 - name: Log in to the Container registry - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Push Image as stable img - uses: akhilerm/tag-push-action@v1.0.0 + uses: akhilerm/tag-push-action@v2.1.0 with: src: ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ matrix.ubuntu_versions }}-${{ matrix.compiler}}-ext-hdf5_${{ matrix.hdf5_versions}}-moab_${{ matrix.moab_versions }}:ci_testing dst: ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ matrix.ubuntu_versions }}-${{ matrix.compiler}}-ext-hdf5_${{ matrix.hdf5_versions}}-moab_${{ matrix.moab_versions }}:stable - name: Push Image as latest img - uses: akhilerm/tag-push-action@v1.0.0 + uses: akhilerm/tag-push-action@v2.1.0 with: src: ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ matrix.ubuntu_versions }}-${{ matrix.compiler}}-ext-hdf5_${{ matrix.hdf5_versions}}-moab_${{ matrix.moab_versions }}:ci_testing - dst: ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ matrix.ubuntu_versions }}-${{ matrix.compiler}}-ext-hdf5_${{ matrix.hdf5_versions}}-moab_${{ matrix.moab_versions }}:latest \ No newline at end of file + dst: ghcr.io/${{ github.repository_owner }}/dagmc-ci-ubuntu-${{ matrix.ubuntu_versions }}-${{ matrix.compiler}}-ext-hdf5_${{ matrix.hdf5_versions}}-moab_${{ matrix.moab_versions }}:latest diff --git a/CI/Dockerfile b/CI/Dockerfile index 3a1753b7ec..6e67c12d95 100644 --- a/CI/Dockerfile +++ b/CI/Dockerfile @@ -1,9 +1,37 @@ +# Svalinn DAGMC Dockerfile + + + +# Global ARGS set before the first build stage are accessable by all build stages +ARG build_mw_reg_tests=OFF +ARG EMBREE_BRANCH='v3.6.1' +ARG geant4_version=10.5.1 ARG UBUNTU_VERSION=18.04 +ARG MOAB_BRANCH=5.3.0 +ARG double_down=OFF +ARG static_exe=OFF +ARG ci_jobs=20 + +ARG HDF5_VERSION=1.10.4 +# currently HDF5 major version must be manually set to match HDF5 version +ARG HDF5_VERSION_major=1.10 + +ARG build_dir=/root/build_dir +ARG install_dir=/root/opt + +# clang and gcc are options for the compiler but to use them CC and CXX must be set +# if clang then change cc to clang and cxx to clang++ +# if gcc then change cc to gcc and cxx to g++ +ARG CC=gcc +ARG CXX=g++ + + FROM ubuntu:${UBUNTU_VERSION} AS base # Use bash as the default shell SHELL ["/bin/bash", "-c"] -# Ubuntu Setup + +# timezone setup ENV TZ=America/Chicago RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone @@ -33,64 +61,209 @@ RUN apt-get -y update; \ update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 10; \ pip install cython; +ARG build_dir +ARG install_dir -# Copy scripts to docker image -RUN mkdir -p /root/etc/ -COPY CI/ /root/etc/CI -#TODO move sh file contents into this Dockerfile -ENV docker_env=/root/etc/CI/env.sh - -ENV build_dir=/root/build_dir -ENV install_dir=/root/opt +ENV build_dir=${build_dir} +ENV install_dir=${install_dir} FROM base as external_deps -#setting the COMPILER variable -ARG COMPILER=gcc -ENV COMPILER=${COMPILER} +# accessing gloabl ARGs in build stage +ARG geant4_version +ARG EMBREE_BRANCH +ARG install_dir +ARG build_dir +ARG ci_jobs +ARG CXX +ARG CC -# Set Geant4 env variable +ENV geant4_basename=geant4-v${geant4_version} +ENV geant4_tarball=${geant4_basename}.tar.gz +ENV geant4_shasum=2397eb859dc4de095ff66059d8bda9f060fdc42e10469dd7890946293eeb0e39 ENV geant4_build_dir=${build_dir}/geant4 ENV geant4_install_dir=${install_dir}/geant4 -# Build Geant4 -#TODO move sh file contents into this Dockerfile -RUN /root/etc/CI/docker/build_geant4.sh +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 && \ + tar -xzf ${geant4_tarball} && \ + cd build && \ + cmake ../${geant4_basename} -DCMAKE_INSTALL_RPATH=${geant4_install_dir}/lib \ + -DCMAKE_INSTALL_PREFIX=${geant4_install_dir} \ + -DGEANT4_USE_SYSTEM_EXPAT=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_CXX_COMPILER=${CXX} \ + -DCMAKE_C_COMPILER=${CC} \ + -DBUILD_STATIC_LIBS=ON && \ + make -j${ci_jobs} && \ + make install && \ + cd && \ + rm -rf ${geant4_build_dir} + -ENV double_down_build_dir=${build_dir}/double-down/ -ENV double_down_install_dir=${install_dir}/double-down/ +ENV embree_install_dir=${install_dir}/embree +ENV embree_build_dir=${build_dir}/embree + +# Clone and install Embree +RUN mkdir -p ${embree_build_dir}/build && \ + cd ${embree_build_dir} && \ + git clone -b ${EMBREE_BRANCH} https://github.com/embree/embree && \ + cd build && \ + cmake ../embree -DCMAKE_INSTALL_PREFIX=${embree_install_dir} \ + -DEMBREE_TASKING_SYSTEM=INTERNAL \ + -DEMBREE_ISPC_SUPPORT=OFF \ + -DEMBREE_TUTORIALS=OFF \ + -DEMBREE_TBB_ROOT=/usr && \ + make -j${ci_jobs} && \ + make -j${ci_jobs} install && \ + cd && \ + rm -rf ${embree_build_dir} -# Build Embree -#TODO move sh file contents into this Dockerfile -RUN /root/etc/CI/docker/build_embree.sh FROM external_deps AS hdf5 -# Set HDF5 env variable +# accessing gloabl ARGs in build stage +ARG HDF5_VERSION_major +ARG HDF5_VERSION +ARG install_dir +ARG build_dir +ARG ci_jobs +ARG CXX +ARG CC + ENV hdf5_build_dir=${build_dir}/hdf5 ENV hdf5_install_dir=${install_dir}/hdf5 -# Build HDF5 -# HDF5 argument possible value: 1.10.4 or system -ARG HDF5=1.10.4 -ENV HDF5_VERSION=${HDF5} -#TODO move sh file contents into this Dockerfile -RUN /root/etc/CI/docker/build_hdf5.sh +RUN mkdir -p ${hdf5_build_dir}/build && \ + cd ${hdf5_build_dir} && \ + wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-${HDF5_VERSION_major}/hdf5-${HDF5_VERSION}/src/hdf5-${HDF5_VERSION}.tar.gz && \ + tar -xzf hdf5-${HDF5_VERSION}.tar.gz && \ + cd build && \ + ../hdf5-${HDF5_VERSION}/configure --enable-shared \ + --prefix=${hdf5_install_dir} \ + CXX=${CXX} \ + CC=${CC} && \ + make -j${ci_jobs} && \ + make install && \ + cd && \ + rm -rf ${hdf5_build_dir} + FROM hdf5 AS moab -ENV PYTHONPATH=/root/build_dir/moab/bld/pymoab/lib/python3.6/site-packages +# accessing gloabl ARGs in build stage +ARG install_dir +ARG MOAB_BRANCH +ARG build_dir +ARG ci_jobs +ARG CXX +ARG CC # Set MOAB env variable ENV moab_build_dir=${build_dir}/moab ENV moab_install_dir=${install_dir}/moab -ARG MOAB=5.3.0 -ENV MOAB_VERSION ${MOAB} -#TODO move sh file contents into this Dockerfile -RUN if [ "${MOAB_VERSION}" != "master" ] && [ "${MOAB_VERSION}" != "develop" ]; then \ - /root/etc/CI/docker/build_moab.sh; \ - fi; +RUN mkdir -p ${moab_build_dir}/build && \ + cd ${moab_build_dir} && \ + git clone -b ${MOAB_BRANCH} --depth 1 https://bitbucket.org/fathomteam/moab && \ + cd build && \ + # static building of moab is also an option and was required for older versions + # cmake ../moab -DENABLE_HDF5=ON -DHDF5_ROOT=${hdf5_install_dir} \ + # -DCMAKE_INSTALL_PREFIX=${moab_install_dir} \ + # -DCMAKE_CXX_COMPILER=${CXX} \ + # -DCMAKE_C_COMPILER=${CC} \ + # -DENABLE_BLASLAPACK=OFF \ + # -DBUILD_SHARED_LIBS=OFF \ + # -DENABLE_FORTRAN=OFF && \ + # make -j${ci_jobs} && \ + # make install && \ + # rm -rf * && \ + cmake ../moab -DCMAKE_INSTALL_RPATH=${hdf5_install_dir}/lib:${moab_install_dir}/lib \ + -DENABLE_HDF5=ON -DHDF5_ROOT=${hdf5_install_dir} \ + -DCMAKE_INSTALL_PREFIX=${moab_install_dir} \ + -DCMAKE_CXX_COMPILER=${CXX} \ + -DCMAKE_C_COMPILER=${CC} \ + -DENABLE_BLASLAPACK=OFF \ + -DBUILD_SHARED_LIBS=ON \ + -DENABLE_FORTRAN=OFF \ + -DENABLE_PYMOAB=ON && \ + mkdir -p ${moab_build_dir}/build/pymoab/lib/python3.6/site-packages && \ + PYTHONPATH=${moab_build_dir}/build/pymoab/lib/python3.6/site-packages:${PYTHONPATH} make -j${ci_jobs} && \ + PYTHONPATH=${moab_build_dir}/build/pymoab/lib/python3.6/site-packages:${PYTHONPATH} make install && \ + cd && \ + rm -rf ${moab_build_dir} + +ENV double_down_build_dir=${build_dir}/double-down +ENV double_down_install_dir=${install_dir}/double-down + +# Clone and install Double-Down +# performed after moab install as double-down requires moab +RUN mkdir -p ${double_down_build_dir}/build && \ + cd ${double_down_build_dir} && \ + git clone --shallow-submodules --single-branch --branch v1.0.0 --depth 1 https://github.com/pshriwise/double-down.git && \ + cd build && \ + cmake ../double-down -DMOAB_DIR=${moab_install_dir} \ + -DCMAKE_INSTALL_PREFIX=${double_down_install_dir} \ + -DEMBREE_DIR=${embree_install_dir} && \ + make -j${ci_jobs} && \ + make -j${ci_jobs} install + + +FROM moab as dagmc + +# accessing gloabl ARGs in build stage +ARG build_mw_reg_tests +ARG install_dir +ARG build_dir +ARG static_exe +ARG CXX +ARG CC + +ENV dagmc_build_dir=${build_dir}/dagmc +ENV dagmc_install_dir=${install_dir}/dagmc + +# copies the enitre git repo into the dockerfile to ensure the submodules can also be found +RUN mkdir -p ${dagmc_build_dir}/build +COPY . ${dagmc_build_dir} +RUN cd ${dagmc_build_dir} && git submodule update --init + +RUN mkdir -p ${dagmc_build_dir}/build && \ + cd ${dagmc_build_dir} && \ + cd build && \ + cmake ../${dagmc} -DMOAB_DIR=${moab_install_dir} \ + -DBUILD_GEANT4=ON \ + -DGEANT4_DIR=${geant4_install_dir} \ + -DBUILD_CI_TESTS=ON \ + # reg tests disabled see issue https://github.com/svalinn/DAGMC/issues/858 + -DBUILD_MW_REG_TESTS=OFF \ + -DBUILD_STATIC_EXE=${static_exe} \ + -DBUILD_STATIC_LIBS=${static_exe} \ + -DCMAKE_C_COMPILER=${CC} \ + -DCMAKE_CXX_COMPILER=${CXX} \ + -DCMAKE_Fortran_COMPILER=gfortran \ + -DCMAKE_INSTALL_PREFIX=${dagmc_install_dir} \ + -DDOUBLE_DOWN=${double_down} \ + -Ddd_ROOT=${double_down_install_dir} && \ + make -j${ci_jobs} && \ + make install + + +FROM dagmc as dagmc_test + +ENV dagmc_build_dir=${build_dir}/dagmc +ENV dagmc_install_dir=${install_dir}/dagmc + +# Test DAGMC executables +RUN cd ${dagmc_build_dir}/build && \ + PATH=${dagmc_install_dir}/bin:$PATH CTEST_OUTPUT_ON_FAILURE=1 make test + +# clean out config test directory for next build +RUN cd ${dagmc_build_dir} && \ + git clean -dxf . -RUN python -c "import pymoab" +# Test DAGMC CMake configuration file +RUN cd ${dagmc_build_dir}/cmake/test_config && \ + cmake . -DDAGMC_ROOT=${dagmc_install_dir} && \ + CTEST_OUTPUT_ON_FAILURE=1 make all test diff --git a/CI/scripts/housekeeping.sh b/CI/scripts/housekeeping.sh index d4ac1d9a9c..552c39f1ae 100755 --- a/CI/scripts/housekeeping.sh +++ b/CI/scripts/housekeeping.sh @@ -2,10 +2,6 @@ set -ex -source ${docker_env} - -cd ${dagmc_build_dir} - # Ensure clang-format is there if ! command -v clang-format &> /dev/null then diff --git a/doc/CHANGELOG.rst b/doc/CHANGELOG.rst index 5e6912f463..7a93541f70 100644 --- a/doc/CHANGELOG.rst +++ b/doc/CHANGELOG.rst @@ -12,6 +12,7 @@ Next version * Using multi stage Dockerfile to reduce the number of Dockerfile (#813) * Adding safe folder to allow CI to compile DAGMC (#814) * Correction to CMake variable name in OpenMC install instructions (#817) + * Move install scripts into Dockerfile (#822) * Updating documentation publishing URL (#823) * Update Pyne submodule (#845) * Update Pyne submodule (#848)