Skip to content

Commit

Permalink
chore(green-coding-solutions#7): adjusted if conditions to resolve bo…
Browse files Browse the repository at this point in the history
…olean string result to numeric and compare it
  • Loading branch information
jreimone committed Apr 14, 2023
1 parent fa5e35b commit de4361c
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions .github/workflows/data-json-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ jobs:
if [ '${{ steps.data-node-setup.outputs.data-lap-json }}' == '' ]; then
echo "Output must not be empty"; exit 1;
fi
if ! [ $(echo '${{ steps.data-node-setup.outputs.data-lap-json }}' | jq 'has("repository", "branch", "workflow", "run_id", "label", "cpu_avg_percent", "energy_joules", "power_avg_watts") and length == 8') ]; then
echo "output has wrong structure"; exit 1;
if [ $(echo '${{ steps.data-node-setup.outputs.data-lap-json }}' | jq -e 'has("repository", "branch", "workflow", "run_id", "label", "cpu_avg_percent", "energy_joules", "power_avg_watts") | if . then 1 else 0 end') -eq 1 ]; then
echo "output has correct structure"
else
echo "output has wrong structure"
exit 1;
fi
if ! [ $(echo '${{ steps.data-node-setup.outputs.data-lap-json }}' | jq '.label == "node setup"') ]; then
echo "value of 'label' must be 'node setup'"; exit 1;
if [ $(echo '${{ steps.data-node-setup.outputs.data-lap-json }}' | jq -e '.label == "node setup" | if . then 1 else 0 end') -eq 1 ]; then
echo "value of 'label' is 'node setup'"
else
echo "value of 'label' must be 'node setup'"
exit 1
fi
- name: Wait before the next step
Expand All @@ -68,11 +74,17 @@ jobs:
if [ '${{ steps.data-sleep.outputs.data-lap-json }}' == '' ]; then
echo "Output must not be empty"; exit 1;
fi
if ! [ $(echo '${{ steps.data-sleep.outputs.data-lap-json }}' | jq 'has("repository", "branch", "workflow", "run_id", "label", "cpu_avg_percent", "energy_joules", "power_avg_watts") and length == 8') ]; then
echo "output has wrong structure"; exit 1;
if [ $(echo '${{ steps.data-sleep.outputs.data-lap-json }}' | jq -e 'has("repository", "branch", "workflow", "run_id", "label", "cpu_avg_percent", "energy_joules", "power_avg_watts") | if . then 1 else 0 end') -eq 1 ]; then
echo "output has correct structure"
else
echo "output has wrong structure"
exit 1;
fi
if ! [ $(echo '${{ steps.data-sleep.outputs.data-lap-json }}' | jq '.label == "sleep"') ]; then
echo "value of 'label' must be 'sleep'"; exit 1;
if [ $(echo '${{ steps.data-sleep.outputs.data-lap-json }}' | jq -e '.label == "sleep" | if . then 1 else 0 end') -eq 1 ]; then
echo "value of 'label' is 'sleep'"
else
echo "value of 'label' must be 'sleep'"
exit 1
fi
- name: Eco CI Energy Estimation
Expand All @@ -92,6 +104,9 @@ jobs:
if [ '${{ steps.data-total.outputs.data-total-json }}' == '' ]; then
echo "Output must not be empty"; exit 1;
fi
if ! [ $(echo '${{ steps.data-total.outputs.data-total-json }}' | jq 'has("repository", "branch", "workflow", "run_id", "label", "cpu_avg_percent", "energy_joules", "power_avg_watts") and length == 8') ]; then
echo "output has wrong structure"; exit 1;
if [ $(echo '${{ steps.data-total.outputs.data-total-json }}' | jq -e 'has("repository", "branch", "workflow", "run_id", "label", "cpu_avg_percent", "energy_joules", "power_avg_watts") | if . then 1 else 0 end') -eq 1 ]; then
echo "output has correct structure"
else
echo "output has wrong structure"
exit 1;
fi

0 comments on commit de4361c

Please sign in to comment.