Skip to content

Conversation

jplimack
Copy link

Summary

This PR enhances the post-annotations functionality to work in both workflow_run scenarios (fork PRs) and same-workflow scenarios (regular PRs with split jobs).

Changes

  • Added dual download strategy for annotations artifacts:
    • First attempts to use actions/download-artifact@v4 for same-workflow scenarios
    • Falls back to GitHub API approach for workflow_run events or if the first attempt fails
  • Updated run ID handling to support both github.event.workflow_run.id and github.run_id
  • Enhanced commit SHA handling for both fork PR and regular PR scenarios
  • Added console logging for better debugging

Use Cases

This enhancement supports three scenarios:

  1. Fork PRs (existing functionality preserved):

    • PR workflow saves annotations as artifact
    • Separate workflow triggered by workflow_run downloads and posts them
  2. Regular PRs with split jobs (new functionality):

    • Job 1: Runs trunk check with save-annotations: true
    • Job 2: Uses post-annotations: true to download and post annotations from same workflow
  3. Regular PRs (existing direct posting still works):

    • Single job can still post annotations directly without artifacts

Testing

The changes maintain backward compatibility while adding new capabilities. The fallback mechanism ensures that if one approach fails, the other is attempted.

Related Issues

Addresses the limitation where post-annotations only worked with workflow_run events, now enabling its use in regular branch PRs with split-job configurations.

…workflow scenarios

- Add dual download strategy using actions/download-artifact for same-workflow scenarios
- Fallback to GitHub API for workflow_run events (fork PRs)
- Support github.run_id in addition to github.event.workflow_run.id
- Handle commit SHA for both fork PR and regular PR scenarios
- Preserve backward compatibility for existing fork PR workflows

This allows post-annotations to work for:
1. Fork PRs using workflow_run trigger (existing functionality)
2. Regular PRs with split jobs in same workflow (new functionality)
3. Regular PRs with direct posting (existing functionality)
@jplimack
Copy link
Author

@TylerJang27 would it be possible to get the required approval to run checks on this PR branch?

@TylerJang27
Copy link
Contributor

CC @puzzler7

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

Successfully merging this pull request may close these issues.

2 participants