-
Notifications
You must be signed in to change notification settings - Fork 17
/
eco-ci-gitlab.yml
44 lines (40 loc) · 2.16 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
variables:
ECO_CI_SEND_DATA: "true"
ECO_CI_DISPLAY_BADGE: "true"
ECO_CI_DISPLAY_TABLE: "true"
ECO_CI_SHOW_CARBON: "true"
ECO_CI_FILTER_TYPE: "machine.ci"
ECO_CI_FILTER_PROJECT: "CI/CD"
ECO_CI_FILTER_MACHINE: "saas-linux-small-amd64"
ECO_CI_FILTER_TAGS: ""
ECO_CI_JSON_OUTPUT: "false"
ECO_CI_CALCULATE_CO2: "true"
ECO_CI_CLONE_BRANCH: "main"
ECO_CI_MACHINE_POWER_DATA: "gitlab_EPYC_7B12_saas-linux-small-amd64.sh"
ECO_CI_API_ENDPOINT_ADD: "https://api.green-coding.io/v2/ci/measurement/add"
ECO_CI_API_BADGE_GET: "https://api.green-coding.io/v1/ci/badge/get"
ECO_CI_DASHBOARD_URL: "https://metrics.green-coding.io"
ECO_CI_GMT_API_TOKEN: ""
ECO_CI_ELECTRICITYMAPS_API_TOKEN: ""
.start_measurement:
script:
- |
echo 'running eco-ci start script'
if [[ -d /tmp/eco-ci ]]; then
rm -rf /tmp/eco-ci
fi
git clone --depth 1 --single-branch --branch "${ECO_CI_CLONE_BRANCH}" https://github.com/green-coding-solutions/eco-ci-energy-estimation /tmp/eco-ci-repo
/tmp/eco-ci-repo/scripts/setup.sh start_measurement "${ECO_CI_MACHINE_POWER_DATA}" "${CI_PIPELINE_ID}" "${CI_COMMIT_REF_NAME}" "${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}" "${CI_PROJECT_ID}" "gitlab-ci.yml" "${CI_COMMIT_SHA}" "gitlab" "${ECO_CI_SEND_DATA}" "${ECO_CI_FILTER_TYPE}" "${ECO_CI_FILTER_PROJECT}" "${ECO_CI_FILTER_MACHINE}" "${ECO_CI_FILTER_TAGS}" "${ECO_CI_CALCULATE_CO2}" "${ECO_CI_GMT_API_TOKEN}" "${ECO_CI_ELECTRICITYMAPS_API_TOKEN}" "${ECO_CI_JSON_OUTPUT}" "${ECO_CI_API_ENDPOINT_ADD}" "${ECO_CI_API_BADGE_GET}" "${ECO_CI_DASHBOARD_URL}"
.get_measurement:
script:
- echo 'running eco-ci measure script'
- |
/tmp/eco-ci-repo/scripts/make_measurement.sh make_measurement "${ECO_CI_LABEL}"
.display_results:
script:
- |
echo 'running eco-ci display script'
FORMAT_CLR="\e[44m" && TXT_CLEAR="\e[0m"
/tmp/eco-ci-repo/scripts/display_results.sh display_results "${ECO_CI_DISPLAY_TABLE}" "${ECO_CI_DISPLAY_BADGE}"
echo -e "$FORMAT_CLR$(cat /tmp/eco-ci/output.txt)$TXT_CLEAR"
cp /tmp/eco-ci/output.txt ./eco-ci-output.txt