Skip to content

Commit 9dac54d

Browse files
author
Cameron Rutherford
authored
Merge branch 'develop' into cameron/spack-fixups
2 parents 43cc3e3 + aa2bc3e commit 9dac54d

21 files changed

+353
-250
lines changed

.github/workflows/pnnl_mirror.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ jobs:
2828
# Give actions access to some secrets
2929
with:
3030
GIT_PUSH_ARGS: '--tags --force --push-option=ci.skip'
31-
REMOTE: 'https://gitlab.pnnl.gov/exasgd/frameworks/exago-github-mirror'
31+
REMOTE: 'https://gitlab.pnnl.gov/earthshot-exago/exago-github-mirror'
3232
GIT_USERNAME: ${{ secrets.GIT_USER }}
3333
GIT_PASSWORD: ${{ secrets.GIT_PASSWORD }}
3434

3535
# Trigger CI pipeline since it was skipped in the above push
3636
- name: Trigger Pipeline
37-
run: curl -X POST -F token=${{ secrets.PNNL_PIPELINE_TRIGGER }} -F ref=${{ steps.extract_branch.outputs.branch }} https://gitlab.pnnl.gov/api/v4/projects/1619/trigger/pipeline
37+
run: curl -X POST -F token=${{ secrets.PNNL_PIPELINE_TRIGGER }} -F ref=${{ steps.extract_branch.outputs.branch }} https://gitlab.pnnl.gov/api/v4/projects/1719/trigger/pipeline

.gitlab/pnnl/.gitlab-ci.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ trigger_newell:
1212
- local: .gitlab/pnnl/base.gitlab-ci.yml
1313
- local: .gitlab/pnnl/newell.gitlab-ci.yml
1414

15-
trigger_incline:
16-
needs: []
17-
trigger:
18-
include:
19-
- local: .gitlab/pnnl/base.gitlab-ci.yml
20-
- local: .gitlab/pnnl/incline.gitlab-ci.yml
15+
# See - #132
16+
#trigger_incline:
17+
# needs: []
18+
# trigger:
19+
# include:
20+
# - local: .gitlab/pnnl/base.gitlab-ci.yml
21+
# - local: .gitlab/pnnl/incline.gitlab-ci.yml
2122

2223
SVC-Account-Cleanup:
2324
image: kfox1111/slurm:deception2

.gitlab/pnnl/README.md

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# How to connect GitHub to a PNNL GitLab (push) Mirror
2+
3+
To run on our HPC clusters at PNNL while hosting our code base on GitHub, we utilize PNNL's CI/CD services on GitLab.
4+
5+
With GitLab premium, integration between GitHub and GitLab is included. The tier of GitLab that we have does not and did not initially support this. While switching to premium would alleviate some of the burden here, our technical requirements expanded having to test on more than one cluster. This is how we have architected a solution with the base level GitLab offering.
6+
7+
The PNNL GitLab repository is a push mirror of the GitHub. So whenever a commit is pushed to a pull request or the `main` branch - the changes are pushed to the GitLab and a CI pipeline is triggered.
8+
9+
## Steps in linking the GitLab and GitHub
10+
11+
1. Push mirror & pipeline trigger
12+
13+
In [`pnnl_mirror.yaml`](/.github/workflows/pnnl_mirror.yaml), we use the variables `GIT_USER`, `GIT_PASSWORD`, and `PNNL_PIPELINE_TRIGGER`. `GIT_PASSWORD` and `PNNL_PIPELINE_TRIGGER` are generated in GitLab and then added to GitHub.
14+
15+
`GIT_USER` is the username of whoever will be authenticated when pushing to GitLab for the mirror action. Since we then manually trigger CI after that, and explicitly skip CI here, this name is cosmetic.
16+
17+
a) GIT_PASSWORD
18+
Go to Settings > Access Tokens. Click `Add new token`.
19+
20+
Pick a reasonable name & expiration date. (ie "GITHUB_PUSH_PASSWORD")
21+
22+
Pick the `Developer` role.
23+
24+
Under `Select scopes`, select `write_repository`.
25+
26+
Create.
27+
28+
Go to GitHub > Settings > Secrets and variables > Actions. Click `New repository secret`.
29+
Name it `GIT_PASSWORD` and paste in the value generated from GitLab.
30+
31+
Add secret.
32+
33+
b) PNNL_PIPELINE_TRIGGER
34+
Go to Settings > CI/CD > Pipeline trigger tokens. Click `Add new token`.
35+
36+
Give it a name and click create.
37+
38+
Go to GitHub > Settings > Secrets and variables > Actions. Click `New repository secret`.
39+
Name it `PNNL_PIPELINE_TRIGGER` and paste in the value generated from GitLab.
40+
41+
2. Push back status & modules
42+
43+
In our module rebuild pipelines, we rebuild spack modules on each PNNL platform, then commit the new module paths/hashes back to the repository.
44+
45+
a) Generate token #1 (`GITLAB_MIRROR_STATUS`)
46+
47+
Go to your GitHub profile > Settings > Developer Settings > Personal access tokens > Fine-grained tokens.
48+
49+
Generate new token:
50+
```
51+
resource owner = pnnl
52+
select repositories = pnnl/exago
53+
permissions > repository permissions > commit statuses (read and write)
54+
copy this token
55+
```
56+
57+
Go to GitLab > Settings > CI/CD > Variables:
58+
```
59+
add variable
60+
type = file
61+
do not protect/mask/expand
62+
key = GITHUB_CURL_HEADER
63+
Value = `Authorization: token <token value>`
64+
```
65+
66+
See https://ecp-ci.gitlab.io/docs/guides/build-status-gitlab.html for more details.
67+
68+
b) Generate token #2 (`GITLAB_COMMIT`)
69+
70+
Go to your GitHub profile > Settings > Developer Settings > Personal access tokens > Fine-grained tokens.
71+
72+
Generate new token:
73+
```
74+
resource owner = pnnl
75+
select repositories = pnnl/exago
76+
permissions > repository permissions > contents (read and write)
77+
<copy this token>
78+
```
79+
80+
Go to GitLab > Settings > CI/CD > Variables:
81+
```
82+
add variable
83+
type = variable
84+
do not protect
85+
key = SPACK_GIT_TOKEN
86+
<paste in value field>
87+
```
88+
89+
## Change path to `.gitlab-ci.yml`
90+
91+
Go to > Settings > CI/CD > General Pipelines, change the `CI/CD configuration file` to the correct path to `.gitlab-ci.yml`.
92+
93+
In our repo, the path is `.gitlab/pnnl/.gitlab-ci.yml`.

.gitlab/pnnl/base.gitlab-ci.yml

+29-29
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ include:
2121
if: '$CI_COMMIT_TITLE =~ /\[deception-rebuild\]/'
2222
when: never
2323
# Only run when the commit **DOES NOT** contains "[incline-rebuild]"
24-
- &rule_no_incline_rebuild
25-
if: '$CI_COMMIT_TITLE =~ /\[incline-rebuild\]/'
26-
when: never
24+
# - &rule_no_incline_rebuild
25+
# if: '$CI_COMMIT_TITLE =~ /\[incline-rebuild\]/'
26+
# when: never
2727
# Only run when the commit **DOES NOT** contains "[ascent-rebuild]"
2828
- &rule_no_ascent_rebuild
2929
if: '$CI_COMMIT_TITLE =~ /\[ascent-rebuild\]/'
@@ -45,13 +45,13 @@ include:
4545
if: '$CI_COMMIT_TITLE =~ /\[deception-test\]/'
4646
when: always
4747
# Only run when the commit **DOES NOT** contains "[incline-test]"
48-
- &rule_no_incline_test
49-
if: '$CI_COMMIT_TITLE =~ /\[incline-test\]/'
50-
when: never
48+
# - &rule_no_incline_test
49+
# if: '$CI_COMMIT_TITLE =~ /\[incline-test\]/'
50+
# when: never
5151
# Only run when the commit **DOES** contains "[incline-test]"
52-
- &rule_yes_incline_test
53-
if: '$CI_COMMIT_TITLE =~ /\[incline-test\]/'
54-
when: always
52+
# - &rule_yes_incline_test
53+
# if: '$CI_COMMIT_TITLE =~ /\[incline-test\]/'
54+
# when: always
5555
# Only run when the commit **DOES NOT** contains "[ascent-test]"
5656
- &rule_no_ascent_test
5757
if: '$CI_COMMIT_TITLE =~ /\[ascent-test\]/'
@@ -173,7 +173,7 @@ stages:
173173
174174
# jobid used in pnnl_after_script_template to cancel job if cancelled or
175175
# timed out by gitlab through the UI
176-
jobid=$(sbatch --export=ALL -A EXASGD $SLURM_ARGS -p $SLURM_Q -o $output -e $output -t 1:00:00 $WORKDIR/buildsystem/build.sh $SCRIPT_ARGS)
176+
jobid=$(sbatch --export=ALL -A earthshot $SLURM_ARGS -p $SLURM_Q -o $output -e $output -t 1:00:00 $WORKDIR/buildsystem/build.sh $SCRIPT_ARGS)
177177
export jobid=$(echo $jobid | cut -f4 -d' ')
178178
179179
partition=$(squeue -j $jobid -h --format="%P")
@@ -372,8 +372,8 @@ stages:
372372
- *rule_no_deception_rebuild
373373
- *rule_no_newell_test
374374
- *rule_no_newell_rebuild
375-
- *rule_no_incline_test
376-
- *rule_no_incline_rebuild
375+
# - *rule_no_incline_test
376+
# - *rule_no_incline_rebuild
377377
- *rule_no_ascent_test
378378
- *rule_no_ascent_rebuild
379379
- *default
@@ -389,8 +389,8 @@ stages:
389389
- *rule_no_deception_rebuild
390390
- *rule_yes_newell_test
391391
- *rule_no_newell_rebuild
392-
- *rule_no_incline_test
393-
- *rule_no_incline_rebuild
392+
# - *rule_no_incline_test
393+
# - *rule_no_incline_rebuild
394394
- *rule_no_ascent_test
395395
- *rule_no_ascent_rebuild
396396
- *default
@@ -399,18 +399,18 @@ stages:
399399
MY_CLUSTER: "newell"
400400
SLURM_ARGS: " --gres=gpu:1 --ntasks=3 "
401401

402-
.incline:
403-
rules:
404-
- *rule_no_deception_test
405-
- *rule_no_deception_rebuild
406-
- *rule_no_newell_test
407-
- *rule_no_newell_rebuild
408-
- *rule_yes_incline_test
409-
- *rule_no_incline_rebuild
410-
- *rule_no_ascent_test
411-
- *rule_no_ascent_rebuild
412-
- *default
413-
variables:
414-
WORKDIR_SUFFIX: "x86_64-clang-hip-build"
415-
MY_CLUSTER: "incline"
416-
SLURM_ARGS: " --exclusive --ntasks=3 "
402+
#.incline:
403+
# rules:
404+
# - *rule_no_deception_test
405+
# - *rule_no_deception_rebuild
406+
# - *rule_no_newell_test
407+
# - *rule_no_newell_rebuild
408+
# - *rule_yes_incline_test
409+
# - *rule_no_incline_rebuild
410+
# - *rule_no_ascent_test
411+
# - *rule_no_ascent_rebuild
412+
# - *default
413+
# variables:
414+
# WORKDIR_SUFFIX: "x86_64-clang-hip-build"
415+
# MY_CLUSTER: "incline"
416+
# SLURM_ARGS: " --exclusive --ntasks=3 "

buildsystem/spack/binary_mirror.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
source buildsystem/spack/load_spack.sh &&
44
SPACK_MIRROR="${SPACK_MIRROR:?SPACK_MIRROR is unset. Please use the load_spack script first.}" &&
5-
spack develop --path=$(pwd) exago@develop &&
6-
spack bootstrap now &&
7-
spack concretize -f &&
8-
(spack mirror create -a --directory $SPACK_MIRROR || true) &&
9-
spack mirror add local file://$SPACK_MIRROR &&
10-
spack mirror list
5+
spack -e $SPACKENV develop --path=$(pwd) exago@develop &&
6+
spack -e $SPACKENV bootstrap now &&
7+
spack -e $SPACKENV concretize -f &&
8+
spack -e $SPACKENV mirror create -a --exclude-specs exago@develop --directory $SPACK_MIRROR &&
9+
spack -e $SPACKENV mirror add local file://$SPACK_MIRROR &&
10+
spack -e $SPACKENV mirror list
1111

1212
res=$?
1313

buildsystem/spack/configure_modules.sh

+6-4
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ base="./buildsystem/spack/${MY_CLUSTER,,""""}"
1010
# Printing out loaded modules for debugging...
1111
module list
1212

13+
echo $SPACKENV
14+
1315
# This assumes that we are installing from a binary mirror, and don't want to fetch files
1416
# Make sure to use binary_mirror.sh if this is failing
15-
spack install -j $1 && \
17+
spack -e $SPACKENV install -j $1 && \
1618

1719
# This deletes the previous modules that are installed
1820
# Either use a different module path than other users, or deal with frequent updates
1921
# To use a different module path, you must update the variable $SPACK_MODULES
2022
# This is configured for the default for the branch in /buildsystem/spack/platform/env.sh
21-
spack module tcl refresh -y && \
23+
spack -e $SPACKENV module tcl refresh -y && \
2224

2325
# We will create a new modules file, with the first line being the module path
2426
mkdir -p $base/modules && \
@@ -35,10 +37,10 @@ echo module use -a $SPACK_INSTALL/$SPACK_MODULES/$arch &> $base/modules/dependen
3537
echo module use -a $SPACK_INSTALL/$SPACK_MODULES/$arch &> $base/modules/exago.sh && \
3638

3739
# Now we can append to the files
38-
spack module tcl loads -r -x exago -x openssl exago &>> $base/modules/dependencies.sh && \
40+
spack -e $SPACKENV module tcl loads -r -x exago -x openssl exago &>> $base/modules/dependencies.sh && \
3941
# spack module tcl loads -r -x exago -x openssl exago &>> $base/modules/optimized-dependencies.sh && \
4042
# spack module tcl loads exago &>> $base/modules/exago-optimized.sh && \
41-
spack module tcl loads exago &>> $base/modules/exago.sh
43+
spack -e $SPACKENV module tcl loads exago &>> $base/modules/exago.sh
4244

4345
exit_code=$?
4446

buildsystem/spack/deception/env.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module load openmpi/4.1.0mlx5.0
1919
# Define environment variables for where spack stores key files
2020
# For now, SPACK_INSTALL is the path where everything spack related is installed
2121
# If you want to modify the module install path, edit the spack.yaml manually
22-
BASE=/qfs/projects/exasgd/src/deception-ci
22+
BASE=/qfs/projects/earthshot/src/deception-ci
2323
export SPACK_INSTALL=$BASE/install
2424
export SPACK_MODULES=ci-modules
2525
export SPACK_CACHE=$BASE/../$(whoami)/spack-cache

0 commit comments

Comments
 (0)