From 93f7a6cfc229017b9c8e18300edc1a43076e36c0 Mon Sep 17 00:00:00 2001 From: Tommy Gatti Date: Tue, 27 Aug 2024 17:24:38 +1000 Subject: [PATCH] Send git attributes of vars.BUILD_DB_PACKAGES to generate-build-metadata.bash --- .github/workflows/deploy-2-start.yml | 30 +++++++++++++++++++++++----- scripts/generate-build-metadata.bash | 10 +++++++++- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy-2-start.yml b/.github/workflows/deploy-2-start.yml index 68f1f91..674d515 100644 --- a/.github/workflows/deploy-2-start.yml +++ b/.github/workflows/deploy-2-start.yml @@ -114,20 +114,40 @@ jobs: spack env activate ${{ inputs.env-name }} spack --debug install --fresh ${{ vars.SPACK_INSTALL_PARALLEL_JOBS }} || exit $? spack module tcl refresh -y + EOT - # Obtain metadata - spack find --paths > ${{ steps.path.outputs.spack }}/var/spack/environments/${{ inputs.env-name }}/spack.location - 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 + - name: Get metadata from ${{ inputs.deployment-environment }} + env: + SPACK_ENV_PATH: ${{ steps.path.outputs.spack }}/var/spack/environments/${{ inputs.env-name }} + run: | + ssh ${{ secrets.USER}}@${{ secrets.HOST }} -i ${{ steps.ssh.outputs.private-key-path }} /bin/bash <<'EOT' + spack find --paths > ${{ env.SPACK_ENV_PATH }}/spack.location + spack find --format '{hash} {prefix}' | jq --raw-input --null-input '[inputs | split(" ") | {(.[0]): (.[1])}] | add' > ${{ env.SPACK_ENV_PATH }}/spack.location.json + + # Get the repos associated with the packages for the build database + jq -n '{}' > ${{ env.SPACK_ENV_PATH }}/build-db-pkgs.json + for pkg in ${{ vars.BUILD_DB_PACKAGES }}; do + # TODO: Is there a way to get the git attribute without concretizing? + pkg_repo=$(spack python -c "import spack.spec; print(spack.spec.Spec('$pkg').concretized().package.git)") + jq \ + --arg p "$pkg" \ + --arg r "$pkg_repo" \ + '. += {($p): ($r)}' \ + ${{ env.SPACK_ENV_PATH }}/build-db-pkgs.json > ${{ env.SPACK_ENV_PATH }}/build-db-pkgs.json.tmp + mv -f ${{ env.SPACK_ENV_PATH }}/build-db-pkgs.json.tmp ${{ env.SPACK_ENV_PATH }}/build-db-pkgs.json + done spack env deactivate - 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 EOT # Release - name: Get Release Metadata + env: + # TODO: Can we put both envs above in a $GITHUB_ENV file instead? + SPACK_ENV_PATH: ${{ steps.path.outputs.spack }}/var/spack/environments/${{ inputs.env-name }} run: | rsync -e 'ssh -i ${{ steps.ssh.outputs.private-key-path }}' \ - '${{ secrets.USER}}@${{ secrets.HOST_DATA }}:${{ steps.path.outputs.spack }}/var/spack/environments/${{ inputs.env-name }}/spack.*' \ + '${{ secrets.USER}}@${{ secrets.HOST_DATA }}:${{ env.SPACK_ENV_PATH }}/spack.*' \ ./${{ inputs.env-name }} - name: Upload Metadata Artifact diff --git a/scripts/generate-build-metadata.bash b/scripts/generate-build-metadata.bash index e1db7ad..abfd68d 100755 --- a/scripts/generate-build-metadata.bash +++ b/scripts/generate-build-metadata.bash @@ -75,14 +75,22 @@ for pkg in "${packages[@]}"; do "$json_dir/spack.location.json" ) + release_url=$(jq --raw-output \ + --arg pkg "$pkg" \ + '.[$pkg]' \ + "$json_dir/build-db-pkgs.json" + ) + component=$(jq \ --arg pkg "$pkg" \ --arg install_path "$install_path" \ + --arg release_url "$release_url" \ '.concrete_specs | to_entries[] | select(.value.name == $pkg) | { spack_hash: .key, spec: (.value.name + "@" + .value.version), - install_path: $install_path + install_path: $install_path, + release_url: $release_url }' "$json_dir/spack.lock" )