Skip to content
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
33 changes: 29 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,27 @@ on:
description: |
Whether to upload the deployment information to the build database (requires tag-deployment to also be true).
NOTE: Setting this to false is not recommended for model deployments.
spack-manifest-schema-path:
type: string
required: false
default: au.org.access-nri/model/spack/environment/deployment
description: |
The path to the Spack manifest schema directory relative to the ACCESS-NRI/schema repository.
spack-manifest-schema-version:
type: string
required: true
description: |
The version of the Spack manifest schema to use for validation, from the ACCESS-NRI/schema repository.
config-versions-schema-version:
type: string
required: true
description: |
The version of the config/versions.json schema to use for validation, from the ACCESS-NRI/schema repository.
config-packages-schema-version:
type: string
required: true
description: |
The version of the config/packages.json schema to use for validation, from the ACCESS-NRI/schema repository.
# Callers usually have the trigger:
# push:
# branches:
Expand Down Expand Up @@ -70,7 +91,7 @@ jobs:

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

Expand All @@ -87,7 +108,7 @@ jobs:
with:
repository: access-nri/build-cd

- uses: access-nri/build-cd/.github/actions/validate-deployment-settings@v5
- uses: access-nri/build-cd/.github/actions/validate-deployment-settings@v6
with:
settings-path: ./config/settings.json
target: ${{ matrix.target }}
Expand All @@ -105,7 +126,7 @@ jobs:

- name: Get root spec ref
id: tag
uses: access-nri/build-cd/.github/actions/get-spack-root-spec@v5
uses: access-nri/build-cd/.github/actions/get-spack-root-spec@v6
with:
spack-manifest-path: ${{ inputs.spack-manifest-path }}

Expand Down Expand Up @@ -159,14 +180,18 @@ jobs:
strategy:
matrix:
target: ${{ fromJson(needs.defaults.outputs.targets) }}
uses: access-nri/build-cd/.github/workflows/deploy-1-setup.yml@v5
uses: access-nri/build-cd/.github/workflows/deploy-1-setup.yml@v6
with:
deployment-target: ${{ matrix.target }}
deployment-ref: ${{ github.ref_name }}
deployment-type: Release
deployment-version: ${{ needs.get-root-spec-ref.outputs.root-spec-ref }}
spack-manifest-path: ${{ inputs.spack-manifest-path }}
expected-root-spec-name: ${{ needs.defaults.outputs.root-sbd }}
spack-manifest-schema-path: ${{ inputs.spack-manifest-schema-path }}
spack-manifest-schema-version: ${{ inputs.spack-manifest-schema-version }}
config-versions-schema-version: ${{ inputs.config-versions-schema-version }}
config-packages-schema-version: ${{ inputs.config-packages-schema-version }}
secrets: inherit
permissions:
contents: write
Expand Down
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@v5
uses: access-nri/build-cd/.github/actions/get-target-matrix@v6
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@v5
uses: access-nri/build-cd/.github/workflows/undeploy-1-start.yml@v6
with:
version-pattern: ${{ inputs.root-sbd }}-pr${{ github.event.pull_request.number }}-*
target: ${{ matrix.target }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:

- name: Original version
id: original
uses: access-nri/build-cd/.github/actions/get-spack-root-spec@v5
uses: access-nri/build-cd/.github/actions/get-spack-root-spec@v6

- name: Setup
id: setup
Expand Down
30 changes: 28 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,27 @@ on:
description: |
The Spack manifest path relative to the caller repository that will be used for the deployment.
This is usually `./spack.yaml`, but can be overridden if needed.
spack-manifest-schema-path:
type: string
required: false
default: au.org.access-nri/model/spack/environment/deployment
description: |
The path to the Spack manifest schema directory relative to the ACCESS-NRI/schema repository.
spack-manifest-schema-version:
type: string
required: true
description: |
The version of the Spack manifest schema to use for validation, from the ACCESS-NRI/schema repository.
config-versions-schema-version:
type: string
required: true
description: |
The version of the config/versions.json schema to use for validation, from the ACCESS-NRI/schema repository.
config-packages-schema-version:
type: string
required: true
description: |
The version of the config/packages.json schema to use for validation, from the ACCESS-NRI/schema repository.
# Callers usually have the trigger:
# pull_request:
# branches:
Expand Down Expand Up @@ -132,7 +153,7 @@ jobs:

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

Expand Down Expand Up @@ -196,7 +217,7 @@ jobs:
matrix:
# Example: ['Gadi', 'Setonix', ...]
target: ${{ fromJson(needs.defaults.outputs.targets) }}
uses: access-nri/build-cd/.github/workflows/deploy-1-setup.yml@v5
uses: access-nri/build-cd/.github/workflows/deploy-1-setup.yml@v6
with:
deployment-target: ${{ matrix.target }}
deployment-ref: ${{ needs.defaults.outputs.head-ref }}
Expand All @@ -208,6 +229,11 @@ jobs:
prerelease-compare-ref: ${{ needs.defaults.outputs.base-ref }}
spack-manifest-path: ${{ inputs.spack-manifest-path }}
expected-root-spec-name: ${{ needs.defaults.outputs.root-sbd }}
# Pass versions and paths for schemas into the deploy workflow
spack-manifest-schema-path: ${{ inputs.spack-manifest-schema-path }}
spack-manifest-schema-version: ${{ inputs.spack-manifest-schema-version }}
config-versions-schema-version: ${{ inputs.config-versions-schema-version }}
config-packages-schema-version: ${{ inputs.config-packages-schema-version }}
secrets: inherit

redeploy-post:
Expand Down
103 changes: 36 additions & 67 deletions .github/workflows/deploy-1-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ on:
description: |
The expected overarching spack bundle that contains all other packages, set in the caller repository.
Usually .spack.specs[0] or .spack.definitions.ROOT_PACKAGE in the manifest, but draft PRs can override this.
spack-manifest-schema-path:
type: string
required: true
description: |
The path to the Spack manifest schema directory relative to the ACCESS-NRI/schema repository.
spack-manifest-schema-version:
type: string
required: true
description: |
The version of the Spack manifest schema to use for validation, from the ACCESS-NRI/schema repository.
config-versions-schema-version:
type: string
required: true
description: |
The version of the config/versions.json schema to use for validation, from the ACCESS-NRI/schema repository.
config-packages-schema-version:
type: string
required: true
description: |
The version of the config/packages.json schema to use for validation, from the ACCESS-NRI/schema repository.
outputs:
general-metadata-artifact-glob:
value: ${{ jobs.deployment.outputs.general-metadata-artifact-glob }}
Expand Down Expand Up @@ -144,20 +164,27 @@ jobs:
- name: Validate ${{ github.repository }} config/versions.json
uses: access-nri/schema/.github/actions/validate-with-schema@main
with:
schema-version: ${{ vars.CONFIG_VERSIONS_SCHEMA_VERSION }}
schema-version: ${{ inputs.config-versions-schema-version }}
schema-location: au.org.access-nri/model/deployment/config/versions
data-location: ./model/config/versions.json

- name: Validate ${{ github.repository }} config/packages.json
uses: access-nri/schema/.github/actions/validate-with-schema@main
with:
schema-version: ${{ inputs.config-packages-schema-version }}
schema-location: au.org.access-nri/model/deployment/config/packages
data-location: ./model/config/packages.json

- name: Validate spack-packages version
id: spack-packages
uses: access-nri/build-cd/.github/actions/validate-repo-version@v5
uses: access-nri/build-cd/.github/actions/validate-repo-version@v6
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@v5
uses: access-nri/build-cd/.github/actions/validate-repo-version@v6
with:
repo-to-check: spack
pr: ${{ inputs.deployment-ref }}
Expand Down Expand Up @@ -188,7 +215,7 @@ jobs:

- name: Validate build-cd config/settings.json
id: settings
uses: access-nri/build-cd/.github/actions/validate-deployment-settings@v5
uses: access-nri/build-cd/.github/actions/validate-deployment-settings@v6
with:
settings-path: ./cd/config/settings.json
target: ${{ inputs.deployment-target }}
Expand Down Expand Up @@ -217,13 +244,13 @@ jobs:
if: env.IS_NOT_DRAFT == 'true' || inputs.deployment-type == 'Release'
uses: access-nri/schema/.github/actions/validate-with-schema@main
with:
schema-version: ${{ vars.SPACK_YAML_SCHEMA_VERSION }}
schema-location: au.org.access-nri/model/spack/environment/deployment
schema-version: ${{ inputs.spack-manifest-schema-version }}
schema-location: ${{ inputs.spack-manifest-schema-path }}
data-location: ${{ inputs.spack-manifest-path }}

- name: Get current (${{ inputs.deployment-ref }}) root spec version
id: current
uses: access-nri/build-cd/.github/actions/get-spack-root-spec@v5
uses: access-nri/build-cd/.github/actions/get-spack-root-spec@v6
with:
spack-manifest-path: ${{ inputs.spack-manifest-path }}

Expand Down Expand Up @@ -262,7 +289,7 @@ jobs:
- name: Get base root spec version
id: base
if: inputs.deployment-type != 'Release' && steps.checkout-base-spack.outcome != 'failure'
uses: access-nri/build-cd/.github/actions/get-spack-root-spec@v5
uses: access-nri/build-cd/.github/actions/get-spack-root-spec@v6
with:
spack-manifest-path: ${{ inputs.spack-manifest-path }}

Expand Down Expand Up @@ -293,64 +320,6 @@ jobs:
You can update it manually.
${{ inputs.spack-manifest-path != './spack.yaml' && env.BUMP_COMMENT_BODY || '' }}


- name: Check Projections - Specs
# This step checks that the root spec has an appropriate projection in the manifest file.
id: projection-check-spec
continue-on-error: true
run: |
git checkout ${{ inputs.deployment-ref }}

current_projection=$(yq '.spack.modules.default.tcl.projections.${{ steps.current.outputs.root-spec-name }}' ${{ inputs.spack-manifest-path }})
expected_projection_prefix='{name}/${{ steps.current.outputs.root-spec-ref }}'

if [[ "$current_projection" == "$expected_projection_prefix"* ]]; then
echo "${{ inputs.spack-manifest-path }}: Current root spec projection ($current_projection) and expected projection prefix ($expected_projection_prefix) match."
else
echo "::error::${{ inputs.spack-manifest-path }}: Current root spec projection ($current_projection) and expected projection prefix ($expected_projection_prefix) don't match."
exit 1
fi

- name: Check Projections - Packages
# This step checks that the defined projections have the same versions as the referenced packages in the spack.yaml file.
# For example, mom5@git.2023.12.12 matches with the
# modulefile mom5/2023.12.12 (specifically, the version strings match)
id: projection-check-packages
continue-on-error: true
if: env.IS_NOT_DRAFT == 'true' || inputs.deployment-type == 'Release'
run: |
FAILED="false"
# Get all the defined projections (minus 'all' and the root spec) and make them suitable for a bash for loop
DEPS=$(yq '.spack.modules.default.tcl.projections | del(.all) | del(.${{ steps.current.outputs.root-spec-name }}) | keys | join(" ")' ${{ inputs.spack-manifest-path }})

# for each of the module names
for DEP in $DEPS; do
# 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'
package_ver=$(yq ".spack.packages.\"$DEP\".require[0] | match(\"^@(?:git.)?([^=]*)\").captures[0].string" ${{ inputs.spack-manifest-path }})
expected_projection_prefix="{name}/$package_ver"

# Projections must start with '{name}/VERSION'. For example, '{name}/2024.11.11', or '{name}/2024.11.11-{hash:7}'
current_projection=$(yq ".spack.modules.default.tcl.projections.\"$DEP\"" ${{ inputs.spack-manifest-path }})

if [[ "$current_projection" == "$expected_projection_prefix"* ]]; then
echo "$DEP in ${{ inputs.spack-manifest-path }}: Current projection ($current_projection) and expected projection prefix ($expected_projection_prefix) match."
else
echo "::error::$DEP in ${{ inputs.spack-manifest-path }}: Current projection ($current_projection) and expected projection prefix ($expected_projection_prefix) don't match."
FAILED='true'
fi
done
if [[ "$FAILED" == "true" ]]; then
exit 1
fi

- name: Check Projections - Error Notifier
# If either of the Check Projection steps failed earlier, exit here
if: steps.projection-check-spec.outcome == 'failure' || steps.projection-check-packages.outcome == 'failure'
run: |
echo "::error::Some projections in ${{ inputs.spack-manifest-path }} don't match."
exit 1

- 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'.
Expand All @@ -361,7 +330,7 @@ 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@v5
uses: access-nri/build-cd/.github/workflows/deploy-2-start.yml@v6
with:
ref: ${{ inputs.deployment-ref }}
version: ${{ inputs.deployment-version }}
Expand Down
Loading