-
Notifications
You must be signed in to change notification settings - Fork 335
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 codeql-action/start-proxy
#2376
Conversation
37674bb
to
19fdcff
Compare
Pushed a commit to update the checked-in dependencies. Please mark the PR as ready for review to trigger PR checks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me 👍 added a few in-line comments.
Additional nit: could you make all the variables in the TS files camelCase to match the repo convention? Thanks 🙇
start-proxy/action.yml
Outdated
@@ -0,0 +1,22 @@ | |||
name: "CodeQL: Start proxy" | |||
description: "Start HTTP proxy server" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: "Start HTTP proxy server" | |
description: "[Experimental] Start HTTP proxy server" |
to match the other experimental actions.
src/start-proxy-action.ts
Outdated
}, | ||
{ | ||
name: "organizationName", | ||
value: "GitHub ic.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gut check: is this meant to be GitHub inc
or something like that? I wasn't able to find the expected value in our internal issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well spotted, it comes from the following place, which has the same spelling mistake ;-)
}); | ||
subprocess.on("exit", (code) => { | ||
if (code !== 0) { | ||
port = Math.floor(Math.random() * (65535 - 49152) + 49152); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious: where does this rand calculation come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just wanted to write port = random_int_between(49152, 65535)
, but I could not find such a function in typescript. The range [49152 .. 65535]
is the dynamic ports range, meant for temporary/client stuff. The randomness is to avoid collisions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah got it — I wasn't sure why those numbers were chosen but makes sense that it's the range for dynamic ports 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-pilot generated the following comment for the code:
// If the proxy failed to start, try a different port from the ephemeral range [49152, 65535]
); | ||
subprocess.unref(); | ||
if (subprocess.pid) { | ||
core.saveState("proxy-process-pid", `${subprocess.pid}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL about saveState
and getState
👍
src/start-proxy-action-post.ts
Outdated
`start-proxy post-action step failed: ${wrapError(error).message}`, | ||
); | ||
} | ||
if (core.isDebug()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to use config.debugMode
instead here; we use this throughout to take into account the debug
input parameter in the init
action:
codeql-action/src/init-action.ts
Line 285 in 0e346f2
debugMode: getOptionalInput("debug") === "true" || core.isDebug(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Note, the start proxy action may have failed before the init step has run, so I added some code that tries to get the config and falls back on core.isDebug()
if it is undefined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me 👍
We may want to add a changelog note indicating this is a new experimental action, probably something similar to this one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing all the comments — looks great to me!
58e34d6
to
77e4172
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
@angelapwen When we do the next release, we'll probably want to add a commit to the v3 -> v2 backport PR to run this Action on Node 16. I wonder whether it's worth doing a release now so we don't forget — what do you think? |
Good point @henrymercer — I'll release earlier in the workday tomorrow. |
Kicking off the release now 🙏 |
Done in #2390! |
This pull request adds a new experimental action,
codeql-action/start-proxy
, which starts the HTTP proxy server that is also used by dependabot update jobs. The Action is used for an experimental implementation leveraging Dependabot's configurations and secrets by CodeQL Default Setup jobs that require access to private maven repositories.Merge / deployment checklist