-
Notifications
You must be signed in to change notification settings - Fork 24
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
Simplified initialSetup() function #26
Simplified initialSetup() function #26
Conversation
@mitchspano just wanted to get a little PR going here, but I have a much bigger question - any reason for not using TypeScript for this repo? It would make refactoring some of these functions a lot easier (especially places where the sync version of |
Hey @jamessimone thank you so much for your contribution! Regarding TypeScript, I would be definitely open to refactoring this to TypeScript - I only chose JavaScript because of my familiarity with the language and the readily available documentation. If we can make this work with TypeScript it would provide the benefits you mentioned above and (perhaps selfishly) be an excellent learning opportunity for me to get familiar with a new language. |
@mitchspano I included another example of how helpful TypeScript can be in the PR I tagged you in on my own fork. There is going to be (in my experience locally developing this application) a significant pain point in keeping Regardless - I think there's a lot of potential to do additional cleanup even if the project remains entirely javascript-based. Here's an example of what I'm talking about (which I only have locally): async function main() {
const { inputs, pullRequest, scannerCliArgs } = initialSetup();
validatePullRequestContext(pullRequest);
const filePathToChangedLines = getDiffInPullRequest(pullRequest);
await recursivelyMoveFilesToTempFolder(filePathToChangedLines);
const diffFindings = performStaticCodeAnalysisOnFilesInDiff(scannerCliArgs);
const existingComments = await getExistingComments(pullRequest);
const filePathToComments = filterFindingsToDiffScope(
diffFindings,
filePathToChangedLines,
inputs,
pullRequest
);
writeComments(
existingComments,
filePathToComments,
pullRequest,
hasHaltingError // this is still a "global" variable, but now it's the only one
);
} Changes like these are meant to remove variables from global state, creating a more idiomatic program control flow. I'm happy to re-create these changes in the pure javascript version here as well. |
Yes, I would like to remove There is an alternative which involves using vercel to compile all the contents of I have created this issue to track the work of removal of |
const inputs = { | ||
severityThreshold: core.getInput("severity-threshold"), | ||
strictlyEnforcedRules: core.getInput("strictly-enforced-rules"), | ||
const scannerFlags = { |
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.
These changes look great - thank you for the simplification!
Were you able to test this running in an action's runtime from your fork?
The testing of this project has been quite challenging - it involves creating a tag and a release, then running the test-release action in a separate repo 😵💫.
If you weren't able to test in an action's runtime, I can create a separate "release" branch for these pending changes to be bundled into a release and tested in a separate repo before being merged into main.
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.
@mitchspano I'm aware of the node_module
"need" for actions, yes. It would definitely be preferable to get around that by bundling. Vercel is just one of many options - tsbuild
is another; ironically I believe rollup
also can do TS transpilation.
In the past I've used act
to test locally, as others were telling you about. As this was a strict refactor, I haven't yet had the chance to do that.
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 also think testing can be much simplified - it should be relatively simple to set up Jest tests for this repo to unit test all changes properly without even having to run the action locally. You certainly should not need to be running things in a separate repo.
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.
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.
These look great - thank you for the contribution @jamessimone!
initialSetup()
function