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

Remove rmDir references #840

Merged
merged 1 commit into from
Dec 8, 2021
Merged

Remove rmDir references #840

merged 1 commit into from
Dec 8, 2021

Conversation

aeisenberg
Copy link
Contributor

@aeisenberg aeisenberg commented Dec 8, 2021

rmDir is not available on the node version used by the actions runner.

Instead, use the del package. It is safe, well-tested, and
cross-platform. Also, downgrade the @types/node package so that it more closely reflects what is being run on the server.

This should fix the failing tests on main.

Interestingly, there are several other places in the code where rmDir is being used, but it is not causing problems because (I think) these code paths are only hit by the runner.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • [n/a] Confirm the readme has been updated if necessary.
  • [n/a] Confirm the changelog has been updated if necessary.

@aeisenberg aeisenberg requested a review from a team as a code owner December 8, 2021 20:01
@aeisenberg aeisenberg force-pushed the aeisenberg/fix-rm branch 2 times, most recently from 9080691 to 82f7736 Compare December 8, 2021 20:10
`rmDir` is not available on the node version used by the actions runner.

Instead, use the `del` package. It is safe, well-tested, and
cross-platform.
@@ -268,8 +275,8 @@ function createToolPath(
);
logger.debug(`destination ${folderPath}`);
const markerPath = `${folderPath}.complete`;
fs.rmSync(folderPath, { recursive: true, force: true });
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be fs.rmdirSync rather than relying on a new dependency? Or does that not offer the same recursive/force behaviour?

Copy link
Contributor Author

@aeisenberg aeisenberg Dec 8, 2021

Choose a reason for hiding this comment

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

rmDirSync was also newly added in v14. So, can't use that method on an actions runner.

Copy link
Contributor

Choose a reason for hiding this comment

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

https://nodejs.org/api/fs.html#fsrmdirsyncpath-options claims it was added in 12 (though various options are deprecated in 14 and 16, which might be annoying when we upgrade).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah...so it is.

Yes, looks like the recursive option was deprecated. We would need to add it now, and then remove it later when the node version increased.

I'm still thinking it is cleaner to use del. It's a very popular package and handles all of these edge cases correctly.

Copy link
Contributor

@edoardopirovano edoardopirovano left a comment

Choose a reason for hiding this comment

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

LGTM. I think we may as well use del wherever possible now that we've introduced the (very reasonable) dependency.

@adityasharad adityasharad merged commit 924a64d into main Dec 8, 2021
@adityasharad adityasharad deleted the aeisenberg/fix-rm branch December 8, 2021 23:09
@adityasharad
Copy link
Contributor

Looks like we need a force flag to delete outside the current directory: https://github.com/github/codeql-action/runs/4464110110?check_suite_focus=true#step:7:4172

@aeisenberg
Copy link
Contributor Author

we've introduced the (very reasonable) dependency.

The dependency already existed. It's just that it was transitive. I had to make it a top level dependency in order to be allowed to import it.

@aeisenberg
Copy link
Contributor Author

Looks like we need a force flag to delete outside the current directory: https://github.com/github/codeql-action/runs/4464110110?check_suite_focus=true#step:7:4172

Curious how this check passed: https://github.com/github/codeql-action/runs/4462419683?check_suite_focus=true
which is the same job.

@edoardopirovano
Copy link
Contributor

The dependency already existed. It's just that it was transitive.

Ah, even better :)

@adityasharad
Copy link
Contributor

I think builds on main have additional data to clean up (the database that's built and uploaded for remote queries).

@github-actions github-actions bot mentioned this pull request Dec 10, 2021
5 tasks
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.

3 participants