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

[ci] check all-jobs-succeed depends on all jobs #720

Merged
merged 6 commits into from Dec 13, 2023

Conversation

tommy-gilligan
Copy link
Contributor

Potentially a new per-PR job could be added to CI without it being included in all-jobs-succeed's dependencies. This prevents that.

I have successfully constructed a failure (by deleting a job from all-jobs-succeed's dependencies)

Closes #444

Copy link

google-cla bot commented Dec 13, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Member

@joshlf joshlf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome, thanks for your work on this! One tiny nit on one of the comments, but otherwise this looks good!

Comment on lines 487 to 488
# Effectively, this checks that all-jobs-succeed does not depend on
# itself. Checking for the existence of a job that we don't want
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, it's slightly different than this - it checks that the set of jobs that all-jobs-succeeded does not depend on is exactly itself. That distinction is important because it also ensures that there are no jobs besides itself that it doesn't depend on. Do I understand that correctly? If so, could you update the comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You make perfect sense and this comment definitely should be updated. In updating the comment though, I found the language hard to get right. So I've eliminated this check. I think it makes it easier to understand with or without comments.

Comment on lines 491 to 498
if [ "$jobs" != "all-jobs-succeed" ]
then
exit 1
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh also: On failure, could you echo $jobs so that a developer can see from the Actions output what the offending jobs are?

Suggested change
if [ "$jobs" != "all-jobs-succeed" ]
then
exit 1
fi
if [ "$jobs" != "all-jobs-succeed" ]
then
missing_jobs="$(echo "$jobs" | tr ' ' '\n' | grep -v '^all-jobs-succeed$')"
echo "all-jobs-succeed missing dependencies on some jobs: $missing_jobs" | tee -a $GITHUB_STEP_SUMMARY
exit 1
fi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh! Sorry I did not see the code suggestion. I added my own message here.

This also changes the logic somewhat (hopefully in a way that improves
readability).  There was a bit of a self-check in place before that has been
removed because it made the code hard to explain (too many double negatives).
# The sed call here excludes all-jobs-succeed from the list of jobs that
# all-jobs-succeed does not depend on. If all-jobs-succeed does
# not depend on itself, we do not care about it.
done | sort | uniq | sed '/^all-jobs-succeed$/d'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO more developers are familiar with grep -v than with sed with the /d suffix. It's also easier to look up since you can just look up the -v flag in the grep manpage (I tried looking up the /d suffix in the sed manpage and wasn't sure how to search for it).

Suggested change
done | sort | uniq | sed '/^all-jobs-succeed$/d'
done | sort | uniq | grep -v '^all-jobs-succeed$'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only trouble here is grep exits with 1 in this case. This is easy enough to ignore though.

@joshlf joshlf added this pull request to the merge queue Dec 13, 2023
Merged via the queue into google:main with commit cb82d57 Dec 13, 2023
127 checks passed
@joshlf
Copy link
Member

joshlf commented Dec 13, 2023

Thanks again for your help with this, @tommy-gilligan!

@tommy-gilligan
Copy link
Contributor Author

No worries! Happy to help! Let me know if there's anything else you'd like me to look at.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Verify that all-jobs-succeeded CI job depends on all other jobs
2 participants