forked from green-coding-solutions/eco-ci-energy-estimation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheco-ci-gitlab.yml
62 lines (57 loc) · 2.08 KB
/
eco-ci-gitlab.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
cache:
paths:
- /tmp/eco-ci/venv/
variables:
ECO_CI_SEND_DATA: "true"
ECO_CI_DISPLAY_BADGE: "true" # true
ECO_CI_DISPLAY_TABLE: "true" # true
ECO_CI_DISPLAY_GRAPH: "false" # false
.initialize_energy_estimator:
script:
- |
apt-get update
apt-get install git python3.10 python3.10-venv gcc bc jq curl golang-go psmisc -y
if [[ -d /tmp/eco-ci ]]; then
rm -rf /tmp/eco-ci
fi
git clone --depth 1 --single-branch --branch main https://github.com/green-coding-berlin/eco-ci-energy-estimation /tmp/eco-ci/main
/tmp/eco-ci/main/scripts/setup.sh initialize -r false -g false
/tmp/eco-ci/main/scripts/setup.sh setup_python
.start_measurement:
script:
- |
echo 'running eco-ci start script'
/tmp/eco-ci/main/scripts/vars.sh add_var "WORKFLOW_ID" $CI_PROJECT_ID
/tmp/eco-ci/main/scripts/setup.sh start_measurement
.get_measurement:
script:
- echo 'running eco-ci measure script'
- |
repo=$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME
/tmp/eco-ci/main/scripts/make_measurement.sh \
-l "$ECO_CI_LABEL" \
-r $CI_PIPELINE_ID \
-b $CI_COMMIT_REF_NAME \
-R $repo \
-c $CI_COMMIT_SHA \
-sd $ECO_CI_SEND_DATA \
-s "gitlab" \
-n "gitlab-ci.yml" \
.display_results:
script:
- echo 'running eco-ci display script'
- |
set -x
FORMAT_CLR="\e[44m" && TXT_CLEAR="\e[0m"
repo=$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME
/tmp/eco-ci/main/scripts/display_results.sh \
-b $CI_COMMIT_REF_NAME \
-db $ECO_CI_DISPLAY_BADGE \
-r $CI_PIPELINE_ID \
-R $repo \
-dt $ECO_CI_DISPLAY_TABLE \
-dg $ECO_CI_DISPLAY_GRAPH \
-sd $ECO_CI_SEND_DATA \
-s "gitlab" \
- echo -e "$FORMAT_CLR$(cat /tmp/eco-ci/output.txt)$TXT_CLEAR"
- cp /tmp/eco-ci/output.txt ./eco-ci-output.txt