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

Add action output for using the error message #65

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

orhun
Copy link
Sponsor

@orhun orhun commented Mar 16, 2024

See #64

Implemented based on amannn/action-semantic-pull-request@880a3c0

Not tested, it is very straightforward so I believe this will work just fine (i.e. I can test after merge if you're okay with that :D)

Let me know what you think! 🐻

Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

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

The code change looks great! I'm a bit concerned about the usage example, though. This is something I'd expect to get copy-pasted into many repos, so we want to have great defaults. Would love your thoughts!

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@obi1kenobi
Copy link
Owner

The remaining CI check just wants you to run npm run all and commit the result.

This is because GitHub Actions currently must be written in JavaScript, so we have to check in the dist/ directory which contains the compiled JavaScript output of the TypeScript the action is otherwise written in. That CI check just ensures we didn't forget to generate and check in that JavaScript, so we don't end up thinking the action does one thing while it does something else.

src/main.ts Outdated
Comment on lines 112 to 117
stdout: (data: Buffer) => {
SEMVER_CHECKS_OUTPUT += data.toString();
},
stderr: (data: Buffer) => {
SEMVER_CHECKS_OUTPUT += data.toString();
},
Copy link
Owner

Choose a reason for hiding this comment

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

Consider checking if data is non-empty and not undefined here. The undefined prefix we see in the output right now is probably from an invocation with data = undefined here.

Copy link
Sponsor Author

Choose a reason for hiding this comment

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

Comment on lines +219 to +220
permissions:
pull-requests: write
Copy link
Owner

Choose a reason for hiding this comment

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

Oh interesting! Does this work correctly even if the PR comes from a fork of the repo? 👀

I would have assumed this might give the job "PR write" permissions on the fork, but admittedly I find the GitHub Actions permissions model confusing and unpredictable even after working with it for years.

Copy link
Sponsor Author

Choose a reason for hiding this comment

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

Yeah I find it confusing as well. I need to find some time to set up a repo to test this - running out of time now.

Copy link
Owner

Choose a reason for hiding this comment

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

If you get a chance to test this, I'd love to make sure it works well before we put it in the docs.

Copy link
Sponsor Author

Choose a reason for hiding this comment

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

Nope, it doesn't work from a fork.

Error: Resource not accessible by integration

Any idea?

Copy link
Owner

Choose a reason for hiding this comment

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

I never got a chance to dig too deep into this, but last time I looked, one possible answer seemed to be something like "create a GitHub App." That seemed a bit annoying to do, so I didn't do it at the time.

If you find or hear about any other possible workarounds, I'd love to know about them.

Copy link
Sponsor Author

Choose a reason for hiding this comment

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

Ah, I see. Well, I'm not sure then. Creating a GitHub app definitely sounds annoying :D

Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

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

Finally got a chance to review this, sorry about the wait!

src/main.ts Outdated Show resolved Hide resolved
Comment on lines +219 to +220
permissions:
pull-requests: write
Copy link
Owner

Choose a reason for hiding this comment

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

If you get a chance to test this, I'd love to make sure it works well before we put it in the docs.

Comment on lines +179 to +180
const output = await runCargoSemverChecks(cargo);
core.setOutput("logs", stripAnsi(output));
Copy link
Owner

Choose a reason for hiding this comment

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

I just realized something. By making output available in the logs output value, are we accidentally preventing it from being printed into the GitHub workflow logs themselves?

That might be shooting ourselves in the foot, because we might prevent maintainers from seeing the output if they need to dig in for any reason. It'd be awesome to have the ability to post run output as a comment in the PR, but I don't think we want to break other users that use the action differently (e.g. before cargo publish like cargo-semver-checks uses it itself).

Copy link
Sponsor Author

Choose a reason for hiding this comment

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

I just realized something. By making output available in the logs output value, are we accidentally preventing it from being printed into the GitHub workflow logs themselves?

What do you mean? In my tests I can see the logs in both GitHub Action run and in the comment.

Comment on lines +219 to +220
permissions:
pull-requests: write
Copy link
Owner

Choose a reason for hiding this comment

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

I never got a chance to dig too deep into this, but last time I looked, one possible answer seemed to be something like "create a GitHub App." That seemed a bit annoying to do, so I didn't do it at the time.

If you find or hear about any other possible workarounds, I'd love to know about them.

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.

None yet

2 participants