Skip to content

Fix GitHub Caching action for Windows#1157

Merged
aomarks merged 5 commits intosetup-github-actions-cachingfrom
action-windows
Aug 13, 2024
Merged

Fix GitHub Caching action for Windows#1157
aomarks merged 5 commits intosetup-github-actions-cachingfrom
action-windows

Conversation

@aomarks
Copy link
Member

@aomarks aomarks commented Aug 13, 2024

Fixes Windows support for GitHub Actions Caching, which has been broken since the security improvement in #1146. (This only affected users who had upgraded to v2 of the action, and the failure was not fatal, it just disabled caching).

The problem was that under Windows, {detached: true} is not sufficient for keeping the server alive after the parent shell exits. The parent shell will exit as soon as the main launching script is done, because the action is invoked through a GitHub Actions uses: clause (as opposed to run: where we would be sharing our parent shell with subsequent steps).

We now use start so that the server is not killed when our parent shell exits: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/start.

Also listens only on localhost instead of all hosts (shouldn't matter because we should have strong network isolation for free through the GitHub Actions container, but seems wise, and good in case this code runs in some other context for some reason).

Also adds a CHANGELOG.md file.

@aomarks aomarks requested a review from rictic August 13, 2024 01:34
main.js Outdated
console.log(`[main] Custodian server ready`);
process.exit(0);
}
if (Date.now() - start > timeoutSecs * 1000) {
Copy link
Member

Choose a reason for hiding this comment

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

Mild optional thing for the future, it's often a bit more elegant to do:

const timedOutTime = Date.now() + (timeoutSecs * 1000);

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes, nice. Done.

@aomarks aomarks merged commit 83d7f8b into setup-github-actions-caching Aug 13, 2024
@aomarks aomarks deleted the action-windows branch August 13, 2024 02:51
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