Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Spack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eic_tools
Spack
Commits
0b67f30e
Commit
0b67f30e
authored
6 years ago
by
Scott Wittenburg
Committed by
Todd Gamblin
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add pre-ci job generation for a multi-repo setup
parent
fabbb3d5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+10
-0
10 additions, 0 deletions
.gitlab-ci.yml
bin/generate-gitlab-ci-yml.sh
+93
-0
93 additions, 0 deletions
bin/generate-gitlab-ci-yml.sh
with
103 additions
and
0 deletions
.gitlab-ci.yml
0 → 100644
+
10
−
0
View file @
0b67f30e
generate ci jobs
:
script
:
-
"
./bin/generate-gitlab-ci-yml.sh"
tags
:
-
"
spack-k8s"
image
:
"
spack/ubuntu:18.04"
artifacts
:
paths
:
-
ci-generation
when
:
always
This diff is collapsed.
Click to expand it.
bin/generate-gitlab-ci-yml.sh
0 → 100755
+
93
−
0
View file @
0b67f30e
#! /usr/bin/env bash
# Remember where we are initially, it's the repo cloned by gitlab-ci
original_directory
=
$(
pwd
)
.
"
${
original_directory
}
/share/spack/setup-env.sh"
# Create a temporary working directory
temp_dir
=
$(
mktemp
-d
)
trap
'rm -rf "$temp_dir"'
INT TERM QUIT EXIT
if
[
-z
"
${
DOWNSTREAM_CI_REPO
}
"
]
;
then
echo
"ERROR: missing variable: DOWNSTREAM_CI_REPO"
>
&2
exit
1
fi
if
[
-z
"
${
SPACK_RELEASE_ENVIRONMENT_PATH
}
"
]
;
then
echo
"ERROR: missing variable: SPACK_RELEASE_ENVIRONMENT_PATH"
>
&2
exit
1
fi
if
[
-z
"
${
CDASH_AUTH_TOKEN
}
"
]
;
then
echo
"ERROR: missing variable: CDASH_AUTH_TOKEN"
>
&2
exit
1
fi
if
[
-z
"
${
SPACK_RELEASE_ENVIRONMENT_REPO
}
"
]
;
then
echo
"Assuming spack repo contains environment"
>
&2
env_repo_dir
=
${
original_directory
}
else
echo
"Cloning
${
SPACK_RELEASE_ENVIRONMENT_REPO
}
into
${
temp_dir
}
/envrepo"
>
&2
cd
${
temp_dir
}
git clone
${
SPACK_RELEASE_ENVIRONMENT_REPO
}
envrepo
cd
envrepo
env_repo_dir
=
$(
pwd
)
fi
current_branch
=
"
$CI_COMMIT_REF_NAME
"
# Because want to see generated gitlab-ci file as an artifact,
# we need to write it within the spack repo cloned by gitlab-ci.
gen_ci_dir
=
"
${
original_directory
}
/ci-generation"
gen_ci_file
=
"
${
gen_ci_dir
}
/.gitlab-ci.yml"
mkdir
-p
${
gen_ci_dir
}
env_dir
=
"
${
env_repo_dir
}
/
${
SPACK_RELEASE_ENVIRONMENT_PATH
}
"
if
[
!
-f
"
${
env_dir
}
/spack.yaml"
]
;
then
echo
"ERROR: Cannot find spack environment file in
${
env_dir
}
"
exit
1
fi
cd
$env_dir
token_file
=
"
${
temp_dir
}
/cdash_auth_token"
echo
${
CDASH_AUTH_TOKEN
}
>
${
token_file
}
# This commands generates the .gitlab-ci.yml and creates buildgroup in cdash
spack release-jobs
--force
--output-file
${
gen_ci_file
}
--cdash-credentials
${
token_file
}
if
[[
$?
-ne
0
]]
;
then
echo
"spack release-jobs command failed"
exit
1
fi
cp
${
gen_ci_file
}
"
${
original_directory
}
/.gitlab-ci.yml"
git config
--global
user.email
"robot@spack.io"
git config
--global
user.name
"Build Robot"
commit_msg
=
"Auto-generated commit testing
${
current_branch
}
(
${
CI_COMMIT_SHA
}
)"
cd
${
original_directory
}
echo
"git status"
git status
echo
"git branch"
git branch
-D
___multi_ci___ 2> /dev/null
||
true
echo
"git checkout"
git checkout
-b
___multi_ci___
echo
"git add"
git add .gitlab-ci.yml
echo
"git commit"
git commit
-m
"
$commit_msg
"
echo
"git commit-tree/reset"
# Prepare to send the whole working copy. Doing this instead should be faster
# until we decide to come up with a way of automatically keeping the downstream
# repo in sync with the main one, at which point just pushing a single, new
# commit with the change would be faster.
git reset
"
$(
git commit-tree HEAD^
{
tree
}
-m
${
commit_msg
}
)
"
echo
"git status"
git status
echo
"git push"
git push
--force
"
$DOWNSTREAM_CI_REPO
"
\
"___multi_ci___:multi-ci-
${
current_branch
}
"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment