Skip to content

Commit

Permalink
chore(green-coding-solutions#7): more precise output
Browse files Browse the repository at this point in the history
  • Loading branch information
jreimone committed Apr 14, 2023
1 parent b208a6c commit ba6a0db
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/data-json-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,22 @@ jobs:
fi
output='${{ steps.data-node-setup.outputs.data-lap-json }}'
required_fields=("repository" "branch" "workflow" "run_id" "label" "cpu_avg_percent" "energy_joules" "power_avg_watts")
fields_count=$(echo "$output" | jq 'keys | length')
if [ "${fields_count}" -eq 8 ]; then
else
echo "output has ${fields_count} instead of 8"
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
if [ $(echo '${{ steps.data-node-setup.outputs.data-lap-json }}' | jq -e '.label == "node setup" | if . then 1 else 0 end') -eq 1 ]; then
label=$(echo '${{ steps.data-node-setup.outputs.data-lap-json }}' | jq -r '.label')
if [ "$label" == "node setup" ]; then
echo "value of 'label' is 'node setup'"
else
echo "value of 'label' must be 'node setup'"
echo "value of 'label' is '$label', but it should be 'node setup'"
exit 1
fi
Expand Down

0 comments on commit ba6a0db

Please sign in to comment.