Skip to content

Commit e9ebfcd

Browse files
authored
Allow @latest (#235)
* get-spack-root-spec action: Allow `@latest` as ref * cd.yml: Add a check so that a `@latest` version is not deployed as a Release * deploy-1-setup.yml: Check that `@latest` isn't used in a non-draft PR * get-spack-root-spec action: Move regex into it's own variable * Update group regex to be appropriately quoted
1 parent 8ce48bd commit e9ebfcd

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

.github/actions/get-spack-root-spec/action.yml

+8-5
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,14 @@ runs:
6363
# Example: [email protected]=release ~variant
6464
full=$(yq '${{ steps.yq.outputs.filter }}' ${{ inputs.spack-manifest-path }})
6565
66-
# Example of groups from the above:
67-
# name: anything before `@git.`. Ex: access-om2
68-
# ref: anything after `@git.` but before an `=` (for =VERSION syntax) or before a space, `+` or `~` (for variants). Ex: 2025.01.0
69-
# version: anything after a `=`, but before a space, `+` or `~` (for variants). Ex: release
70-
groups=$(yq '${{ steps.yq.outputs.filter }} | capture("(?<name>.+)@git\\.(?<ref>[^=+~ ]+)(?:=(?<version>[^~+ ]+))?.*")' ${{ inputs.spack-manifest-path }})
66+
# Example of captured groups from the above:
67+
# name: anything before `@`. Ex: access-om2
68+
# ref: anything after `@` or `@git.`; but before `=` (for =VERSION syntax) or ` `/`+`/`~` (for variants). Ex: 2025.01.0
69+
# version: anything after a `=`, but before ` `/`+`/`~` (for variants). Ex: release
70+
71+
groups_regex='(?<name>.+)@(?:git\\.)?(?<ref>[^=+~ ]+)(?:=(?<version>[^~+ ]+))?.*'
72+
73+
groups=$(yq '${{ steps.yq.outputs.filter }} | capture("'"$groups_regex"'")' ${{ inputs.spack-manifest-path }})
7174
7275
# Pull values from groups above
7376
name=$(yq '.name' <<< "$groups")

.github/workflows/cd.yml

+5
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ jobs:
104104
env:
105105
TAG: ${{ steps.tag.outputs.root-spec-ref }}
106106
run: |
107+
if [[ "${{ env.TAG }}" == "latest" ]]; then
108+
echo "::error::The version 'latest' is reserved for a spack package that moves often and cannot be used as a release tag. Reset the 'main' or 'backport' branch, reopen the merged PR, and update the version."
109+
exit 1
110+
fi
111+
107112
git tag ${{ env.TAG }} -m "Deployment of ${{ inputs.model }} ${{ env.TAG }} via build-cd 'cd.yml' workflow"
108113
git push --tags
109114

.github/workflows/deploy-1-setup.yml

+10
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,16 @@ jobs:
183183
id: current
184184
uses: access-nri/build-cd/.github/actions/get-spack-root-spec@v4
185185

186+
- name: Check '@latest' version usage
187+
if: >-
188+
(github.event_name == 'pull_request' && !github.event.pull_request.draft) ||
189+
(github.event_name == 'issue_comment' && !github.event.issue.draft)
190+
run: |
191+
if [[ "${{ steps.current.outputs.root-spec-ref }}" == "latest" ]]; then
192+
echo "::error::The '@latest' version string is not allowed in non-draft PRs. It is reserved for a spack package that moves often and cannot be used as a future release tag"
193+
exit 1
194+
fi
195+
186196
- name: Checkout base (${{ inputs.prerelease-compare-ref }}) spack manifest
187197
if: inputs.deployment-type != 'Release'
188198
continue-on-error: true

0 commit comments

Comments
 (0)