Skip to content

Commit c347c2a

Browse files
committed
Send git attributes of vars.BUILD_DB_PACKAGES to generate-build-metadata.bash
1 parent c9905a6 commit c347c2a

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

.github/workflows/deploy-2-start.yml

+26-5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
outputs:
4444
packages-version: ${{ steps.versions.outputs.packages }}
4545
config-version: ${{ steps.versions.outputs.config }}
46+
build-db-packages-versions: ${{ steps.}}
4647
steps:
4748
# Deployment
4849
- uses: actions/checkout@v4
@@ -114,20 +115,40 @@ jobs:
114115
spack env activate ${{ inputs.env-name }}
115116
spack --debug install --fresh ${{ vars.SPACK_INSTALL_PARALLEL_JOBS }} || exit $?
116117
spack module tcl refresh -y
118+
EOT
117119
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
120+
- name: Get metadata from ${{ inputs.deployment-environment }}
121+
env:
122+
SPACK_ENV_PATH: ${{ steps.path.outputs.spack }}/var/spack/environments/${{ inputs.env-name }}
123+
run: |
124+
ssh ${{ secrets.USER}}@${{ secrets.HOST }} -i ${{ steps.ssh.outputs.private-key-path }} /bin/bash <<'EOT'
125+
spack find --paths > ${{ env.SPACK_ENV_PATH }}/spack.location
126+
spack find --format '{hash} {prefix}' | jq --raw-input --null-input '[inputs | split(" ") | {(.[0]): (.[1])}] | add' > ${{ env.SPACK_ENV_PATH }}/spack.location.json
127+
128+
# Get the repos associated with the packages for the build database
129+
jq -n '{}' > ${{ env.SPACK_ENV_PATH }}/build-db-pkgs.json
130+
for pkg in ${{ vars.BUILD_DB_PACKAGES }}; do
131+
# TODO: Is there a way to get the git attribute without concretizing?
132+
pkg_repo=$(spack python -c "import spack.spec; print(spack.spec.Spec('$pkg').concretized().package.git)")
133+
jq \
134+
--arg p "$pkg" \
135+
--arg r "$pkg_repo" \
136+
'. += {($p): ($r)}' \
137+
${{ env.SPACK_ENV_PATH }}/build-db-pkgs.json > ${{ env.SPACK_ENV_PATH }}/build-db-pkgs.json.tmp
138+
mv -f ${{ env.SPACK_ENV_PATH }}/build-db-pkgs.json.tmp ${{ env.SPACK_ENV_PATH }}/build-db-pkgs.json
139+
done
121140
122141
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
124142
EOT
125143
126144
# Release
127145
- name: Get Release Metadata
146+
env:
147+
# TODO: Can we put both envs above in a $GITHUB_ENV file instead?
148+
SPACK_ENV_PATH: ${{ steps.path.outputs.spack }}/var/spack/environments/${{ inputs.env-name }}
128149
run: |
129150
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.*' \
151+
'${{ secrets.USER}}@${{ secrets.HOST_DATA }}:${{ env.SPACK_ENV_PATH }}/spack.*' \
131152
./${{ inputs.env-name }}
132153
133154
- name: Upload Metadata Artifact

scripts/generate-build-metadata.bash

+9-1
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,22 @@ for pkg in "${packages[@]}"; do
7575
"$json_dir/spack.location.json"
7676
)
7777

78+
release_url=$(jq --raw-output \
79+
--arg pkg "$pkg" \
80+
'.[$pkg]' \
81+
"$json_dir/build-db-pkgs.json"
82+
)
83+
7884
component=$(jq \
7985
--arg pkg "$pkg" \
8086
--arg install_path "$install_path" \
87+
--arg release_url "$release_url" \
8188
'.concrete_specs | to_entries[] | select(.value.name == $pkg)
8289
| {
8390
spack_hash: .key,
8491
spec: (.value.name + "@" + .value.version),
85-
install_path: $install_path
92+
install_path: $install_path,
93+
release_url: $release_url
8694
}' "$json_dir/spack.lock"
8795
)
8896

0 commit comments

Comments
 (0)