Skip to content

CI: pass with comment on linkcheck fail #462

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sam-maloney
Copy link
Contributor

@sam-maloney sam-maloney commented Aug 8, 2025

Problem: linkcheck fails frequently for various out-of-our-control reasons

Make the workflow pass regardless of make linkcheck outcome, but post a comment to the PR notifying if linkcheck failed.

Such a workaround is necessary because unfortunately GitHub CI does not natively support a sensible allow-failure type option, see e.g. actions/runner#2347 or https://github.com/orgs/community/discussions/15452

[Update]
It also turns out that workflows on PRs triggered from external forks do not have permission to create comments, so the attempt in the first commit is insufficient.. Instead a 2nd workflow is required, which is triggered by the completion of the main workflow, but since it is triggered by the target repo itself, this 2nd workflow should have permission to comment 🤞
This is based on: https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/

@sam-maloney sam-maloney force-pushed the allow-linkcheck-fail branch 4 times, most recently from b6df625 to 04a31f8 Compare August 8, 2025 12:03
@sam-maloney
Copy link
Contributor Author

I've tested that this works on my own forked repo, but of course until the second workflow file is merged here I can only hope that it actually solves the permissions as intended.

@sam-maloney sam-maloney changed the title ci: pass with comment on linkcheck fail CI: pass with comment on linkcheck fail Aug 8, 2025
@sam-maloney sam-maloney force-pushed the allow-linkcheck-fail branch from 04a31f8 to 9f4a831 Compare August 8, 2025 12:18
@grondo
Copy link
Contributor

grondo commented Aug 8, 2025

Another simpler approach would be to drop the linkcheck requirement from .mergify.yml and just treat the error as a warning. Though I do like the idea of a PR comment much better, perhaps the 2nd workflow is overkill in this situation.

I'm fine either way, though. Perhaps others can chime in on their preferences.

In any event, dropping the explicit required checks in .mergify.yml in preference for branch protections like we've done in other projects is probably warranted here, so I can make a PR for that.

@sam-maloney
Copy link
Contributor Author

I completely agree that it's overkill, haha! But it was the only way I could find to have the workflow show as 'passing' even if the linkcheck failed while still actually providing a warning that it had failed, and by that point I was in too deep and figured I'd just try implementing it to learn more about GitHub's CI 😁 Feel free to just make a simpler PR and close this though, if you prefer!

Other options I saw were just to use make linkcheck || true to always pass, but then you have to manually check the logs to even see the status; or as you suggested, make the linkcheck optional for mergify so it doesn't actually stop merging, but then the workflow will be frequently displayed as failing (which isn't the end of the world, but does seem to defeat the purpose of the status marks if every merged PR has a red X next to it!)

@grondo
Copy link
Contributor

grondo commented Aug 11, 2025

make the linkcheck optional for mergify so it doesn't actually stop merging, but then the workflow will be frequently displayed as failing (which isn't the end of the world, but does seem to defeat the purpose of the status marks if every merged PR has a red X next to it!)

This change has been enabled with the merge of #464, but it is good practice to move the status checks to branch protections anyway since it is easier to keep up to date. Your point about the status checks almost always being red is salient. I think we should accept this PR and see how it goes.

Thanks!

@grondo
Copy link
Contributor

grondo commented Aug 11, 2025

I'm going to rebase then merge this @sam-maloney. Hope that's ok.

@grondo grondo force-pushed the allow-linkcheck-fail branch from 9f4a831 to bade8c3 Compare August 11, 2025 14:22
@grondo
Copy link
Contributor

grondo commented Aug 11, 2025

Oh, new validator typos support caught one typo in a commit message.

Problem: linkcheck fails frequently for various out-of-our-control reasons

Make the workflow pass regardless of `make linkcheck` outcome, but post a
comment to the PR notifying if linkcheck failed.
Problem: workflows triggered by a pull_request from an xternal fork
do not have permission to write comments.

Use a 2nd workflow triggered by the completion of the first via
workflow_run to write the comment if necessary. Based on:
https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
@sam-maloney sam-maloney force-pushed the allow-linkcheck-fail branch from bade8c3 to 15b40d4 Compare August 12, 2025 05:53
@sam-maloney
Copy link
Contributor Author

I'm going to rebase then merge this @sam-maloney. Hope that's ok.

Always OK with me to rebase/edit/mangle my PRs in any way you see fit, haha! 😁

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.

2 participants