Skip to content
Snippets Groups Projects
Commit b08379d9 authored by Ralf Jung's avatar Ralf Jung
Browse files

remove duplication in build-all script

parent 2da41848
No related branches found
No related tags found
No related merge requests found
...@@ -9,17 +9,23 @@ import requests ...@@ -9,17 +9,23 @@ import requests
# (default to default git branch). IRIS_REPO and STDPP_REPO can be used to take branches from forks. # (default to default git branch). IRIS_REPO and STDPP_REPO can be used to take branches from forks.
# Setting IRIS to "user:branch" will use the given branch on that user's fork of Iris, and similar for STDPP. # Setting IRIS to "user:branch" will use the given branch on that user's fork of Iris, and similar for STDPP.
# Pre-processing: we support setting `PROJECT` to `user:branch` (GitLab MR syntax), # Pre-processing for variables: you can set 'PROJECT' to 'user:branch',
# which will set `PROJECT_REPO` and `PROJECT_REV` automatically. # or set 'PROJECT_REPO' and 'PROJECT_REV' automatically.
def preprocess_repo_rev(var, project): PROJECT_VARS = ['STDPP', 'IRIS', 'ORC11', 'GPFSL']
GITLAB_VARS = []
for var in PROJECT_VARS:
if var in os.environ: if var in os.environ:
(repo, rev) = os.environ[var].split(':') (repo, rev) = os.environ[var].split(':')
os.environ[var+"_REPO"] = repo + "/" + project repo = repo + "/" + var.lower()
os.environ[var+"_REV"] = rev else:
preprocess_repo_rev('STDPP', 'stdpp') repo = os.environ.get(var+"_REPO")
preprocess_repo_rev('IRIS', 'iris') rev = os.environ.get(var+"_REV")
preprocess_repo_rev('ORC11', 'orc11') # Add them to GITLAB_VARS
preprocess_repo_rev('GPFSL', 'gpfsl') if repo is not None:
GITLAB_VARS.append({ 'key': var+"_REPO", 'value': repo })
if rev is not None:
GITLAB_VARS.append({ 'key': var+"_REV", 'value': rev })
# Check if everything is set # Check if everything is set
if not "GITLAB_TOKEN" in os.environ: if not "GITLAB_TOKEN" in os.environ:
...@@ -27,7 +33,7 @@ if not "GITLAB_TOKEN" in os.environ: ...@@ -27,7 +33,7 @@ if not "GITLAB_TOKEN" in os.environ:
print("You can create such tokens at <https://gitlab.mpi-sws.org/profile/personal_access_tokens>.") print("You can create such tokens at <https://gitlab.mpi-sws.org/profile/personal_access_tokens>.")
print("Make sure you grant access to the 'api' scope.") print("Make sure you grant access to the 'api' scope.")
sys.exit(1) sys.exit(1)
if not "IRIS_REV" in os.environ: if not "IRIS_REV" in os.environ and not "IRIS" in os.environ:
print("Please set IRIS_REV, STDPP_REV, ORC11_REV and GPFSL_REV environment variables to the branch/tag/commit of the respective project that you want to use.") print("Please set IRIS_REV, STDPP_REV, ORC11_REV and GPFSL_REV environment variables to the branch/tag/commit of the respective project that you want to use.")
print("Only IRIS_REV is mandatory, the rest defaults to the default git branch.") print("Only IRIS_REV is mandatory, the rest defaults to the default git branch.")
sys.exit(1) sys.exit(1)
...@@ -56,7 +62,7 @@ for project in PROJECTS: ...@@ -56,7 +62,7 @@ for project in PROJECTS:
url = "https://gitlab.mpi-sws.org/api/v4/projects/{}/pipeline".format(id) url = "https://gitlab.mpi-sws.org/api/v4/projects/{}/pipeline".format(id)
json = { json = {
'ref': project['branch'], 'ref': project['branch'],
'variables': [{ 'key': var, 'value': os.environ[var] } for var in VARS if var in os.environ], 'variables': GITLAB_VARS,
} }
r = requests.post(url, headers={'PRIVATE-TOKEN': GITLAB_TOKEN}, json=json) r = requests.post(url, headers={'PRIVATE-TOKEN': GITLAB_TOKEN}, json=json)
r.raise_for_status() r.raise_for_status()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment