Repository navigation
Respect RUNNER_TEMP environment variable - #194
svdschoot-wefabricate wants to merge 1 commit into
Conversation
| private static readonly _tmpDir = fs.mkdtempSync(path.join(Context._tryCreateDirctory(process.env.RUNNER_TEMP) || os.tmpdir(), 'docker-actions-toolkit-')); | ||
|
|
||
| private static _tryCreateDirctory(directoryPath: string | undefined): string | undefined { | ||
| if (directoryPath !== undefined) { | ||
| const createdPath = fs.mkdirSync(directoryPath, {recursive: true}); | ||
| if (createdPath !== directoryPath) { | ||
| return undefined; | ||
| } | ||
| } | ||
| return directoryPath; | ||
| } |
There was a problem hiding this comment.
Don't think _tryCreateDirctory is necessary, can just be:
| private static readonly _tmpDir = fs.mkdtempSync(path.join(Context._tryCreateDirctory(process.env.RUNNER_TEMP) || os.tmpdir(), 'docker-actions-toolkit-')); | |
| private static _tryCreateDirctory(directoryPath: string | undefined): string | undefined { | |
| if (directoryPath !== undefined) { | |
| const createdPath = fs.mkdirSync(directoryPath, {recursive: true}); | |
| if (createdPath !== directoryPath) { | |
| return undefined; | |
| } | |
| } | |
| return directoryPath; | |
| } | |
| private static readonly _tmpDir = fs.mkdtempSync(path.join(process.env.RUNNER_TEMP || os.tmpdir(), 'docker-actions-toolkit-')); |
There was a problem hiding this comment.
A directory at path RUNNER_TEMP may not exist, in which case fs.mkdtempSync(path.join(process.env.RUNNER_TEMP, 'docker-actions-toolkit-')) would throw an exception. Even though the provided string is a prefix, the directory in which the temporary directory would be created must already exist.
There was a problem hiding this comment.
Runner worker makes sure temp folder exists from what I see: https://github.com/actions/runner/blob/a4c57f27477077e57545af79851551ff7f5632bd/src/Runner.Worker/TempDirectoryManager.cs#L43-L44
There was a problem hiding this comment.
Ahh good point. This means the tests also need to point RUNNER_TEMP to an existing directory tough.
Will update the PR.
There was a problem hiding this comment.
This means the tests also need to point
RUNNER_TEMPto an existing directory tough.
Will update the PR.
This is already set in jest config:
actions-toolkit/jest.config.ts
Line 26 in b525cd9
On some (self hosted) runners
os.tmpdir()cannot be used to communicate between applications. For example when using snap, every snap will get it's own, isolated,os.tmpdir().Github already provides us with an environment variable,
RUNNER_TEMP, that should point to a directory that we can use as a temporary storage location that should be accessible by different applications on the same host. This change will use the directory pointed to byRUNNER_TEMPas base for tmpDir when the variable is defined and the directory can be created or already existed