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: make required checks passed if skipped #37

Merged
merged 2 commits into from
Aug 8, 2024
Merged

Conversation

sripwoud
Copy link
Member

@sripwoud sripwoud commented Aug 8, 2024

Fix #22

A limitation of GitHub actions is that ci jobs that used as checks required to allow a PR to merge, are always required, even if they were skipped.
In the case they were skipped...well the ci check isn't passed, not allowing a valid PR to merge.

A workaround is to use ${{ !(failure() || cancelled()) }} as a condition, meaning: if the dependents jobs didn't fail or weren't cancelled, execute (especially: if dependents jobs were skipped, execute).
This can be used as an if condition in a dummy job that will always be executed and successful, unless the dependents jobs failed or were cancelled. Which is what we want.

The workflow diagram illustrates well what is going on:
image

This PR does not affect any sol files, so the _tests and _slither matrix jobs are all skipped.
However tests and slither which depends on _tests and _slither respectively and are used as ci required checks, are still executed and pass, allowing the PR to merge.

This will speed up even more the CI, and avoid ci checks being a stuck with waiting for status to be reported state.

@sripwoud sripwoud requested a review from cedoor as a code owner August 8, 2024 07:10
@sripwoud sripwoud added the devops 🔧 Operations management and dev tools label Aug 8, 2024
@sripwoud sripwoud self-assigned this Aug 8, 2024
@sripwoud sripwoud marked this pull request as draft August 8, 2024 07:11
@sripwoud sripwoud added the bug 🐛 Something isn't working label Aug 8, 2024
name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel: true
flag-name: run ${{ join(matrix.*, '-') }}

test:
Copy link
Member Author

Choose a reason for hiding this comment

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

dummy job to wrap _tests

@@ -194,3 +207,11 @@ jobs:
const header = '# Slither report'
const body = process.env.REPORT
await script({ github, context, header, body })

slither:
Copy link
Member Author

Choose a reason for hiding this comment

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

dummy job to wrap _slither

@sripwoud sripwoud force-pushed the ci/conditional-checks branch 3 times, most recently from f1ddcc1 to 7fd6b85 Compare August 8, 2024 07:23
@sripwoud sripwoud marked this pull request as ready for review August 8, 2024 07:26
.github/workflows/main.yml Outdated Show resolved Hide resolved
@sripwoud sripwoud requested a review from cedoor August 8, 2024 10:41
Copy link
Member

@cedoor cedoor left a comment

Choose a reason for hiding this comment

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

LGTM!

@sripwoud sripwoud merged commit 597e070 into main Aug 8, 2024
9 checks passed
@sripwoud sripwoud deleted the ci/conditional-checks branch August 8, 2024 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working devops 🔧 Operations management and dev tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement a workaround for the conditional ci checks always being required
2 participants