diff --git a/.github/workflows/build_docker_VANTAGE_dependencies_image.yml b/.github/workflows/build_docker_VANTAGE_dependencies_image.yml new file mode 100644 index 000000000..727b2f241 --- /dev/null +++ b/.github/workflows/build_docker_VANTAGE_dependencies_image.yml @@ -0,0 +1,81 @@ +name: Build hermes-3+vantagereactions dependencies Docker image + +# Configures this workflow to run every time a change is pushed to the default branch in this repo, +# or when manually triggered. +on: + push: + branches: + - 'VANTAGE-Reactions-Coupling/dev' + workflow_dispatch: # Allows manual triggering + +env: + REGISTRY: ghcr.io + IMAGE_NAME: UKAEA-Edge-Code/hermes-3-vantage-deps + DOCKERFILE: VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile + +permissions: + packages: write + +jobs: + + build-final-image: + + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + submodules: recursive + fetch-depth: 1 + + # Set up BuildKit Docker container builder to be able to build + # multi-platform images and export cache + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + platforms: linux/amd64 + + - name: Log in to registry ${{ env.REGISTRY }} + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + # set "latest" tag + type=raw,value=latest,enable={{is_default_branch}} + # whichever workflow runs last will be tagged as edge + type=raw,value=edge + # short sha tag + type=sha,enable={{is_default_branch}} + # tag with semantic version + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + # tag with branch name + type=ref,event=branch + + # Build and push Docker image with Buildx + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v6 + with: + context: . + file: ${{ env.DOCKERFILE }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64 + cache-from: type=gha + cache-to: type=gha,mode=max + diff --git a/.github/workflows/docker_VANTAGE_tests.yml b/.github/workflows/docker_VANTAGE_tests.yml new file mode 100644 index 000000000..eefea0d49 --- /dev/null +++ b/.github/workflows/docker_VANTAGE_tests.yml @@ -0,0 +1,44 @@ +name: hermes-3 + VANTAGE Tests +on: + pull_request: + branches: + - '**' # This will trigger for PRs against any branch + +defaults: + run: + shell: bash + +jobs: + docker_spack_install_tests: + runs-on: ubuntu-latest + # timeout to avoid running tests which do unexpected spack installation + timeout-minutes: 35 + container: + image: ghcr.io/ukaea-edge-code/hermes-3-vantage-deps:edge + credentials: + username: ${{ github.actor }} + password: ${{ secrets.github_token }} + env: + OMP_NUM_THREADS: 1 + OMPI_MCA_rmaps_base_oversubscribe: yes + permissions: + packages: read + steps: + - name: Check out repository + uses: actions/checkout@v6 + with: + submodules: recursive + - name: Install + run: | + source /opt/spack/share/spack/setup-env.sh && + sed -i 's/^[[:space:]]*granularity:[[:space:]]*microarchitectures/ granularity: generic/' spack.yaml && + sed -i '/^[[:space:]]*providers:/i\ require: "target=x86_64_v3"' spack.yaml && + spack env activate . -v gcc && + spack concretize -f && + spack install -j 4 --only-concrete + - name : Run tests + run: | + source /opt/spack/share/spack/setup-env.sh && + spack env activate . -v gcc && + spack cd -b hermes-3 && + ctest -j 1 --output-on-failure --timeout 300 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fbd24ee0f..14a8e0fc7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,9 +1,6 @@ --- name: Tests on: - push: - branches: - - '**' pull_request: branches: - '**' # This will trigger for PRs against any branch diff --git a/VANTAGE-docker/README.md b/VANTAGE-docker/README.md new file mode 100644 index 000000000..a2459bf78 --- /dev/null +++ b/VANTAGE-docker/README.md @@ -0,0 +1,55 @@ +# Docker image for hermes-3+vantagereactions + +The file `hermes-3-VANTAGE-dependencies.dockerfile` contains the commands to create a docker image which contains the spack dependencies needed to quickly compile hermes-3, BOUT++, NESO-Particles, and VANTAGE-Reactions. + +# Make a local docker image + +Check for existing docker images. +``` +$ docker image ls +``` + +Make a new docker image from Dockerfile. +``` +$ docker build -t hermes_3_vantage_deps_img -f ./path/to/VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile . +``` + +# Make a local container and test hermes-3 within the container + +Check for existing containers +``` +$ docker ps -as +``` + +Make a new container +``` +$ cd /path/to/your/hermes-3/ +$ docker run --name hermes_3_vantage -v "$(pwd):/root/Hermes-3" -it hermes_3_vantage_deps_img +``` + +The `-v` option mounts the `hermes-3/` repo to the container on the path `/root/Hermes-3`. + +Activate spack. +``` +$ . /opt/spack/share/spack/setup-env.sh +``` +Activate the environment. +``` +$ cd ~/Hermes-3 +$ . activate_h3env +``` +Install the top-level packages (if spack needs to install more than the top-level, `VANTAGE-Reactions`, `NESO-Particles`, `BOUT++`, `hermes-3` etc, then there is likely a problem with the image, which should capture all build and link dependencies). +``` +$ spack concretize -f +$ spack install -j 1 +``` +Change to the Hermes build directory and test. +``` +$ spack cd -b hermes-3 +$ ./hermes_unit_tests +$ ctest -j 1 +``` +To later restart the container. +``` +$ docker start -i hermes_3_vantage +``` \ No newline at end of file diff --git a/VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile b/VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile new file mode 100644 index 000000000..8ef889b80 --- /dev/null +++ b/VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile @@ -0,0 +1,53 @@ +# Build stage with Spack pre-installed and ready to be used +FROM spack/ubuntu-noble@sha256:a1c7d1dcfea874f74ec827851f04fc116ca54869c30a766c92c5299967a4f33c +# above FROM equivalent to +# FROM spack/ubuntu-noble:1.1.0 +# the image sha256 hash is obtained from the following url +# https://hub.docker.com/layers/spack/ubuntu-noble/1.1.0/images/sha256-a1c7d1dcfea874f74ec827851f04fc116ca54869c30a766c92c5299967a4f33c +# we use the sha256 hash to pin to a specific version +# in case the image associated with tag :1.1.0 is updated + +RUN apt update && \ + apt install -y git --no-install-recommends \ + && rm -rf /var/lib/apt/lists/* +# use develop version of spack repos +RUN sed -i '/^[[:space:]]*branch:/ s|releases/v2025\.11|develop|g' /opt/spack/etc/spack/defaults/base/repos.yaml +# update spack repos +RUN spack repo update +# find the gcc compiler +RUN spack compiler find +# copy the files in the hermes-3 repo needed to install dependencies +COPY ./external /root/hermes-3/external +COPY ./spack.yaml /root/hermes-3/spack.yaml +# set the workdir +WORKDIR /root/hermes-3 + +# Install hermes-3 dependencies via spack +# Activate the hermes-3 environment, install dependencies +RUN <