try unsetting/resetting go111module instead, plus debug output #125
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test data output as json | |
on: | |
push: | |
workflow_dispatch: | |
jobs: | |
test-data-output-action: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Initialize Energy Estimation | |
uses: ./ | |
with: | |
task: start-measurement | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Node Setup Energy Measurment | |
id: data-node-setup | |
uses: ./ | |
with: | |
task: get-measurement | |
label: 'node setup' | |
send-data: false | |
- name: Print node setup data | |
run: | | |
echo "total json: ${{ steps.data-node-setup.outputs.data-lap-json }}" | |
- name: Assert node setup output is appropriate | |
shell: bash | |
run: | | |
# setup | |
output='${{ steps.data-node-setup.outputs.data-lap-json }}' | |
required_label="node setup" | |
required_fields=("repository" "branch" "workflow" "run_id" "label" "cpu_avg_percent" "energy_joules" "power_avg_watts") | |
required_count=${#required_fields[@]} | |
# assertions | |
if [ -z "$output" ]; then | |
echo "Output must not be empty" | |
exit 1 | |
fi | |
fields_count=$(echo "$output" | jq 'keys | length') | |
if ! [ "${fields_count}" -eq "${required_count}" ]; then | |
echo "output has ${fields_count} instead of ${required_count}" | |
exit 1 | |
fi | |
for field in "${required_fields[@]}"; do | |
if ! echo "$output" | jq -e --arg field "$field" 'has($field)' >/dev/null; then | |
echo "output is missing the field: $field" | |
exit 1 | |
fi | |
done | |
label=$(echo "$output" | jq -r '.label') | |
if [ "$label" == "$required_label" ]; then | |
echo "value of 'label' is '$required_label'" | |
else | |
echo "value of 'label' is '$label', but it should be '$required_label'" | |
exit 1 | |
fi | |
- name: Wait before the next step | |
run: sleep 10 | |
- name: Sleep measurement | |
id: data-sleep | |
uses: ./ | |
with: | |
task: get-measurement | |
label: "sleep" | |
send-data: false | |
- name: Print sleep data | |
run: | | |
echo "total json: ${{ steps.data-sleep.outputs.data-lap-json }}" | |
- name: Assert sleep output is appropriate | |
shell: bash | |
run: | | |
# setup | |
output='${{ steps.data-sleep.outputs.data-lap-json }}' | |
required_label="sleep" | |
required_fields=("repository" "branch" "workflow" "run_id" "label" "cpu_avg_percent" "energy_joules" "power_avg_watts") | |
required_count=${#required_fields[@]} | |
# assertions | |
if [ -z "$output" ]; then | |
echo "Output must not be empty" | |
exit 1 | |
fi | |
fields_count=$(echo "$output" | jq 'keys | length') | |
if ! [ "${fields_count}" -eq "${required_count}" ]; then | |
echo "output has ${fields_count} instead of ${required_count}" | |
exit 1 | |
fi | |
for field in "${required_fields[@]}"; do | |
if ! echo "$output" | jq -e --arg field "$field" 'has($field)' >/dev/null; then | |
echo "output is missing the field: $field" | |
exit 1 | |
fi | |
done | |
label=$(echo "$output" | jq -r '.label') | |
if [ "$label" == "$required_label" ]; then | |
echo "value of 'label' is '$required_label'" | |
else | |
echo "value of 'label' is '$label', but it should be '$required_label'" | |
exit 1 | |
fi | |
- name: Eco CI Energy Estimation | |
id: data-total | |
uses: ./ | |
with: | |
task: display-results | |
send-data: false | |
- name: Print total data | |
run: | | |
echo "total json: ${{ steps.data-total.outputs.data-total-json }}" | |
- name: Assert total output is appropriate | |
shell: bash | |
run: | | |
# setup | |
output='${{ steps.data-total.outputs.data-total-json }}' | |
required_label="TOTAL" | |
required_fields=("repository" "branch" "workflow" "run_id" "label" "cpu_avg_percent" "energy_joules" "power_avg_watts") | |
required_count=${#required_fields[@]} | |
# assertions | |
if [ -z "$output" ]; then | |
echo "Output must not be empty" | |
exit 1 | |
fi | |
fields_count=$(echo "$output" | jq 'keys | length') | |
if ! [ "${fields_count}" -eq "${required_count}" ]; then | |
echo "output has ${fields_count} instead of ${required_count}" | |
exit 1 | |
fi | |
for field in "${required_fields[@]}"; do | |
if ! echo "$output" | jq -e --arg field "$field" 'has($field)' >/dev/null; then | |
echo "output is missing the field: $field" | |
exit 1 | |
fi | |
done | |
label=$(echo "$output" | jq -r '.label') | |
if [ "$label" == "$required_label" ]; then | |
echo "value of 'label' is '$required_label'" | |
else | |
echo "value of 'label' is '$label', but it should be '$required_label'" | |
exit 1 | |
fi |