-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from ACCESS-NRI/50-compiler-base-spack
Compiler in base-spack
- Loading branch information
Showing
6 changed files
with
128 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Dependency Image Generation Pipeline | ||
on: | ||
workflow_call: | ||
inputs: | ||
spack-packages-version: | ||
description: Tag associated with the access-nri/spack_packages repo | ||
type: string | ||
compiler-name: | ||
description: Name of the compiler | ||
type: string | ||
compiler-package: | ||
description: Spack package name of the compiler | ||
type: string | ||
compiler-version: | ||
description: Spack package version of the compiler | ||
type: string | ||
model: | ||
description: A model name (eg. access-om2) | ||
type: string | ||
jobs: | ||
base-spack-image-check: | ||
name: Check for the existence of base-spack-${{ inputs.compiler-name }}@${{ inputs.compiler-version }}-${{ inputs.spack-packages-version }} | ||
runs-on: ubuntu-latest | ||
outputs: | ||
image-exists: ${{ steps.image-exists.outputs.check }} | ||
steps: | ||
- name: Log in to container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Check for existing package | ||
id: image-exists | ||
run: | | ||
manifest=$(docker manifest inspect ghcr.io/access-nri/base-spack-${{ inputs.compiler-name }}@${{ inputs.compiler-version }}-${{ inputs.spack-packages-version }}:latest) | ||
if [ "$manifest" != "manifest unknown" ]; then | ||
echo "check=true" >> $GITHUB_OUTPUT | ||
fi | ||
base-spack-image: | ||
name: Create the base-spack image | ||
needs: | ||
- base-spack-image-check | ||
if: needs.base-spack-image-check.outputs.image-exists | ||
uses: access-nri/build-ci/.github/workflows/build-and-push-image.yml@main | ||
with: | ||
container-registry: ghcr.io | ||
container-name: access-nri/base-spack-${{ inputs.spack-packages-version }} | ||
dockerfile-directory: containers | ||
dockerfile-name: Dockerfile.base-spack | ||
build-args: | | ||
"SPACK_PACKAGES_REPO_VERSION=${{ inputs.spack-packages-version }}" | ||
"COMPILER_NAME=${{ inputs.compiler-name }}" | ||
"COMPILER_PACKAGE=${{ inputs.compiler-package }}" | ||
"COMPILER_VERSION=${{ inputs.compiler-version }}" | ||
secrets: | ||
build-secrets: | | ||
"S3_ACCESS_KEY_ID=${{ secrets.S3_ACCESS_KEY_ID }}" | ||
"S3_ACCESS_KEY_SECRET=${{ secrets.S3_ACCESS_KEY_SECRET }}" | ||
"access-nri.priv=${{ secrets.BUILDCACHE_KEY_PRIVATE }}" | ||
"access-nri.pub=${{ secrets.BUILDCACHE_KEY_PUBLIC }}" | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
dependency-image: | ||
# running always() means it will run even if base-spack is skipped | ||
if: always() | ||
needs: | ||
- base-spack-image | ||
uses: access-nri/build-ci/.github/workflows/build-and-push-image.yml@main | ||
with: | ||
container-registry: ghcr.io | ||
container-name: access-nri/build-${{ inputs.model}}-${{ inputs.compiler-name }}${{ inputs.compiler-version }}-${{ inputs.spack-packages-version }} | ||
dockerfile-directory: containers | ||
dockerfile-name: Dockerfile.${{ inputs.model }} | ||
build-args: | | ||
# TODO: Probably shouldn't hard code base image path | ||
"BASE_IMAGE=ghcr.io/access-nri/base-spack-${{ inputs.compiler-name }}@${{ inputs.compiler-version }}-${{ inputs.spack-packages-version }}:latest" | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,15 @@ | ||
#!/bin/bash | ||
|
||
# usage: ./setup-spack-envs <compiler package> <compiler name> <compiler version> <models string> | ||
# eg: | ||
if [ "$#" -ne 4 ]; then | ||
echo "Invalid number of arguments: expecting 4" | ||
exit 1 | ||
fi | ||
# usage: ./setup-spack-envs <models string> | ||
|
||
COMPILER_PACKAGE="$1" | ||
COMPILER_NAME="$2" | ||
COMPILER_VERSION="$3" | ||
PACKAGES="$4" | ||
PACKAGES="$1" | ||
|
||
for PACKAGE in $PACKAGES; do | ||
spack env create $PACKAGE | ||
spack env activate $PACKAGE | ||
spack -d install -j 4 --add --fail-fast $COMPILER_PACKAGE@$COMPILER_VERSION | ||
spack load $COMPILER_PACKAGE@$COMPILER_VERSION | ||
spack -d install -j 4 --add --fail-fast $SPACK_ENV_COMPILER_PACKAGE@$SPACK_ENV_COMPILER_VERSION | ||
spack load $SPACK_ENV_COMPILER_PACKAGE@$SPACK_ENV_COMPILER_VERSION | ||
spack compiler find --scope env:$PACKAGE | ||
spack -d install -j 4 --add --only dependencies --fail-fast $PACKAGE%$COMPILER_NAME@$COMPILER_VERSION | ||
spack gc -y | ||
spack -d install -j 4 --add --only dependencies --fail-fast $PACKAGE%$SPACK_ENV_COMPILER_NAME@$SPACK_ENV_COMPILER_VERSION | ||
spack env deactivate | ||
done |