-
Notifications
You must be signed in to change notification settings - Fork 3
Use GHA workflow commands in PRs from forks instead of API calls #3
Comments
Thats much better idea. It's also easier 😅 |
I am looking forward to see it working as annotations are really awesome. And thanks for the work on that. Hopefully we can now make it easier for developers to read their own errors. |
You should be able to use import this from the actions toolkit: https://github.com/actions/toolkit/blob/b0e01b71c0e630eb4b420f763029a7476c6cf075/packages/core/src/command.ts import * as core from '@actions/core';
core.issueCommand(
'warning',
{
file: 'PASTE THE FILE PATH HERE',
line: 42,
col: 42,
},
'YOUR MESSAGE HERE',
) (https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L145) |
P.S. I'd still use the API where possible because workflow commands have some character limitations. And while |
Hey, Do you mean like this? Do you guys now how to test this correctly? Last time I did many releases 🙈 |
Ah, honestly, I was going to build an action like this but decided to check for the prior art so that there'll be no unnecessary double effort.
Something like this but I think it should also use the old way when running for non-fork PRs because of the limitations I mentioned above.
Testing around GHA is a long-time mystery. I know that one of the approaches that GitHub suggests is to have a self-testing workflow in the same repo. Some people probably use https://github.com/nektos/act. You can also test that commit without releasing by just using |
I have now built it in the master like your description :) |
@shyim currently, the annotations show up with the wrong file, have you tested this? https://github.com/ansible/ansible-lint/actions/runs/178928109. Also, |
Yep I have tested it in my branch. I use PHPUnit with jUnit. Maybe the schema is not very similar. Can you provide me an example file? :) |
Here you go: pytest-junit-example.tar.gz. P.S. It'd be useful to also log the file locations to stdout too for debugging... |
Thanks i will Look tomorrow into |
Hey, all tests are passed in that file 🙈 |
Something is wrong I updated I also configured |
File is already printed |
@shyim btw you could move |
@ssbarnea that setting modifies the paths that are inside of the report, not the report lookup on disk. Previous versions generated annotations on the workflow page, just not matched to the proper files. |
@ssbarnea I've found the root of the issue. We use Possible solutions:
|
@shyim sometimes using |
Using |
@shyim there's one problem with the annotations: it looks like there's an off-by-one. Our XML file contains lines with 0-based numbering while diffs on GH start with 1. We probably need an option to tell this action to increment the line number after reading from the report. |
GITHUB_TOKEN
in forked repos cannot write to Checks API: https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token.I suggest falling back to using Workflow commands (https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message) in order to overcome this limitation.
The idea is simple: just output things like
::warning file={name},line={line},col={col}::{message}
to stdout and GitHub Action runner will pick those up and post them as annotations.The text was updated successfully, but these errors were encountered: