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

Multi-HPC Workflows #218

Merged
merged 47 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
87e4c8d
Move jobs around so they can be part of a single parallel workflow (#…
CodeGat Jan 6, 2025
faa931e
deploy-2-start.yml: Remove `release` and `build-db` jobs, output new …
CodeGat Jan 7, 2025
0cd3f8a
deploy-1-setup.yml: Output `general-metadata-artifact-glob` from `dep…
CodeGat Jan 7, 2025
9c812e4
cd.yml: Add `release`, `build-db` jobs from `deploy-2-start.yml`
CodeGat Jan 7, 2025
f60b30d
deploy-2-start.yml: Prepend metadata artifacts with deployment enviro…
CodeGat Jan 7, 2025
de70856
cd.yml: Generate release notes based on deployment targets
CodeGat Jan 7, 2025
619c2b7
Merge pull request #205 from ACCESS-NRI/200-multi-target-release
CodeGat Jan 9, 2025
bcfb373
.gitignore venv, pytest metadata
CodeGat Jan 9, 2025
35cb667
Create j2 templates for release notes and deployment comments
CodeGat Jan 9, 2025
08fac8a
Add scripts for jinja generation, requirements, created modules
CodeGat Jan 9, 2025
454206d
Update ci/cd to use templating script
CodeGat Jan 13, 2025
44c7c59
Add testing infrastructure
CodeGat Jan 13, 2025
c095483
Updated ci/cd calls to use script notation, removed --type arg
CodeGat Jan 14, 2025
1d35de0
ci.yml: Use output file as comment due to https://github.com/ACCESS-N…
CodeGat Jan 16, 2025
2d4b4a1
Add test validating non-collection of variables with the wrong `templ…
CodeGat Jan 16, 2025
7ac9817
Remove outputs folder as it is unused
CodeGat Jan 16, 2025
352d529
Update requirements.txt filepath
CodeGat Jan 16, 2025
d0c00d6
Added backslashes to multiline script invocation
CodeGat Jan 16, 2025
63f1981
Update template
CodeGat Jan 16, 2025
dea907f
Merge pull request #207 from ACCESS-NRI/206-jinja-templating
CodeGat Jan 16, 2025
c8570df
Replace `env.SPACK_YAML_MODEL_YQ` to accomodate for multi-target-form…
CodeGat Jan 17, 2025
6ebc7c2
Uppercase ROOT_PACKAGE
CodeGat Jan 20, 2025
1443a8d
Merge pull request #210 from ACCESS-NRI/208-multi-target-spack-yaml
CodeGat Jan 22, 2025
616dc3a
Update target matrix generation to take into account model repos depl…
CodeGat Jan 21, 2025
2f52e43
Added comments
CodeGat Jan 21, 2025
895fdd0
Added new get-target-matrix action
CodeGat Jan 23, 2025
cd03bf1
Update ci.yml, cd.yml to use get-target-matrix
CodeGat Jan 23, 2025
4d8a7c8
Simplify undeploy workflow
CodeGat Jan 23, 2025
17bfea2
cd.yml: Updated output variable
CodeGat Jan 23, 2025
cf41a69
Updated workflow reference to `undeploy-1-start.yml`
CodeGat Jan 23, 2025
a106dab
get-target-matrix: Made vars more generic
CodeGat Jan 23, 2025
c94ffe1
Merge pull request #211 from ACCESS-NRI/209-support-deployment-target…
CodeGat Jan 23, 2025
270b4c5
generate-build-metadata.bash: Reference explicit Gadi.* files
CodeGat Jan 22, 2025
0b92cf3
tests/scripts/generate-build-metadata: Updated test data inputs/outputs
CodeGat Jan 22, 2025
a0f0bbe
cd.yml: Use Gadi-specific outputs/metadata for build-db upload
CodeGat Jan 22, 2025
8292e25
Merge pull request #214 from ACCESS-NRI/212-interim-model-db-fix
CodeGat Jan 23, 2025
dad7e3b
Update README.md with information on this repository and it's workflows
CodeGat Jan 23, 2025
0eb22e8
Add config/README.md to explain files within the folder
CodeGat Jan 23, 2025
85c25cb
Apply suggestions from code review
CodeGat Jan 23, 2025
d84fa7a
Add GitHub search link
CodeGat Jan 23, 2025
d7aab02
Merge pull request #216 from ACCESS-NRI/215-readme-update
CodeGat Jan 23, 2025
fa11ad3
Small scale fixes from ACCESS-TEST E2E Testing
CodeGat Jan 28, 2025
beee2cf
Split `deployment-environment` input into `deployment-target` and `de…
CodeGat Jan 28, 2025
6299c48
Update all build-cd refs to latest `v4`, get latest default branch re…
CodeGat Jan 28, 2025
2b635fb
Use default `inputs.ref` for `checkout` action to get default branch
CodeGat Jan 30, 2025
23bf067
Remove conditional logic for `deployment-type`s
CodeGat Feb 3, 2025
e23cba8
Merge pull request #221 from ACCESS-NRI/220-consistent-environment-names
CodeGat Feb 3, 2025
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
2 changes: 1 addition & 1 deletion .github/actions/get-deploy-paths/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
steps:
- name: Get Deployment Paths
id: paths
uses: access-nri/build-cd/.github/actions/get-deploy-paths@main
uses: access-nri/build-cd/.github/actions/get-deploy-paths@vX
with:
spack-installs-root-path: ${{ vars.SPACK_INSTALLS_ROOT_PATH }}
spack-version: "0.21"
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/get-target-matrix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
valid-targets: ${{ steps.generate.outputs.valid-targets }}
steps:
- id: generate
uses: access-nri/build-cd/.github/actions/get-target-matrix@main
uses: access-nri/build-cd/.github/actions/get-target-matrix@vX
with:
targets: ${{ vars.MODEL_REPO_TARGETS }}

Expand Down
7 changes: 6 additions & 1 deletion .github/actions/get-target-matrix/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ outputs:
runs:
using: composite
steps:
- name: Get default branch
shell: bash
id: default
run: echo "branch=$(gh repo view access-nri/build-cd --json defaultBranchRef --jq '.[].name')" >> $GITHUB_OUTPUT

- name: Get deployment settings.json
uses: actions/checkout@v4
with:
repository: access-nri/build-cd
ref: main
ref: ${{ steps.default.outputs.branch }}

- name: Generate Deployment Target Matrix
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/validate-deployment-settings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This action validates various `ACCESS-NRI/build-cd` deployment settings.
# ...
- name: Validate settings
id: settings
uses: access-nri/build-cd/.github/actions/validate-deployment-settings@main
uses: access-nri/build-cd/.github/actions/validate-deployment-settings@vX
with:
settings-path: ./some/settings.json
target: Supercomputer
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/validate-repo-version/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This action checks that the tags specified in a models `config/versions.json` is
```yaml
# ...
- id: validate
uses: access-nri/build-cd/.github/actions/validate-repo-version@main
uses: access-nri/build-cd/.github/actions/validate-repo-version@vX
with:
repo-to-check: spack-packages
pr: 12
Expand Down
26 changes: 19 additions & 7 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:

- name: Generate Deployment Target Matrix
id: target
uses: access-nri/build-cd/.github/actions/get-target-matrix@v3
uses: access-nri/build-cd/.github/actions/get-target-matrix@v4
with:
targets: ${{ vars.RELEASE_DEPLOYMENT_TARGETS }}

Expand All @@ -65,12 +65,16 @@ jobs:
matrix:
target: ${{ fromJson(needs.defaults.outputs.targets) }}
steps:
- name: Get default branch
id: default
run: echo "branch=$(gh repo view access-nri/build-cd --json defaultBranchRef --jq '.[].name')" >> $GITHUB_OUTPUT

- uses: actions/checkout@v4
with:
repository: ACCESS-NRI/build-cd
ref: main
repository: access-nri/build-cd
ref: ${{ steps.default.outputs.branch }}

- uses: access-nri/build-cd/.github/actions/validate-deployment-settings@main
- uses: access-nri/build-cd/.github/actions/validate-deployment-settings@v4
with:
settings-path: ./config/settings.json
target: ${{ matrix.target }}
Expand Down Expand Up @@ -121,7 +125,7 @@ jobs:
strategy:
matrix:
target: ${{ fromJson(needs.defaults.outputs.targets) }}
uses: access-nri/build-cd/.github/workflows/deploy-1-setup.yml@v3
uses: access-nri/build-cd/.github/workflows/deploy-1-setup.yml@v4
with:
deployment-target: ${{ matrix.target }}
deployment-ref: ${{ github.ref_name }}
Expand All @@ -132,6 +136,9 @@ jobs:
secrets: inherit
permissions:
contents: write
# We require pull-requests:write despite not using it in this path,
# because it is needed by the pull_request invocation of the workflow.
pull-requests: write

release:
name: Create Release
Expand All @@ -146,11 +153,15 @@ jobs:
url: ${{ steps.release.outputs.url }}
created-at: ${{ steps.metadata.outputs.created-at }}
steps:
- name: Get default branch
id: default
run: echo "branch=$(gh repo view access-nri/build-cd --json defaultBranchRef --jq '.[].name')" >> $GITHUB_OUTPUT

- name: Checkout build-cd
uses: actions/checkout@v4
with:
repository: access-nri/build-cd
ref: v3
ref: ${{ steps.default.outputs.branch }}

- name: Download Metadata Artifacts
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -214,6 +225,7 @@ jobs:
build-db:
name: Build DB Metadata Upload
needs:
- defaults
- deploy-release
- release
runs-on: ubuntu-latest
Expand Down Expand Up @@ -260,7 +272,7 @@ jobs:
${{ needs.release.outputs.url }} ${{ needs.release.outputs.created-at }} \
${{ steps.spack-versions.outputs.packages-version }} ${{ steps.spack-versions.outputs.config-version }} \
${{ env.METADATA_PATH }} ${{ env.OUTPUTS_PATH }} \
${{ inputs.root-sbd }} ${{ vars.BUILD_DB_PACKAGES }}
${{ needs.defaults.outputs.root-sbd }} ${{ vars.BUILD_DB_PACKAGES }}

echo "Attempting upload of build_metadata.json"
python ./tools/release_provenance/save_release.py "${{ env.OUTPUTS_PATH }}/build_metadata.json"
4 changes: 2 additions & 2 deletions .github/workflows/ci-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

- name: Generate Deployment Target Matrix
id: target
uses: access-nri/build-cd/.github/actions/get-target-matrix@v3
uses: access-nri/build-cd/.github/actions/get-target-matrix@v4
with:
targets: ${{ vars.PRERELEASE_DEPLOYMENT_TARGETS }}

Expand All @@ -50,7 +50,7 @@ jobs:
matrix:
target: ${{ fromJson(needs.setup.outputs.targets) }}
fail-fast: false
uses: access-nri/build-cd/.github/workflows/undeploy-1-start.yml@main
uses: access-nri/build-cd/.github/workflows/undeploy-1-start.yml@v4
with:
version-pattern: ${{ inputs.root-sbd }}-pr${{ github.event.pull_request.number }}-*
target: ${{ matrix.target }}
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:

- name: Generate Deployment Target Matrix
id: target
uses: access-nri/build-cd/.github/actions/get-target-matrix@v3
uses: access-nri/build-cd/.github/actions/get-target-matrix@v4
with:
targets: ${{ vars.PRERELEASE_DEPLOYMENT_TARGETS }}

Expand Down Expand Up @@ -189,7 +189,7 @@ jobs:
matrix:
# Example: ['Gadi', 'Setonix', ...]
target: ${{ fromJson(needs.defaults.outputs.targets) }}
uses: access-nri/build-cd/.github/workflows/deploy-1-setup.yml@main
uses: access-nri/build-cd/.github/workflows/deploy-1-setup.yml@v4
with:
deployment-target: ${{ matrix.target }}
deployment-ref: ${{ needs.defaults.outputs.head-ref }}
Expand Down Expand Up @@ -245,11 +245,15 @@ jobs:
OUTPUT_ARTIFACT_PATH: ./merged_outputs
TEMPLATED_COMMENT_BODY_PATH: /opt/comment-body.md
steps:
- name: Get default branch
id: default
run: echo "branch=$(gh repo view access-nri/build-cd --json defaultBranchRef --jq '.[].name')" >> $GITHUB_OUTPUT

- name: Checkout build-cd for scripts
uses: actions/checkout@v4
with:
repository: access-nri/build-cd
ref: v3
ref: ${{ steps.default.outputs.branch }}

- name: Download matrix deployment outputs
uses: actions/download-artifact@v4
Expand Down
22 changes: 14 additions & 8 deletions .github/workflows/deploy-1-setup.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Deploy
on:
# This is invoked by both `on.pull_request` and `on.push` events.
workflow_call:
inputs:
deployment-target:
Expand Down Expand Up @@ -120,23 +121,27 @@ jobs:

- name: Validate spack-packages version
id: spack-packages
uses: access-nri/build-cd/.github/actions/validate-repo-version@main
uses: access-nri/build-cd/.github/actions/validate-repo-version@v4
with:
repo-to-check: spack-packages
pr: ${{ inputs.deployment-ref }}

- name: Validate spack version
id: spack
uses: access-nri/build-cd/.github/actions/validate-repo-version@main
uses: access-nri/build-cd/.github/actions/validate-repo-version@v4
with:
repo-to-check: spack
pr: ${{ inputs.deployment-ref }}

- name: Get default branch
id: default
run: echo "branch=$(gh repo view access-nri/build-cd --json defaultBranchRef --jq '.[].name')" >> $GITHUB_OUTPUT

- name: Checkout build-cd Config
uses: actions/checkout@v4
with:
repository: ACCESS-NRI/build-cd
ref: main
repository: access-nri/build-cd
ref: ${{ steps.default.outputs.branch }}
path: cd

- name: Get spack-config version
Expand All @@ -151,7 +156,7 @@ jobs:

- name: Validate build-cd config/settings.json
id: settings
uses: access-nri/build-cd/.github/actions/validate-deployment-settings@main
uses: access-nri/build-cd/.github/actions/validate-deployment-settings@v4
with:
settings-path: ./cd/config/settings.json
target: ${{ inputs.deployment-target }}
Expand Down Expand Up @@ -241,7 +246,7 @@ jobs:
if [[ "$DEP" == "${{ inputs.spack-manifest-root-sbd }}" ]]; then
# The model version is the bit after '@git.', before any later, space-separated, optional variants.
# For example, in '[email protected] type=ACCESS ~debug' the version is 'VERSION'.
DEP_VER=$(yq '.spack.specs[0] | capture(".+@git\\.(?<version>[^ ]+).*") | .version' spack.yaml)
DEP_VER=$(yq '${{ env.SPACK_YAML_MODEL_YQ }} | capture(".+@git\\.(?<version>[^ ]+).*") | .version' spack.yaml)
else
# Capture the section after '@git.' or '@' (if it's not a git-attributed version) and before a possible '=' for a given dependency.
# Ex. '@git.2024.02.11' -> '2024.02.11', '@access-esm1.5' -> 'access-esm1.5', '@git.2024.05.21=access-esm1.5' -> '2024.05.21'
Expand Down Expand Up @@ -280,14 +285,15 @@ jobs:
needs:
- check-config # Verify configuration information is correct
- check-spack-yaml # Verify spack manifest information is correct
uses: access-nri/build-cd/.github/workflows/deploy-2-start.yml@v3
uses: access-nri/build-cd/.github/workflows/deploy-2-start.yml@v4
with:
type: ${{ inputs.deployment-type }}
model: ${{ inputs.spack-manifest-root-sbd }}
ref: ${{ inputs.deployment-ref }}
version: ${{ inputs.deployment-version }}
env-name: ${{ needs.check-spack-yaml.outputs.spack-env-name }}
deployment-environment: ${{ inputs.deployment-type == 'Prerelease' && format('{0} Prerelease', inputs.deployment-target) || inputs.deployment-target }}
deployment-target: ${{ inputs.deployment-target }}
deployment-type: ${{ inputs.deployment-type }}
root-sbd: ${{ inputs.spack-manifest-root-sbd }}
secrets: inherit

Expand Down
47 changes: 32 additions & 15 deletions .github/workflows/deploy-2-start.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Deploy Start
concurrency: ${{ inputs.deployment-environment }}
concurrency: ${{ inputs.deployment-target }} ${{ inputs.deployment-type }}
on:
workflow_call:
inputs:
Expand All @@ -23,10 +23,19 @@ on:
type: string
required: true
description: The spack-env-compliant environment name for the model
deployment-environment:
deployment-target:
type: string
required: true
description: The GitHub deployment environment name
description: |
The GitHub Environment, minus a potential Type.
Combined with inputs.deployment-type to create the GitHub Environment name.
deployment-type:
type: string
required: true
description: |
The type of deployment.
Can be one of: Release, Prerelease.
Combined with inputs.deployment-type to create the GitHub Environment name.
root-sbd:
type: string
required: true
Expand All @@ -49,12 +58,12 @@ env:
SPACK_YAML_MODEL_YQ: (.spack.definitions[] | select(."ROOT_PACKAGE") | .[][]) // .spack.specs[0]
SPACK_YAML_MODULEFILE_PROJECTION_YQ: .spack.modules.default.tcl.projections.${{ inputs.root-sbd }}
METADATA_PATH: /opt/metadata
ARTIFACT_NAME: deploy-metadata.${{ inputs.deployment-environment }}
ARTIFACT_NAME: deploy-metadata.${{ inputs.deployment-target }}
jobs:
deploy-to-environment:
name: Deploy to ${{ inputs.deployment-environment }}
name: Deploy to ${{ inputs.deployment-target }} ${{ inputs.deployment-type }}
runs-on: ubuntu-latest
environment: ${{ inputs.deployment-environment }}
environment: ${{ inputs.deployment-target }} ${{ inputs.deployment-type != 'Release' && inputs.deployment-type || '' }}
outputs:
packages-version: ${{ steps.versions.outputs.packages }}
config-version: ${{ steps.versions.outputs.config }}
Expand All @@ -73,13 +82,13 @@ jobs:
echo "spack=$(jq --compact-output --raw-output '.spack' ./config/versions.json)" >> $GITHUB_OUTPUT
echo "packages=$(jq --compact-output --raw-output '."spack-packages"' ./config/versions.json)" >> $GITHUB_OUTPUT

- name: Get ${{ inputs.deployment-environment }} Remote Paths
- name: Get ${{ inputs.deployment-target }} ${{ inputs.deployment-type }} Remote Paths
id: path
uses: access-nri/build-cd/.github/actions/get-deploy-paths@main
uses: access-nri/build-cd/.github/actions/get-deploy-paths@v4
with:
spack-installs-root-path: ${{ vars.SPACK_INSTALLS_ROOT_LOCATION }}
spack-version: ${{ steps.versions.outputs.spack }}
deployment-environment: ${{ inputs.deployment-environment }}
deployment-environment: ${{ inputs.deployment-target }} ${{ inputs.deployment-type }}

- name: Setup SSH
id: ssh
Expand All @@ -97,7 +106,7 @@ jobs:
# Also removes the `@git.VERSION` specifier for Prereleases so
# we don't have to shift tags around.
run: |
yq -i '${{ env.SPACK_YAML_SPEC_YQ }} = (${{ env.SPACK_YAML_SPEC_YQ }} | split("@").[0])' spack.yaml
yq -i '${{ env.SPACK_YAML_MODEL_YQ }} = (${{ env.SPACK_YAML_MODEL_YQ }} | split("@").[0])' spack.yaml
yq -i '${{ env.SPACK_YAML_MODULEFILE_PROJECTION_YQ }} = "{name}/${{ inputs.version }}"' spack.yaml
echo '::notice::Prerelease accessible as module `${{ inputs.model}}/${{ inputs.version }}`'

Expand Down Expand Up @@ -125,16 +134,20 @@ jobs:
done
EOT

- name: Deploy to ${{ inputs.deployment-environment }}
- name: Deploy to ${{ inputs.deployment-target }} ${{ inputs.deployment-type }}
# ssh into deployment environment, create and activate the env, install the spack.yaml.
run: |
ssh ${{ secrets.USER}}@${{ secrets.HOST }} -i ${{ steps.ssh.outputs.private-key-path }} /bin/bash <<'EOT'
# Check that a suitable deployment location exists
if [ ! -d "${{ steps.path.outputs.root }}" ]; then
echo '::error::A deployment of spack does not exist in `${{ steps.path.outputs.root }}` for `${{ inputs.deployment-environment }}`'
echo '::error::A deployment of spack does not exist in `${{ steps.path.outputs.root }}` for `${{ inputs.deployment-target }} ${{ inputs.deployment-type}}`'
exit 1
fi

# Export vars.DEPLOYMENT_TARGET
export DEPLOYMENT_TARGET="${{ vars.DEPLOYMENT_TARGET }}"
echo "DEPLOYMENT_TARGET exported as $DEPLOYMENT_TARGET"

# Update spack-packages
git -C ${{ steps.path.outputs.spack-packages }} fetch
git -C ${{ steps.path.outputs.spack-packages }} checkout --force ${{ steps.versions.outputs.packages }}
Expand All @@ -156,11 +169,15 @@ jobs:
echo "spack=${{ steps.path.outputs.spack }}" >> $GITHUB_OUTPUT
echo "modules=${{ vars.DEPLOYED_MODULES_DIR }}" >> $GITHUB_OUTPUT

- name: Get metadata from ${{ inputs.deployment-environment }}
- name: Get metadata from ${{ inputs.deployment-target }} ${{ inputs.deployment-type}}
env:
SPACK_ENV_PATH: ${{ steps.path.outputs.spack }}/../environments/${{ inputs.env-name }}
run: |
ssh ${{ secrets.USER}}@${{ secrets.HOST }} -i ${{ steps.ssh.outputs.private-key-path }} /bin/bash <<'EOT'
ssh ${{ secrets.USER }}@${{ secrets.HOST }} -i ${{ steps.ssh.outputs.private-key-path }} /bin/bash <<'EOT'
# Export vars.DEPLOYMENT_TARGET
export DEPLOYMENT_TARGET="${{ vars.DEPLOYMENT_TARGET }}"
echo "DEPLOYMENT_TARGET exported as $DEPLOYMENT_TARGET"

. ${{ steps.path.outputs.spack-config }}/spack-enable.bash
spack env activate ${{ inputs.env-name }}

Expand Down Expand Up @@ -213,7 +230,7 @@ jobs:
# Rename the files to include the deployment environment
cd ./${{ env.ARTIFACT_NAME }}
for file in *; do
mv "$file" "${{ inputs.deployment-environment }}.$file"
mv "$file" "${{ inputs.deployment-target }}.$file"
done
cd -

Expand Down
Loading