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

Make action compatible with private repos. #113

Merged
merged 30 commits into from
Nov 11, 2023
Merged

Conversation

ApoorvGuptaAi
Copy link
Contributor

@ApoorvGuptaAi ApoorvGuptaAi commented Nov 6, 2023

Make action compatible with private repos.

  • Switches to the latest github actions package and API.
  • Use octokit rest API interface to get PR diff (works for private repos too).

[x] Unit tests run and pass.

@ApoorvGuptaAi
Copy link
Contributor Author

Example run on private repo:

Screenshot 2023-11-06 at 9 18 02 PM

@JJ
Copy link
Owner

JJ commented Nov 6, 2023

Make action compatible with private repos.

* Switches to the latest github actions package and API.

* Use octokit rest API interface to get PR diff (works for private repos too).

Wow, amazing. Thanks a lot. I need some time to check it out, even to understand it properly. Stick around, don't go far, and again, thanks a lot.

@ApoorvGuptaAi
Copy link
Contributor Author

Wow, amazing. Thanks a lot. I need some time to check it out, even to understand it properly. Stick around, don't go far, and again, thanks a lot.

Couple of things to look out for:

  • Havent tested the waivedUser functionality, specifically if non-"User" type users should be checked.
  • Tested on small PRs on private repos, I dont know if the new diff API has any limitations on size.

Copy link
Owner

@JJ JJ left a comment

Choose a reason for hiding this comment

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

I would say it looks fine overall. There are some minor nits, would be helpful if you clarified them before merging.

package.json Show resolved Hide resolved
src/main.ts Outdated
import parse from "parse-diff";
import { rexify } from "./utils";

async function getDiff(octokit, context) {
Copy link
Owner

Choose a reason for hiding this comment

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

What we are using here from context is payload.repository and payload.pull request. Maybe destructure these in the argument declaration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

src/main.ts Show resolved Hide resolved
src/main.ts Show resolved Hide resolved
src/main.ts Outdated
core.warning(`⚠️ Not running this workflow for waived user «${senderName}»`);
return;
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

No else here? What happens if it's not an user? Maybe warn "waivedUsers" is not applicable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove the sender type check.
Added a warning now though if sender info is missing.

src/main.ts Outdated
@@ -28,13 +51,11 @@ async function run() {
core.warning("⚠️ Not a pull request, skipping PR body checks");
} else {
if (bodyContains || bodyDoesNotContain) {
const PRBody = context?.payload?.pull_request?.body;
Copy link
Owner

Choose a reason for hiding this comment

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

Again, the action can't continue if context does not exist; if payload does not exist, either. It's probably best to check early, and then just go with it, don't you think so?

src/main.ts Outdated Show resolved Hide resolved
let additions: number = 0;
files.forEach(function (file) {
additions += file.additions;
file.chunks.forEach(function (chunk: parse.Chunk) {
Copy link
Owner

Choose a reason for hiding this comment

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

No change here but indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I removed an if condition that decreased indentation by 1 level.

);
}

core.info("Checking lines/files changed");
Copy link
Owner

Choose a reason for hiding this comment

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

Don't know what happened here, seems to be the same except for indentation...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack, explained above.

@JJ
Copy link
Owner

JJ commented Nov 6, 2023

Wow, amazing. Thanks a lot. I need some time to check it out, even to understand it properly. Stick around, don't go far, and again, thanks a lot.

Couple of things to look out for:

* Havent tested the waivedUser functionality, specifically if non-"User" type users should be checked.

That was one of my questions, probably something should be conveyed to the user in that case, but so far I didn't know such kind of users existed... Might be worth the while a separate PR, maybe, although what is there so far looks great.

* Tested on small PRs on private repos, I dont know if the new diff API has any limitations on size

In diff size, you mean? At any rate, maybe add a caveat in the documentation?

@JJ
Copy link
Owner

JJ commented Nov 6, 2023

Also, waivedUsers is not working. I have to get around to it since summer #106

@ApoorvGuptaAi
Copy link
Contributor Author

ApoorvGuptaAi commented Nov 10, 2023

Have responded to and fixed everything.

@JJ Havent tested the latest set of changes, is there some way to test it out?

@JJ
Copy link
Owner

JJ commented Nov 10, 2023

Just the basics, I just approved running them. I don't have time ATM but I would say all looks good... Thanks!

@ApoorvGuptaAi
Copy link
Contributor Author

Just confirmed itsworking, please go ahead and merge.

Copy link
Owner

@JJ JJ left a comment

Choose a reason for hiding this comment

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

Still a TODO and NOTE to go, but I guess your intention is to create an issue for later, right?

@JJ JJ merged commit 11e14a5 into JJ:master Nov 11, 2023
2 checks passed
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