This repository has been archived by the owner on Jun 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
88 lines (83 loc) · 3.19 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
include:
- remote: 'https://gitlab.com/cscs-ci/recipes/-/raw/master/templates/v2/.cscs.yml'
stages:
- benchmark
- publish
variables:
UPLOAD_IMAGE: dropd/asv-upload-history:latest
BENCHMARK_IMAGE: dropd/asv-upload-history:latest
GITHUB_PATH: GridTools/cigrbench.git
.github_push_setup:
before_script:
# setting origin to github and enabling up push access
- mkdir -p ~/.ssh
- cp "$DEPLOY_PRIVATE_KEY" ~/.ssh/id_asv
- chmod 600 ~/.ssh/id_asv
- git config --global user.email $GITLAB_USER_EMAIL
- git config --global user.name $GITLAB_USER_NAME
- export GIT_SSH_COMMAND="ssh -i ~/.ssh/id_asv -o IdentitiesOnly=yes -o StrictHostKeyChecking=no"
- git remote set-url origin [email protected]:${GITHUB_PATH}
- git remote set-url --push origin [email protected]:${GITHUB_PATH}
- git fetch
benchmark:
extends: [".daint"]
image: $BENCHMARK_IMAGE
variables:
PULL_IMAGE: "YES"
SLURM_JOB_NUM_NODES: 1
SLURM_TIMELIMIT: 10
only:
- main
- trying
stage: benchmark
before_script:
# remove cached remote / branch if they exist
- git remote remove gh || echo "remote not initialized"
- git branch -D gh/history || echo "branch did not exist yet"
script:
# the daint runner sometimes fails to checkout the current commit, wtf?
- git checkout main
- git pull
# get or initialize the history branch from github
- mkdir -p $HOME # on sarus the home dir sometimes does not exist...
- cp ./daint-node.json $HOME/.asv-machine.json
- git remote add gh https://github.com/${GITHUB_PATH}
- git fetch gh history || git branch gh/history
# put history in current directory to add the current run to it
- git checkout gh/history .asv || echo "no history" # get the history if it exists
# install and run asv for benchmarks
- pip install asv virtualenv
- asv run --machine daint-compute-node --show-stderr --skip-existing
# store the results as artifact
- cp -r .asv/results $CI_PROJECT_DIR/results # artifacts must be in the project dir
artifacts:
when: always
paths:
- results/ # this will make the `results` folder available on the default work dir of the upload script
publish:
extends: [".github_push_setup"]
tags: ["kubernetes"]
image: $UPLOAD_IMAGE
only:
- main
- trying
stage: publish
needs:
- job: "benchmark"
artifacts: true
script:
# making sure gh-pages branch is up to date with github
- git checkout -b main
- git checkout gh-pages && git pull && git checkout -
- git checkout history || (git checkout -b history && mkdir -p .asv/results)
# getting results from artifacts & pushing to history
- mv results ~/results
- cp -r ~/results/* .asv/results/ # the `/*` on `results/*` is crucial to copy the contents not the dir as a whole
- git add -f .asv/results # -f because .asv is ignored by .gitignore
- git diff --cached --exit-code || (git commit -m "update history" && git push -u origin history)
# get back to the main branch and put the results back
- git checkout -
- git checkout history .asv
# intall and run asv to publish
- pip install asv virtualenv
- asv gh-pages # publish all results to github pages