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

[3.1] add a final job that passes if all tests pass making it easier to branch protect on checks #56

Merged
merged 3 commits into from
Aug 26, 2022

Conversation

spoonincode
Copy link
Member

Currently PRs can't be merged because they aren't satisfying branch protection rules. Turns out that a branch protection rule specifying, for example, "Tests" doesn't satisfy the matrix of tests such as "Tests (ubuntu18)", "Tests (ubuntu20)", etc

Making the branch protection rule specify all matrix'ed jobs is too brittle: the names of jobs will change overtime as we add and remove new tests, such as an upcoming test that checks the native contract unit tests.

Instead, let's create a final job in the workflow that only passes if all dependent jobs pass -- where all dependent jobs are all the test jobs. That way the branch protection rule can simply check that "All Required Tests Passed" passed and the workflow can evolve over time without needing to touch the branch protection rule.

@spoonincode spoonincode added the CICD Anything dealing with the CI workflow behavior label Aug 25, 2022

all-passing:
name: All Required Tests Passed
needs: [tests, lr-tests, np-tests]
Copy link
Member

Choose a reason for hiding this comment

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

Since lr-tests are not always run, does this work?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think so, because

A default status check of success() is applied

and success() is defined as

Returns true when none of the previous steps have failed or been canceled.

So lr-tests being skipped means it is neither failed nor cancelled.

Similarly, all-passing will be skipped if dependent jobs fail, and afaict the branch protection rule does require the test to pass -- skipped does not meet the requirement.

Copy link
Member Author

Choose a reason for hiding this comment

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

welp, I guess not 😂

Frustratingly I checked a simple workflow in a private repo beforehand but apparently some combination I didn't account for.

Copy link
Member

Choose a reason for hiding this comment

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

Lol, I noticed the test run and saw it passed, so approved it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Similarly, all-passing will be skipped if dependent jobs fail, and afaict the branch protection rule does require the test to pass -- skipped does not meet the requirement.

and bizarrely that seems false as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CICD Anything dealing with the CI workflow behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants