Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prerelease: Unique Modulefiles #54

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ jobs:
type: prerelease
ref: ${{ github.head_ref }}
version: ${{ needs.version-tag.outputs.prerelease }}
root-sbd: ${{ inputs.root-sbd }}
secrets: inherit

notifier:
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/deploy-1-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,44 @@ on:
type: string
required: true
description: The version for the model being deployed
root-sbd:
type: string
required: false
# default: The model name, taken from the callers repository name
description: The root SBD that is being used as the modulefile name

jobs:
setup-spack-env:
name: Setup Spack Environment
runs-on: ubuntu-latest
outputs:
# Model name inferred from repository name
model: ${{ steps.get-model.outputs.model }}
# Spack env name in form <model>-<version>
env-name: ${{ steps.get-env-name.outputs.env-name }}
# Root SBD that defaults to the model name
root-sbd: ${{ steps.set-root-sbd.outputs.root-sbd }}
steps:
- name: Get Model
id: get-model
# for the cases where the repo name is in uppercase but the package name is lowercase (eg. access-nri/MOM5)
run: echo "model=$(echo ${{ github.event.repository.name }} | tr [:upper:] [:lower:])" >> $GITHUB_OUTPUT

- name: Set Spack Env Name String
id: get-env-name
# replace occurences of '.' with '_' in environment name as spack doesn't support '.'. Ex: 'access-om2-v1.0.0' -> 'access-om2-v1_0_0'.
run: echo "env-name=$(echo '${{ steps.get-model.outputs.model }}-${{ inputs.version }}' | tr '.' '_')" >> $GITHUB_OUTPUT

- name: Set Root SBD Default
id: set-root-sbd
# We set the default here because we don't have access to the modified repo name in the inputs section yet
run: |
if [[ "${{ inputs.root-sbd }}" == "" ]]; then
echo "root-sbd=${{ steps.get-model.outputs.model }}" >> $GITHUB_OUTPUT
else
echo "root-sbd=${{ inputs.root-sbd }}" >> $GITHUB_OUTPUT
fi

setup-deployment-env:
name: Setup Deployment Environment
runs-on: ubuntu-latest
Expand Down Expand Up @@ -73,4 +93,5 @@ jobs:
version: ${{ inputs.version }}
env-name: ${{ needs.setup-spack-env.outputs.env-name }}
deployment-environment: ${{ matrix.deployment-environment }}
root-sbd: ${{ needs.setup-spack-env.outputs.root-sbd }}
secrets: inherit
16 changes: 15 additions & 1 deletion .github/workflows/deploy-2-start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ on:
type: string
required: true
description: The GitHub deployment environment name

root-sbd:
type: string
required: false
default: ${{ inputs.model }}
description: The root SBD that is being used as the modulefile name
env:
SPACK_YAML_MODULEFILE_PROJECTION_YQ: .spack.modules.default.tcl.projections.${{ inputs.root-sbd }}
jobs:
deploy-to-environment:
name: Deploy to ${{ inputs.deployment-environment }}
Expand All @@ -54,6 +60,14 @@ jobs:
${{ secrets.HOST }}
${{ secrets.HOST_DATA }}

- name: Prerelease Modulefile Name
if: inputs.type == 'prerelease'
# Modifies the name of the prerelease modulefile to the
# `pr<number>-<commit>` style. For example, `access-om3/pr12-2`
aidanheerdegen marked this conversation as resolved.
Show resolved Hide resolved
run: |
yq -i '${{ env.SPACK_YAML_MODULEFILE_PROJECTION_YQ }} = {name}/${{ inputs.version }}' spack.yaml
echo "::notice::Prerelease accessible as module `${{ inputs.model}}/${{ inputs.version }}`"

- name: Copy spack.yaml
run: |
rsync -e 'ssh -i ${{ steps.ssh.outputs.private-key-path }}' \
Expand Down