FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Remove rmDir references by aeisenberg · Pull Request #840 · github/codeql-action · GitHub

Remove rmDir references - #840

Merged
adityasharad merged 1 commit into
mainfrom
aeisenberg/fix-rm
Dec 8, 2021
Merged

adityasharad merged 1 commit into
mainfrom
aeisenberg/fix-rm

Conversation

aeisenberg commented Dec 8, 2021
edited
Loading

Copy link
Copy Markdown
Contributor

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 requested a review from a team as a code owner December 8, 2021 20:01
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.
Comment thread src/toolcache.ts
@@ -268,8 +275,8 @@ function createToolPath(
);
logger.debug(`destination ${folderPath}`);
const markerPath = `${folderPath}.complete`;
fs.rmSync(folderPath, { recursive: true, force: true });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

aeisenberg Dec 8, 2021
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

edoardopirovano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

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

Copy link
Copy Markdown
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

Copy link
Copy Markdown
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.

Copy link
Copy Markdown
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.

Copy link
Copy Markdown
Contributor

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

Ah, even better :)

Copy link
Copy Markdown
Contributor

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

github-actions Bot mentioned this pull request Dec 10, 2021
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL