-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test environment package * update readme Signed-off-by: vsoch <vsoch@users.noreply.github.com> Co-authored-by: vsoch <vsoch@users.noreply.github.com>
- Loading branch information
Showing
6 changed files
with
328 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
name: "Spack Binary Release Action" | ||
description: "Build and release a package.py in a source repository with spack." | ||
inputs: | ||
spack_yaml: | ||
description: A spack yaml to install and add to the build cache | ||
required: true | ||
repos: | ||
description: comma separated list of additional repos to clone and add | ||
required: false | ||
branch: | ||
description: Spack branch to clone | ||
required: false | ||
default: develop | ||
release: | ||
description: A spack release to use (if defined, overrides branch) | ||
required: false | ||
default: "" | ||
token: | ||
description: A GitHub token required if releasing artifacts to the same repository | ||
required: true | ||
flags: | ||
description: Extra flags (compiler, target, variants, etc) to add to the install command | ||
required: false | ||
tag: | ||
description: Tag to use for package (defaults to latest) | ||
required: false | ||
deploy: | ||
description: Deploy (release) package to GitHub repository (token is required) | ||
required: true | ||
default: false | ||
|
||
outputs: | ||
package_name: | ||
description: "package name uploaded to" | ||
value: ${{ steps.release.outputs.package_name }} | ||
package_tagged_name: | ||
description: "package name with custom tag uploaded to" | ||
value: ${{ steps.release.outputs.package_name }} | ||
package_tag: | ||
description: "package tag (along with latest)" | ||
value: ${{ steps.release.outputs.package_tag }} | ||
package_content_type: | ||
description: "the package content type" | ||
value: ${{ steps.release.outputs.content_type }} | ||
spec_jsons: | ||
description: "comma separately list of json files in the cache to describe the entry." | ||
value: ${{ steps.build.outputs.spec_jsons }} | ||
build_cache: | ||
description: "Build cache path (dated YY.MM)" | ||
value: ${{ steps.build.outputs.build_cache }} | ||
build_cache_prefix: | ||
description: Prefix of spack build cache (directory above build_cache) | ||
value: ${{ steps.build.outputs.build_cache_prefix }} | ||
spec: | ||
description: "Spec used for build" | ||
value: ${{ steps.build.outputs.spec }} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Set Root Directory | ||
env: | ||
ACTION_PATH: ${{ github.action_path }} | ||
run: ${{ github.action_path }}/scripts/set_root.sh | ||
shell: bash | ||
|
||
- name: Install Spack and Dependencies | ||
env: | ||
INPUT_SPACK_BRANCH: ${{ inputs.branch }} | ||
INPUT_RELEASE: ${{ inputs.release }} | ||
INPUT_REPOS: ${{ inputs.repos }} | ||
INPUT_SPACK_ROOT: /opt/spack | ||
run: ${{ env.ACTION_ROOT }}/install/scripts/install.sh | ||
shell: bash | ||
|
||
- name: Build Packages | ||
id: build | ||
env: | ||
INPUT_SPACK_YAML: ${{ inputs.spack_yaml }} | ||
INPUT_FLAGS: ${{ inputs.flags }} | ||
ACTION_ROOT: ${{ github.action_path }} | ||
run: ${{ github.action_path }}/scripts/build.sh | ||
shell: bash | ||
|
||
- name: Package Release | ||
id: release | ||
env: | ||
INPUT_PACKAGE_NAME: ${{ inputs.package }} | ||
GITHUB_TOKEN: ${{ inputs.token }} | ||
GITHUB_ACTOR: ${{ github.actor }} | ||
INPUT_TAG: ${{ inputs.tag }} | ||
BUILD_CACHE_PREFIX: ${{ env.build_cache_prefix }} | ||
BUILD_CACHE: ${{ env.build_cache }} | ||
SPACK_ROOT: /opt/spack | ||
DEPLOY: ${{ inputs.deploy }} | ||
run: ${{ github.action_path }}/scripts/release.sh | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
echo $PWD | ||
ls | ||
|
||
|
||
# Setup the spack environment | ||
. /opt/spack/share/spack/setup-env.sh | ||
|
||
# The spack yaml must exist | ||
if [ ! -f "${INPUT_SPACK_YAML}" ]; then | ||
printf "${INPUT_SPACK_YAML} does not exist\n" | ||
exit | ||
fi | ||
|
||
# Show user all variables for debugging | ||
printf "spack_yaml: ${INPUT_SPACK_YAML}\n" | ||
printf "flags: ${INPUT_FLAGS}\n" | ||
printf "spec: ${SPACK_SPEC}\n" | ||
|
||
# Do we want a custom compiler / variants? | ||
if [ ! -z ${INPUT_FLAGS} ]; then | ||
SPACK_SPEC="$SPACK_SPEC ${INPUT_FLAGS}" | ||
fi | ||
|
||
# Create the spack environment | ||
envdirname=$(dirname ${INPUT_SPACK_YAML}) | ||
cd $envdirname | ||
|
||
# And install packages to it | ||
spack env create -d . | ||
spack env activate . | ||
spack install | ||
|
||
# After install, create and add to build cache. | ||
# We want the directory to be the YEAR.MONTH (21.05) | ||
month=$(date '+%y.%m') | ||
build_cache=/opt/${month} | ||
mkdir -p $build_cache | ||
|
||
# Add the key, stored with buildcache action (we need to do both these things?) | ||
root=$(dirname ${ACTION_ROOT}) | ||
spack gpg trust ${root}/buildcache/4A424030614ADE118389C2FD27BDB3E5F0331921.pub | ||
spack gpg init | ||
spack gpg create "${GITHUB_ACTOR}" "${GITHUB_ACTOR}@users.noreply.github.com" | ||
|
||
# Install packages. If needed, we can add a variable to customize the string here | ||
spack buildcache create -a -d ${build_cache} $(spack find --format "{name}/{hash}") | ||
|
||
# Did we make stuff? | ||
tree ${build_cache} | ||
|
||
# We want to save the .json files for any following step :) | ||
spec_jsons="" | ||
|
||
echo "::set-output name=build_cache::${build_cache}" | ||
echo "::set-output name=build_cache_prefix::${build_cache_prefix}" | ||
|
||
# There can be more than one thing in the build cache | ||
for spec_json in $(find ${build_cache} -name *.json); do | ||
printf "${spec_json}\n" | ||
cat ${spec_json} | ||
if [[ "${spec_jsons}" == "" ]]; then | ||
spec_jsons=${spec_json} | ||
else | ||
spec_jsons="${spec_jsons},${spec_json}" | ||
fi | ||
done | ||
|
||
# Set output for spec, and TODO binary to upload/save for next step | ||
echo "::set-output name=spec::${SPACK_SPEC}" | ||
echo "::set-output name=spec_jsons::${spec_jsons}" | ||
echo "spec=${SPACK_SPEC}" >> $GITHUB_ENV | ||
echo "spec_jsons=${spec_jsons}" >> $GITHUB_ENV | ||
echo "build_cache=${build_cache}" >> $GITHUB_ENV | ||
echo "build_cache_prefix=${month}/build_cache" >> $GITHUB_ENV |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
echo $PWD | ||
ls | ||
|
||
printf "build cache prefix: ${BUILD_CACHE_PREFIX}" | ||
printf "build cache: ${BUILD_CACHE}" | ||
printf "package: ${INPUT_PACKAGE_NAME}\n" | ||
printf "actor: ${GITHUB_ACTOR}\n" | ||
printf "tag: ${INPUT_TAG}\n" | ||
printf "deploy: ${DEPLOY}\n" | ||
|
||
# Setup the spack environment | ||
. "${SPACK_ROOT}/share/spack/setup-env.sh" | ||
|
||
# Install oras | ||
curl -LO https://github.com/oras-project/oras/releases/download/v0.12.0/oras_0.12.0_linux_amd64.tar.gz | ||
mkdir -p oras-install/ | ||
tar -zxf oras_0.12.0_*.tar.gz -C oras-install/ | ||
mv oras-install/oras /usr/local/bin/ | ||
rm -rf oras_0.12.0_*.tar.gz oras-install/ | ||
|
||
# Login to GitHub packages | ||
if [ "${DEPLOY}" == "true" ]; then | ||
echo ${GITHUB_TOKEN} | oras login -u ${GITHUB_ACTOR} --password-stdin ghcr.io | ||
fi | ||
|
||
# Do we have a tag? | ||
if [ -z "${INPUT_TAG}" ]; then | ||
INPUT_TAG=${GITHUB_SHA:0:8} | ||
fi | ||
|
||
# Package content type is always consistent | ||
package_content_type=application/vnd.spack.package | ||
echo "::set-output name=package_content_type::${package_content_type}" | ||
echo "package_content_type=${package_content_type}" >> $GITHUB_ENV | ||
|
||
# As is common input tag | ||
echo "::set-output name=package_tag::${INPUT_TAG}" | ||
echo "package_tag=${INPUT_TAG}" >> $GITHUB_ENV | ||
|
||
# Keep lists of package names, tagged, names | ||
tagged_names="" | ||
package_names="" | ||
|
||
# The package name must include the package and hash, etc. | ||
# linux-ubuntu20.04-broadwell-gcc-10.3.0-zlib-1.2.11-5vlodp7yawk5elx4dfhnpzmpg743fwv3.spack | ||
for spack_package in $(find ${BUILD_CACHE} -name *.spack); do | ||
|
||
spack_package_name=$(basename $spack_package) | ||
package_name="${build_cache_prefix}/${spack_package_name}" | ||
|
||
# Absolute paths not allowed | ||
mv ${spack_package} ${spack_package_name} | ||
|
||
package_full_name=ghcr.io/${GITHUB_REPOSITORY}/${package_name}:latest | ||
package_tagged_name=ghcr.io/${GITHUB_REPOSITORY}/${package_name}:${INPUT_TAG} | ||
|
||
# Add to listing, comma separated | ||
if [ "${tagged_names}" == "" ]; then | ||
tagged_names="${package_tagged_name}" | ||
package_names="${package_full_name}" | ||
else | ||
tagged_names="${tagged_names},${package_tagged_name}" | ||
package_names="${package_names},${package_full_name}" | ||
fi | ||
|
||
# Push for latest | ||
if [ "${DEPLOY}" == "true" ]; then | ||
printf "oras push ${package_full_name} --manifest-config /dev/null:${package_content_type} ${spack_package_name}\n" | ||
oras push ${package_full_name} --manifest-config /dev/null:${package_content_type} ${spack_package_name} | ||
|
||
# And custom tag (which will default to GITHUB_SHA) | ||
printf "oras push ${package_tagged_name} --manifest-config /dev/null:${package_content_type} ${spack_package_name}\n" | ||
oras push ${package_tagged_name} --manifest-config /dev/null:${package_content_type} ${spack_package_name} | ||
fi | ||
done | ||
|
||
echo "::set-output name=package_name::${package_names}" | ||
echo "::set-output name=package_tagged_names::${tagged_names}" | ||
echo "package_names=${package_names}" >> $GITHUB_ENV | ||
echo "package_tagged_names=${tagged_names}" >> $GITHUB_ENV |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
echo $PWD | ||
ls | ||
|
||
ACTION_ROOT=$(dirname $ACTION_PATH) | ||
printf "ACTION_ROOT is ${ACTION_ROOT}\n" | ||
ls ${ACTION_ROOT} | ||
echo "ACTION_ROOT=${ACTION_ROOT}" >> $GITHUB_ENV |