@@ -114,20 +114,61 @@ jobs:
114
114
spack env activate ${{ inputs.env-name }}
115
115
spack --debug install --fresh ${{ vars.SPACK_INSTALL_PARALLEL_JOBS }} || exit $?
116
116
spack module tcl refresh -y
117
+ EOT
118
+
119
+ - name : Get metadata from ${{ inputs.deployment-environment }}
120
+ env :
121
+ SPACK_ENV_PATH : ${{ steps.path.outputs.spack }}/var/spack/environments/${{ inputs.env-name }}
122
+ run : |
123
+ ssh ${{ secrets.USER}}@${{ secrets.HOST }} -i ${{ steps.ssh.outputs.private-key-path }} /bin/bash <<'EOT'
124
+ . ${{ steps.path.outputs.spack-config }}/spack-enable.bash
125
+ spack env activate ${{ inputs.env-name }}
126
+
127
+ spack find --paths > ${{ env.SPACK_ENV_PATH }}/spack.location
128
+ spack find --format '{hash} {prefix}' | jq --raw-input --null-input '[inputs | split(" ") | {(.[0]): (.[1])}] | add' > ${{ env.SPACK_ENV_PATH }}/spack.location.json
129
+
130
+ # Get the repos associated with the packages for the build database
131
+ jq -n '{}' > ${{ env.SPACK_ENV_PATH }}/build-db-pkgs.json
132
+ for pkg in ${{ vars.BUILD_DB_PACKAGES }}; do
133
+ # TODO: Is there a way to get the git attribute without concretizing?
134
+ pkg_repo_url=$(spack python -c "import spack.spec; print(spack.spec.Spec('$pkg').concretized().package.git)")
117
135
118
- # Obtain metadata
119
- spack find --paths > ${{ steps.path.outputs.spack }}/var/spack/environments/${{ inputs.env-name }}/spack.location
120
- spack find --format '{hash} {prefix}' | jq --raw-input --null-input '[inputs | split(" ") | {(.[0]): (.[1])}] | add' > ${{ steps.path.outputs.spack }}/var/spack/environments/${{ inputs.env-name }}/spack.location.json
136
+ # We get the version of $pkg from spack.lock, and then strip
137
+ # potential 'git.' and '=VERSION' parts from 'git.TAG=VERSION'
138
+ version=$(jq --compact-output --raw-output \
139
+ --arg p "$pkg" \
140
+ '.concrete_specs | to_entries[].value | select(.name == $p) | .version
141
+ | match("^(?:git.)?([^=]*)")
142
+ | .captures[0].string' \
143
+ ${{ env.SPACK_ENV_PATH}}/spack.lock
144
+ )
145
+
146
+ # Example:
147
+ # pkg_repo_url = https://github.com/ACCESS-NRI/MOM5.git, which is then stripped of the '.git'.
148
+ # version = 2024.08.11, giving
149
+ # pkg_release_url = https://github.com/ACCESS-NRI/MOM5/releases/tag/2024.08.11
150
+ pkg_release_url="${pkg_repo_url%.*}/releases/tag/${version}"
151
+
152
+ echo "$pkg pkg_repo_url is $pkg_repo_url, pkg_release_url is $pkg_release_url, version is $version"
153
+ jq \
154
+ --arg p "$pkg" \
155
+ --arg r "$pkg_release_url" \
156
+ '. += {($p): ($r)}' \
157
+ ${{ env.SPACK_ENV_PATH }}/build-db-pkgs.json > ${{ env.SPACK_ENV_PATH }}/build-db-pkgs.json.tmp
158
+ mv -f ${{ env.SPACK_ENV_PATH }}/build-db-pkgs.json.tmp ${{ env.SPACK_ENV_PATH }}/build-db-pkgs.json
159
+ done
121
160
122
161
spack env deactivate
123
- echo "$(date): Deployed ${{ inputs.model }} ${{ inputs.version }} with spack-packages ${{ steps.versions.outputs.packages }}, spack-config ${{ steps.versions.outputs.config }}" >> ${{ steps.path.outputs.root }}/release.log
124
162
EOT
125
163
126
164
# Release
127
165
- name : Get Release Metadata
166
+ env :
167
+ # TODO: Can we put both envs above in a $GITHUB_ENV file instead?
168
+ SPACK_ENV_PATH : ${{ steps.path.outputs.spack }}/var/spack/environments/${{ inputs.env-name }}
128
169
run : |
129
170
rsync -e 'ssh -i ${{ steps.ssh.outputs.private-key-path }}' \
130
- '${{ secrets.USER}}@${{ secrets.HOST_DATA }}:${{ steps.path.outputs.spack }}/var/spack/environments/${{ inputs. env-name }}/spack.*' \
171
+ '${{ secrets.USER}}@${{ secrets.HOST_DATA }}:${{ env.SPACK_ENV_PATH }}/spack.*' \
131
172
./${{ inputs.env-name }}
132
173
133
174
- name : Upload Metadata Artifact
0 commit comments