Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@

#[create-unique-path--]
variables:
SPACK_PARENT_DIR: ${CI_BUILDS_DIR}/llnl-stack-${CI_COMMIT_SHORT_SHA}
CARE_PATH: ${CI_BUILDS_DIR}/llnl-stack-${CI_COMMIT_SHORT_SHA}/care
REPO_PARENT_DIR: ${CI_BUILDS_DIR}/llnl-stack-${CI_COMMIT_SHORT_SHA}
SPACK_PATH: ${CI_BUILDS_DIR}/llnl-stack-${CI_COMMIT_SHORT_SHA}/spack
#[--create-unique-path]
CARE_REPO: https://github.com/LLNL/CARE
CARE_REF: develop
SPACK_REPO: https://github.com/spack/spack.git
SPACK_REF: develop
SPACK_REF: 1c92d832b6eefaf2cf1d053ff621ddd44de7606e
SPACK_DEBUG: "-d"
ENV_NAME: "radiuss"
ENV_NAME: "care"

# We only do one generation per stage because we found conflicts otherwise
#[one-generate-per-stage--]
stages:
- get-spack
- generate-quartz
- get-repos
#- concretize-test
#- generate-quartz
- generate-lassen
- build
- rm-spack
- rm-repos
#[--one-generate-per-stage]

.on-quartz:
Expand All @@ -31,21 +35,25 @@ stages:
.on-lassen:
tags: [shell, lassen]

#[get-spack--]
get-spack:
#[get-repos--]
get-repos:
extends: [.on-quartz]
stage: get-spack
stage: get-repos
script:
- export SPACK_PACKAGE_DIR=$SPACK_PATH/var/spack/repos/builtin/packages
- export CARE_PACKAGE_DIR=$CARE_PATH/scripts/spack_packages
- scripts/get-spack
#[--get-spack]
- scripts/get-care
- scripts/copy-care-packages
#[--get-repos]

#[rm-spack--]
rm-spack:
#[rm-repos--]
rm-repos:
extends: [.on-quartz]
stage: rm-spack
stage: rm-repos
script:
- scripts/remove-spack
#[--rm-spack]
- scripts/remove-repos
#[--rm-repos]

include:
- .gitlab/generate.yml
46 changes: 24 additions & 22 deletions .gitlab/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
rules:
- if: '$ENV_NAME == ""'
when: never
- if: '$CI_JOB_NAME == "rm-spack"'
- if: '$CI_JOB_NAME == "rm-repos"'
when: always
- when: on_success

Expand All @@ -26,35 +26,37 @@
.generate-pipeline:
script:
- . ${SPACK_PATH}/share/spack/setup-env.sh
- spack env activate spack-environments/${ENV_NAME}
- echo $_spack_share_dir
- cd spack-environments/${ENV_NAME}
- spack ${SPACK_DEBUG} env activate --without-view .
- spack ${SPACK_DEBUG} ci generate
--artifacts-root "${CI_PROJECT_DIR}/jobs_scratch_dir"
--output-file "${CI_PROJECT_DIR}/jobs_scratch_dir/pipeline.yml"
- cp -r spack-environments/${ENV_NAME}/${SYS_TYPE} ${CI_PROJECT_DIR}/jobs_scratch_dir/concrete_environment/
- cp -r ${SYS_TYPE} ${CI_PROJECT_DIR}/jobs_scratch_dir/concrete_environment/
artifacts:
paths:
- "${CI_PROJECT_DIR}/jobs_scratch_dir"

# quartz
generate-on-quartz:
extends: [.generate-pipeline, .on-quartz, .has_project_name]
stage: generate-quartz
before_script:
- scripts/print-variables
## quartz
#generate-on-quartz:
# extends: [.generate-pipeline, .on-quartz, .has_project_name]
# stage: generate-quartz
# before_script:
# - scripts/print-variables

#[send-variable-child--]
build-on-quartz:
extends: [.has_project_name]
stage: build
variables:
CHILD_SPACK_PATH: ${SPACK_PATH}
trigger:
include:
- artifact: "jobs_scratch_dir/pipeline.yml"
job: generate-on-quartz
strategy: depend
needs: [generate-on-quartz]
#[--send-variable-child]
##[send-variable-child--]
#build-on-quartz:
# extends: [.has_project_name]
# stage: build
# variables:
# CHILD_SPACK_PATH: ${SPACK_PATH}
# trigger:
# include:
# - artifact: "jobs_scratch_dir/pipeline.yml"
# job: generate-on-quartz
# strategy: depend
# needs: [generate-on-quartz]
##[--send-variable-child]

# lassen
generate-on-lassen:
Expand Down
35 changes: 35 additions & 0 deletions scripts/copy-care-packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

set -e

# Check necessary variables
care_package_dir=${CARE_PACKAGE_DIR:-""}
spack_package_dir=${SPACK_PACKAGE_DIR:-""}

usage() {
echo " $0 needs the CARE package directory"
echo " Use \$CARE_PACKAGE_DIR to specify it."
echo ""
echo " $0 needs a Spack package directory"
echo " Use \$SPACK_PACKAGE_DIR to specify it."
}

if [[ -z ${care_package_dir} || ! -d ${care_package_dir} ]]; then
echo "[ERROR] \$CARE_PACKAGE_DIR not defined or not a directory."
usage
else
echo "Using ${care_package_dir} as the CARE package directory."
fi

if [[ -z ${spack_package_dir} || ! -d ${spack_package_dir} ]]; then
echo "[ERROR] \$SPACK_PACKAGE_DIR not defined or not a directory."
usage
else
echo "Using ${spack_package_dir} as the SPACK package directory."
fi

DIRS=`ls ${care_package_dir}`
for dir in $DIRS; do
echo "Replace selected package file(s) for ${dir}"
cp -f ${care_package_dir}/${dir}/* ${spack_package_dir}/${dir}
done
71 changes: 71 additions & 0 deletions scripts/get-care
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash
#
# Required inputs are environment variables:
# - CARE_REF = a branch or hash
# - CARE_REPO = repository URL
# - CARE_PATH = repository clone destination

set -e

# Check necessary variables
care_ref=${CARE_REF:-""}
care_repo=${CARE_REPO:-""}
care_path=${CARE_PATH:-""}

usage() {
echo " $0 needs either a branch or a hash."
echo " Use \$CARE_REF to specify it."
echo ""
echo " $0 needs a repository url."
echo " Use \$CARE_REPO to specify it."
echo ""
echo " $0 needs a repository clone path."
echo " Use \$CARE_PATH to specify it."
}

if [[ -z ${care_ref} ]]; then
echo "[ERROR] No branch or hash are defined in \$CARE_REF."
usage
else
echo "[INFO] Using ${care_ref} as the branch or hash."
fi

if [[ -z ${care_repo} ]]; then
echo "[ERROR] No repository url defined in \$CARE_REPO."
usage
else
echo "[INFO] Using ${care_repo} as the repository URL."
fi

if [[ -z ${care_path} ]]; then
echo "[ERROR] No clone path defined in \$CARE_PATH."
usage
else
echo "[INFO] Using ${care_path} as the clone path."
fi

echo "[INFO] Calling scripts/get-repo from $PWD"
scripts/get-repo $care_repo $care_ref $care_path

##[get-care--]
## Create a new repo if not present, and prepare for fetch
#if [[ ! -d ${care_path} ]]
#then
# mkdir -p ${care_path}
# cd ${care_path}
# git init
# git remote add origin ${care_repo}
#fi
#
## Go to the repo.
#cd ${care_path}
#
## Fetch the reference.
#git fetch --depth 1 origin ${care_ref}
#
## Checkout the reference.
#git checkout FETCH_HEAD
#
## Tag the commit with current pipeline ID.
#git tag ${CI_PIPELINE_ID}
##[--get-care]
42 changes: 42 additions & 0 deletions scripts/get-repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

set -e

if [[ $# -ne 3 ]]; then
echo "[ERROR] $0 requires three command line arguments."
echo
echo "USAGE: $0 <repository-url> <repository-ref-or-hash> <clone-path>"
exit 1
else
echo "Using $1 as the repository url."
echo "Using $2 as the repository reference or branch."
echo "Using $3 as the clone path."
fi

# Check necessary variables
repo=$1
ref=$2
clone_path=$3

#[get-repo--]
# Create a new repo if not present, and prepare for fetch
if [[ ! -d ${clone_path} ]]
then
mkdir -p ${clone_path}
cd ${clone_path}
git init
git remote add origin ${repo}
fi

# Go to the repo.
cd ${clone_path}

# Fetch the reference.
git fetch --depth 1 origin ${ref}

# Checkout the reference.
git checkout FETCH_HEAD

# Tag the commit with current pipeline ID.
git tag ${CI_PIPELINE_ID}
#[--get-repo]
82 changes: 65 additions & 17 deletions scripts/get-spack
Original file line number Diff line number Diff line change
@@ -1,23 +1,71 @@
#!/bin/bash
#
# Required inputs are environment variables:
# - SPACK_REF = a branch or hash
# - SPACK_REPO = repository URL
# - SPACK_PATH = repository clone destination

set -e

#[get-spack--]
if [[ ! -d ${SPACK_PATH} ]]
then
mkdir -p ${SPACK_PATH}/..
# A shallow clone is enough, and much faster.
git clone ${SPACK_REPO} --depth 1 --branch ${SPACK_REF} ${SPACK_PATH}
# We tag the commit so we can retrieve which one was used by a given pipeline.
git tag ${CI_PIPELINE_ID}
# Check necessary variables
spack_ref=${SPACK_REF:-""}
spack_repo=${SPACK_REPO:-""}
spack_path=${SPACK_PATH:-""}

usage() {
echo " $0 needs either a branch or a hash."
echo " Use \$SPACK_REF to specify it."
echo ""
echo " $0 needs a repository url."
echo " Use \$SPACK_REPO to specify it."
echo ""
echo " $0 needs a repository clone path."
echo " Use \$SPACK_PATH to specify it."
}

if [[ -z ${spack_ref} ]]; then
echo "[ERROR] No branch or hash are defined in \$SPACK_REF."
usage
else
echo "[INFO] Using ${spack_ref} as the branch or hash."
fi

if [[ -z ${spack_repo} ]]; then
echo "[ERROR] No repository defined in \$SPACK_REPO."
usage
else
cd ${SPACK_PATH}
git checkout -b temp
git branch -D ${SPACK_REF}
git fetch --depth 1 ${SPACK_REPO} ${SPACK_REF}:${SPACK_REF}
git checkout ${SPACK_REF}
git tag ${CI_PIPELINE_ID}
git branch -D temp
cd -
echo "[INFO] Using ${spack_repo} as the repository."
fi
#[--get-spack]

if [[ -z ${spack_path} ]]; then
echo "[ERROR] No clone path defined in \$SPACK_PATH."
usage
else
echo "[INFO] Using ${spack_path} as the clone path."
fi

echo "[INFO] Calling scripts/get-repo from $PWD"
scripts/get-repo $spack_repo $spack_ref $spack_path

##[get-spack--]
## Create a new repo if not present, and prepare for fetch
#if [[ ! -d ${spack_path} ]]
#then
# mkdir -p ${spack_path}
# cd ${spack_path}
# git init
# git remote add origin ${spack_repo}
#fi
#
## Go to the repo.
#cd ${spack_path}
#
## Fetch the reference.
#git fetch --depth 1 origin ${spack_ref}
#
## Checkout the reference.
#git checkout FETCH_HEAD
#
## Tag the commit with current pipeline ID.
#git tag ${CI_PIPELINE_ID}
##[--get-spack]
12 changes: 12 additions & 0 deletions scripts/remove-repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -e

#[rm-repos--]
if [[ ! -d ${REPOS_PARENT_DIR} ]]
then
echo "Repos parent directory ($REPOS_PARENT_DIR) not found"
else
rm -rf ${REPOS_PARENT_DIR}
fi
#[--rm-repos]
Loading