Skip to content

Commit 6ce536a

Browse files
committed
ci: do not test frontier builds before support
1 parent 3036842 commit 6ce536a

File tree

4 files changed

+108
-60
lines changed

4 files changed

+108
-60
lines changed

.gitlab/config/dynamic_pipeline.yml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ child_pipeline_{branch}:
66
include:
77
- project: 'ci/ums029/dev/adios2'
88
ref: '{branch}'
9-
file: '.gitlab/gitlab-ci-crusher.yml'
9+
file: '.gitlab/gitlab-ci-frontier.yml'

.gitlab/config/generate_pipelines.py

Lines changed: 72 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
import time
1515
import re
1616
import urllib3
17+
import git
18+
import gitdb
19+
1720
# Remove annoying warning about insecure connection (self-signed cert).
1821
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
1922

@@ -35,7 +38,7 @@ def __call__(self, fn, *args, **kwargs):
3538

3639

3740
def http_get_request(*args, **kwargs):
38-
kwargs['verify'] = False
41+
kwargs["verify"] = False
3942
return requests.get(*args, **kwargs)
4043

4144

@@ -48,95 +51,124 @@ def request_as_list(url, *args, **kwargs):
4851

4952
header = response.headers
5053
current_url = None
51-
if 'link' in header:
54+
if "link" in header:
5255
links = re.search(
53-
r'(?<=\<)([\S]*)(?=>; rel="next")', header['link'], flags=re.IGNORECASE)
56+
r'(?<=\<)([\S]*)(?=>; rel="next")', header["link"], flags=re.IGNORECASE
57+
)
5458
if links is not None:
5559
current_url = links.group(0)
5660

5761
return body_json
5862

5963

6064
def add_timestamp(branch):
61-
date_str = branch['commit']['committed_date']
65+
date_str = branch["commit"]["committed_date"]
6266
# We ignore the TZ since Gitlab/GitHub always reports in UTC
63-
branch['dt'] = int(
64-
datetime.strptime(date_str.split(".")[0],
65-
'%Y-%m-%dT%H:%M:%S').timestamp())
67+
branch["dt"] = int(datetime.strptime(date_str.split(".")[0], "%Y-%m-%dT%H:%M:%S").timestamp())
6668
return branch
6769

6870

71+
def is_descendant_of_root(branch, root_commit, repo):
72+
if root_commit is None:
73+
return True
74+
try:
75+
commit_sha = branch["commit"]["id"]
76+
repo.commit(commit_sha)
77+
merge_base = repo.merge_base(args.root_commit, commit_sha)
78+
if len(merge_base) >= 1 and str(merge_base[0]) == args.root_commit:
79+
return True
80+
except gitdb.exc.BadObject:
81+
return False
82+
83+
6984
def is_recent(branch):
7085
deadline_sec = int(time.time()) - (args.days * 86400)
71-
return branch['dt'] > deadline_sec
86+
return branch["dt"] > deadline_sec
7287

7388

7489
def has_no_status(branch):
75-
gh_commit_sha = branch['commit']['id']
90+
gh_commit_sha = branch["commit"]["id"]
7691
# Backported branches use the merge head
77-
if re.fullmatch(r'^pr\d+_.*$', branch['name']):
78-
gh_commit_sha = branch['commit']['parent_ids'][1]
92+
if re.fullmatch(r"^pr\d+_.*$", branch["name"]):
93+
gh_commit_sha = branch["commit"]["parent_ids"][1]
7994

8095
# Query GitHub for the status of this commit
81-
response = http_get_request(
82-
gh_url + '/commits/' + gh_commit_sha + '/status')
83-
if int(response.headers['x-ratelimit-remaining']) <= 0:
96+
response = http_get_request(gh_url + "/commits/" + gh_commit_sha + "/status")
97+
if int(response.headers["x-ratelimit-remaining"]) <= 0:
8498
raise ConnectionError(response.json())
8599

86100
commit = response.json()
87-
if commit is None or 'sha' not in commit:
101+
if commit is None or "sha" not in commit:
88102
return False
89103

90-
for status in commit['statuses']:
91-
if status['context'] == args.gh_context:
104+
for status in commit["statuses"]:
105+
if status["context"] == args.gh_context:
92106
return False
93107

94108
return True
95109

96110

97111
parser = argparse.ArgumentParser(
98-
prog='generate_pipeline.py',
99-
description='Generate Dynamic pipelines for Gitlab')
112+
prog="generate_pipeline.py", description="Generate Dynamic pipelines for Gitlab"
113+
)
114+
parser.add_argument(
115+
"-u",
116+
"--gl-url",
117+
required=True,
118+
help="Base URL for Gitlab remote. Ex: https://code.olcf.ornl.gov/",
119+
)
100120
parser.add_argument(
101-
'-u', '--gl-url', required=True,
102-
help='Base URL for Gitlab remote. Ex: https://code.olcf.ornl.gov/')
121+
"-n", "--gh-name", required=True, help="Full name of the GitHub project. Ex: ornladios/ADIOS2"
122+
)
103123
parser.add_argument(
104-
'-n', '--gh-name', required=True,
105-
help='Full name of the GitHub project. Ex: ornladios/ADIOS2')
124+
"-p", "--project_id", required=True, help="Gitlab internal project ID of the project."
125+
)
106126
parser.add_argument(
107-
'-p', '--project_id', required=True,
108-
help='Gitlab internal project ID of the project.')
127+
"-c",
128+
"--gh-context",
129+
default="OLCF Frontier",
130+
help="Name of the status in GitHub (A.K.A context)",
131+
)
109132
parser.add_argument(
110-
'-c', '--gh-context', default='OLCF Crusher (Frontier)',
111-
help='Name of the status in GitHub (A.K.A context)')
133+
"-d", "--days", type=int, default=1, help="How many days back to search for commits"
134+
)
112135
parser.add_argument(
113-
'-d', '--days', type=int, default=1,
114-
help='How many days back to search for commits')
136+
"-m", "--max", type=int, default=2, help="Maximum amount of pipelines computed"
137+
)
115138
parser.add_argument(
116-
'-m', '--max', type=int, default=2,
117-
help='Maximum amount of pipelines computed')
139+
"-r",
140+
"--root-commit",
141+
default=None,
142+
type=str,
143+
help="Template file of the pipeline `{branch}` will be substituted",
144+
)
118145
parser.add_argument(
119-
'-f', '--template_file', required=True,
120-
help='Template file of the pipeline `{branch}` will be substituted')
146+
"-f",
147+
"--template_file",
148+
required=True,
149+
help="Template file of the pipeline `{branch}` will be substituted",
150+
)
121151
args = parser.parse_args()
122152

123153

124-
gl_url = args.gl_url + '/api/v4/projects/' + str(args.project_id)
125-
gh_url = 'https://api.github.com/repos/' + args.gh_name
154+
gl_url = args.gl_url + "/api/v4/projects/" + str(args.project_id)
155+
gh_url = "https://api.github.com/repos/" + args.gh_name
126156

127-
with open(args.template_file, 'r') as fd:
157+
with open(args.template_file, "r") as fd:
128158
template_str = fd.read()
129159

130-
branches = request_as_list(gl_url + '/repository/branches')
160+
repo = git.Repo(".", odbt=git.GitDB)
161+
162+
branches = request_as_list(gl_url + "/repository/branches")
163+
branches = [b for b in branches if is_descendant_of_root(b, args.root_commit, repo)]
131164
branches = [add_timestamp(branch) for branch in branches]
132165
branches = [b for b in branches if is_recent(b)]
133-
branches = sorted(branches, key=lambda x: x['dt'])
166+
branches = sorted(branches, key=lambda x: x["dt"])
134167

135168
# Skip running (and return true) has_no_status after returning True args.max times.
136169
# We need this not to hog the Github Rest API draconian ratelimit.
137170
run_n_times = skip_after_n_successes(default_value=False, n=args.max)
138171
branches = [b for b in branches if run_n_times(has_no_status, b)]
139172

140173
for branch in branches:
141-
print(template_str.format(
142-
branch=branch['name'], commit=branch['commit']['id']))
174+
print(template_str.format(branch=branch["name"], commit=branch["commit"]["id"]))

.gitlab/gitlab-ci-frontier.yml

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Ad-hoc build that runs in the ECP Hardware, concretely in OLCF Crusher.
1+
# Ad-hoc build that runs in the ECP Hardware, concretely in OLCF Frontier.
22

33
stages:
44
- pre
@@ -23,13 +23,17 @@ stages:
2323
ccache -s
2424

2525
.frontier-common:
26+
variables:
27+
CUSTOM_CI_BUILDS_DIR: "/lustre/orion/ums029/scratch/ums029_auser/ci/adios2/runtime"
28+
OLCF_SERVICE_ACCOUNT: "ums029_auser"
29+
30+
.frontier-cmake-common:
2631
rules:
2732
- if: $CI_PIPELINE_SOURCE =~ /parent_pipeline|web/
2833
interruptible: true
2934
variables:
3035
CCACHE_BASEDIR: "/lustre/orion/ums029/scratch/"
3136
CCACHE_DIR: "/lustre/orion/ums029/scratch/ums029_auser/ci/adios2/ccache"
32-
CUSTOM_CI_BUILDS_DIR: "/lustre/orion/ums029/scratch/ums029_auser/ci/adios2/runtime"
3337

3438
# -isystem= is not affected by CCACHE_BASEDIR, thus we must ignore it
3539
CCACHE_IGNOREOPTIONS: "-isystem=*"
@@ -42,9 +46,11 @@ stages:
4246

4347
# We do not want to use the user's ~/.gitconfig
4448
GIT_CONFIG_GLOBAL: "true"
45-
GITLAB_SITE: "OLCF Crusher"
49+
GITLAB_SITE: "OLCF Frontier"
4650
CI_BIN_DIR: "$CI_PROJECT_DIR/build"
47-
OLCF_SERVICE_ACCOUNT: "ums029_auser"
51+
52+
extends:
53+
.frontier-common
4854

4955
.setup-common:
5056
stage: setup
@@ -105,7 +111,7 @@ setup:frontier-kokkos-hip:
105111
-DKokkos_ENABLE_HIP_RELOCATABLE_DEVICE_CODE:BOOL=OFF
106112
-DKokkos_ENABLE_SERIAL:BOOL=ON
107113
extends:
108-
- .frontier-common
114+
- .frontier-cmake-common
109115
- .setup-common
110116
- .kokkos-hip-common
111117
before_script:
@@ -115,7 +121,7 @@ setup:frontier-kokkos-hip:
115121

116122
build:frontier-kokkos-hip:
117123
extends:
118-
- .frontier-common
124+
- .frontier-cmake-common
119125
- .build-common
120126
- .kokkos-hip-common
121127
before_script:
@@ -137,7 +143,7 @@ build:frontier-kokkos-hip:
137143
zstd
138144
DefApps
139145
extends:
140-
- .frontier-common
146+
- .frontier-cmake-common
141147

142148
setup:frontier-cray:
143149
extends:
@@ -157,10 +163,11 @@ build:frontier-cray:
157163
rules:
158164
- if: $CI_PIPELINE_SOURCE =~ /parent_pipeline|web/
159165
tags: [ shell ]
166+
extends:
167+
.frontier-common
160168
variables:
161169
STATUS_PROJECT: ornladios/ADIOS2
162-
STATUS_NAME: OLCF Crusher (Frontier)
163-
OLCF_SERVICE_ACCOUNT: "ums029_auser"
170+
STATUS_NAME: OLCF Frontier
164171
before_script: |
165172
git fetch
166173
source scripts/ci/gitlab-ci/setup-vars.sh
@@ -176,14 +183,12 @@ pending:
176183
stage: pre
177184
variables:
178185
STATUS_DESC: Pipeline is running
179-
OLCF_SERVICE_ACCOUNT: "ums029_auser"
180186
extends:
181187
- .report-status
182188
success:
183189
stage: post
184190
variables:
185191
STATUS_DESC: Pipeline succeeded
186-
OLCF_SERVICE_ACCOUNT: "ums029_auser"
187192
extends:
188193
- .report-status
189194
dependencies:
@@ -196,7 +201,6 @@ failure:
196201
when: on_failure
197202
variables:
198203
STATUS_DESC: Pipeline failed
199-
OLCF_SERVICE_ACCOUNT: "ums029_auser"
200204
extends:
201205
- .report-status
202206
dependencies:
@@ -205,25 +209,37 @@ failure:
205209

206210
generate_pipelines:
207211
stage: setup
212+
extends:
213+
.frontier-common
208214
tags: [frontier, shell]
209215
rules:
210216
- if: $CI_PIPELINE_SOURCE == "schedule"
211217
variables:
212-
CUSTOM_CI_BUILDS_DIR: "/lustre/orion/ums029/scratch/ums029_auser/ci/adios2/runtime"
213-
OLCF_SERVICE_ACCOUNT: "ums029_auser"
218+
GL_PROJECT_ID: 105
219+
# This the commit where the frontier CI was added, we want to avoid testing
220+
# commits before this.
221+
ROOT_COMMIT_SHA: 30368427fc41d57e428cdd15e7629dded2f71728
214222
script:
215-
- .gitlab/config/generate_pipelines.py -u "https://code.olcf.ornl.gov/" -p 105 -n ornladios/ADIOS2 -f .gitlab/config/dynamic_pipeline.yml.in > generated_pipelines.yml
223+
- pip install --user urllib3 requests GitPython
224+
- >
225+
.gitlab/config/generate_pipelines.py
226+
-u "https://code.olcf.ornl.gov/"
227+
-r "${ROOT_COMMIT_SHA}"
228+
-p "${GL_PROJECT_ID}"
229+
-n ornladios/ADIOS2
230+
-f .gitlab/config/dynamic_pipeline.yml.in
231+
> generated_pipelines.yml
232+
216233
artifacts:
217234
paths:
218235
- generated_pipelines.yml
219236

220237
launch_pipelines:
221238
stage: build
239+
extends:
240+
.frontier-common
222241
rules:
223242
- if: $CI_PIPELINE_SOURCE == "schedule"
224-
variables:
225-
CUSTOM_CI_BUILDS_DIR: "/lustre/orion/ums029/scratch/ums029_auser/ci/adios2/runtime"
226-
OLCF_SERVICE_ACCOUNT: "ums029_auser"
227243
trigger:
228244
include:
229245
- artifact: generated_pipelines.yml

scripts/ci/gitlab-ci/setup-vars.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ else
2222
export CI_BRANCH_REF="${DOWNSTREAM_BRANCH_REF}"
2323
fi
2424

25-
# In OLCF Crusher we must fix the build directory in the yml.
25+
# In OLCF Frontier we must fix the build directory in the yml.
2626
if [ -z "$CI_BIN_DIR" ]
2727
then
2828
export CI_BIN_DIR="${CI_ROOT_DIR}/${CI_BUILD_NAME}"

0 commit comments

Comments
 (0)