-
Notifications
You must be signed in to change notification settings - Fork 20
222 lines (186 loc) · 6.55 KB
/
test.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
name: Test PR & Periodic
on:
pull_request:
paths-ignore:
- 'README.md'
- 'LICENSE'
- '.gitlab-ci.yml.example'
- '.gitignore'
schedule:
# only run once a week to show the action is working and preserve as much energy as possible
# Reason being that we pull our ML model and this could have changed in the meantime
- cron: '22 4 * * 6'
workflow_dispatch:
permissions:
contents: read
actions: read
pull-requests: write
jobs:
test-action:
runs-on: ${{ matrix.os }}
continue-on-error: false
strategy:
fail-fast: true
matrix:
os: [ubuntu-22.04, ubuntu-24.04, ubuntu-20.04, macos-13, macos-14]
steps:
- name: Install dependencies (macos only)
if: ${{ contains(matrix.os, 'macos') }}
run: |
brew install coreutils
echo "/opt/homebrew/opt/coreutils/libexec/gnubin:/usr/local/opt/coreutils/libexec/gnubin:$PATH" >> $GITHUB_PATH
- uses: actions/checkout@v4
with:
path: .
- name: API Base Debug
run: |
echo "Current API Base is" ${{ github.api_url }}
- name: Initialize Energy Estimation (Linux)
if: ${{ !contains(matrix.os, 'macos') }}
uses: ./
with:
task: start-measurement
project: "Eco-CI"
machine: "ubuntu-latest"
tags: "CI/CD,Test PR & Periodic-Workflow"
gmt-api-token: ${{ secrets.GMT_API_TOKEN }}
electricitymaps-api-token: ${{ secrets.ELECTRICITYMAPS_TOKEN }}
- name: Initialize Energy Estimation (macos-14)
if: ${{ contains(matrix.os, 'macos-14') }}
uses: ./
with:
task: start-measurement
project: "Eco-CI"
machine: "ubuntu-latest"
tags: "CI/CD,Test PR & Periodic-Workflow"
gmt-api-token: ${{ secrets.GMT_API_TOKEN }}
electricitymaps-api-token: ${{ secrets.ELECTRICITYMAPS_TOKEN }}
machine-power-data: "macos-14-mac-mini-m1.sh"
- name: Initialize Energy Estimation (macos-13)
if: ${{ contains(matrix.os, 'macos-13') }}
uses: ./
with:
task: start-measurement
project: "Eco-CI"
machine: "ubuntu-latest"
tags: "CI/CD,Test PR & Periodic-Workflow"
gmt-api-token: ${{ secrets.GMT_API_TOKEN }}
electricitymaps-api-token: ${{ secrets.ELECTRICITYMAPS_TOKEN }}
machine-power-data: "macos-13-mac-mini-intel.sh"
- name: Sleep step
run: sleep 2
- name: Dump ECO-CI CPU Step before
run: |
cat /tmp/eco-ci/cpu-util-step.txt
- name: Dump ECO-CI CPU before
run: |
cat /tmp/eco-ci/cpu-util-total.txt
- name: Test measurement 1
uses: ./
with:
task: get-measurement
label: "echo Hellos; $SHELL; \""
- name: Dump ECO-CI CPU Step actual processed
run: |
cat /tmp/eco-ci/cpu-util-temp.txt
- name: Dump ECO-CI Energy Step actual processed
run: |
cat /tmp/eco-ci/energy-step.txt
- name: Sleep 3
run: sleep 3
- name: Test measurement 2
uses: ./
with:
task: get-measurement
label: "(Soo this is something); & ; echo $SHELL"
- name: Sleep 3
run: sleep 3
- name: Test measurement 3
uses: ./
with:
task: get-measurement
label: 'Environment setup (OS ${{ matrix.os }}, lint)'
# - name: Sleep 3
# run: sleep 3
# There is currently no way of catching this IMHO
# - name: Test measurement 4
# uses: ./
# with:
# task: get-measurement
# label: without quotes'; echo
- name: Sleep 3
run: sleep 3
- name: Test measurement 5
uses: ./
with:
task: get-measurement
label: without quotes"; echo
# - name: Sleep 3
# run: sleep 3
# There is currently no way of catching this IMHO
# - name: Test measurement 6
# uses: ./
# with:
# task: get-measurement
# label: 'without quotes'''
- name: Dump ECO-CI CPU
run: |
cat /tmp/eco-ci/cpu-util-total.txt
- name: Dump ECO-CI Energy
run: |
cat /tmp/eco-ci/energy-total.txt
- name: Dump running processes
run: |
ps -ax | grep scripts
ps -ax | grep iostat
- name: Final
uses: ./
with:
task: get-measurement
- name: Eco CI Energy Estimation
uses: ./
with:
task: display-results
pr-comment: true
- name: Validate macOS energy values
if: ${{ contains(matrix.os, 'macos-14') }}
shell: bash
run: |
set -e
min=25
max=45
total_energy=$(awk '{sum+=$1} END {print int(sum+0.5)}' /tmp/eco-ci/energy-total.txt)
if [[ $total_energy -gt $min && $total_energy -lt $max ]]; then
echo "Energy value $total_energy is in the expected range [$min, $max]."
else # if total_energy is not int the check will fail silently. Thus else is our fallback
echo "Energy value $total_energy is outside the expected range or not an integer [$min, $max]."
exit 1
fi
- name: Validate macOS energy values
if: ${{ contains(matrix.os, 'macos-13') }}
shell: bash
run: |
set -e
min=50
max=90
total_energy=$(awk '{sum+=$1} END {print int(sum+0.5)}' /tmp/eco-ci/energy-total.txt)
if [[ $total_energy -gt $min && $total_energy -lt $max ]]; then
echo "Energy value $total_energy is in the expected range [$min, $max]."
else # if total_energy is not int the check will fail silently. Thus else is our fallback
echo "Energy value $total_energy is outside the expected range or not an integer [$min, $max]."
exit 1
fi
- name: Validate linux energy values
if: ${{ !contains(matrix.os, 'macos') }}
shell: bash
run: |
set -e
min=20
max=40
total_energy=$(awk '{sum+=$1} END {print int(sum+0.5)}' /tmp/eco-ci/energy-total.txt)
if [[ $total_energy -gt $min && $total_energy -lt $max ]]; then
echo "Energy value $total_energy is in the expected range [$min, $max]."
else # if total_energy is not int the check will fail silently. Thus else is our fallback
echo "Energy value $total_energy is outside the expected range or not an integer [$min, $max]."
exit 1
fi