Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gate SRU with clear warning in the description (Infra) #1380

Merged
merged 12 commits into from
Aug 7, 2024
16 changes: 16 additions & 0 deletions .github/workflows/pr_validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,19 @@ jobs:
echo
echo
echo "Difference of com.canonical.certification::sru-server (diff this_branch main)"
# the following line sorts the array of jobs/templates obtained from the pre/post checkout
# this is done because we want compare the list/content of jobs but not necessarely the order
# that for most jobs is not deterministic either way. The array keys are sorted as well
# as what counts is the content of each key (id, environ, command) and not the order
# the exporter prints them out
Hook25 marked this conversation as resolved.
Show resolved Hide resolved
# Taken partially from: https://github.com/jqlang/jq/issues/893
diff \
<(jq -S 'def post_recurse(f): def r: (f | select(. != null) | r), .; r; def post_recurse: post_recurse(.[]?); (. | (post_recurse | arrays) |= sort)' "sru_server_testplan_this_branch.json") \
Hook25 marked this conversation as resolved.
Show resolved Hide resolved
<(jq -S 'def post_recurse(f): def r: (f | select(. != null) | r), .; r; def post_recurse: post_recurse(.[]?); (. | (post_recurse | arrays) |= sort)' "sru_server_testplan_main.json") | tee sru_server_diff.txt

if [ -s sru_server_diff.txt ]; then
# if the sru_server_diff file is not empty, there is at least one diff (patch) done to it
# require the PR description to contain the bold text highlighting it
if [[ "$DESCRIPTION" == *"## WARNING: This modifies com.canonical.certification::sru-server"* ]]; then
echo "Warning is correcty posted in the description for sru-server"
else
Expand All @@ -82,11 +90,19 @@ jobs:
fi

echo "Difference of com.canonical.certification::sru (diff this_branch main)"
# the following line sorts the array of jobs/templates obtained from the pre/post checkout
# this is done because we want compare the list/content of jobs but not necessarely the order
# that for most jobs is not deterministic either way. The array keys are sorted as well
# as what counts is the content of each key (id, environ, command) and not the order
# the exporter prints them out
# Taken partially from: https://github.com/jqlang/jq/issues/893
diff \
<(jq -S 'def post_recurse(f): def r: (f | select(. != null) | r), .; r; def post_recurse: post_recurse(.[]?); (. | (post_recurse | arrays) |= sort)' "sru_testplan_this_branch.json") \
<(jq -S 'def post_recurse(f): def r: (f | select(. != null) | r), .; r; def post_recurse: post_recurse(.[]?); (. | (post_recurse | arrays) |= sort)' "sru_testplan_main.json") | tee sru_diff.txt

if [ -s sru_diff.txt ]; then
# if the sru_server_diff file is not empty, there is at least one diff (patch) done to it
# require the PR description to contain the bold text highlighting it
if [[ "$DESCRIPTION" == *"## WARNING: This modifies com.canonical.certification::sru"* ]]; then
echo "Warning is correcty posted in the description for sru"
else
Expand Down