fix: only move to bin directory when not cached
Some checks failed
Check Transpiled JavaScript / Check dist/ (push) Successful in 34s
Continuous Integration / GitHub Actions Test (push) Failing after 8s
Continuous Integration / TypeScript Tests (push) Successful in 49s

This commit is contained in:
Peter 2024-05-03 16:59:14 +02:00
parent 47b2964798
commit b025437574
Signed by: prskr
GPG key ID: F56BED6903BC5E37
5 changed files with 36 additions and 36 deletions

26
dist/index.js vendored
View file

@ -49389,10 +49389,9 @@ class Platform {
core.debug(`workDir: ${workDir}`); core.debug(`workDir: ${workDir}`);
return workDir; return workDir;
} }
async ensureBinDir(workDir) { async ensureBinDir() {
const binDir = external_path_default().join(workDir, 'bin'); const binDir = external_path_default().join(this.getHomeDir(), Action.WorkDirName, 'bin');
await io.mkdirP(binDir); await io.mkdirP(binDir);
core.addPath(binDir);
core.debug(`binDir: ${binDir}`); core.debug(`binDir: ${binDir}`);
return binDir; return binDir;
} }
@ -49444,8 +49443,6 @@ class HugoInstaller {
core.debug(`Operating System: ${this.platform.os}`); core.debug(`Operating System: ${this.platform.os}`);
core.debug(`Processor Architecture: ${this.platform.arch}`); core.debug(`Processor Architecture: ${this.platform.arch}`);
const hugoBinName = this.platform.binaryName(Hugo.CmdName); const hugoBinName = this.platform.binaryName(Hugo.CmdName);
const workDir = await this.platform.createWorkDir();
const binDir = await this.platform.ensureBinDir(workDir);
const tmpDir = external_node_os_namespaceObject.tmpdir(); const tmpDir = external_node_os_namespaceObject.tmpdir();
try { try {
const cachedTool = tool_cache.find(Hugo.Name, release.tag_name, this.platform.arch); const cachedTool = tool_cache.find(Hugo.Name, release.tag_name, this.platform.arch);
@ -49471,13 +49468,16 @@ class HugoInstaller {
await tool_cache.extractTar(destPath, tmpDir); await tool_cache.extractTar(destPath, tmpDir);
} }
await (0,io.rmRF)(destPath); await (0,io.rmRF)(destPath);
core.debug(`move binaries to binDir: ${binDir}`);
await (0,io.mv)(external_path_default().join(tmpDir, hugoBinName), binDir);
try { try {
await tool_cache.cacheFile(external_path_default().join(binDir, hugoBinName), hugoBinName, Hugo.Name, release.tag_name, this.platform.arch); const cachedHugoPath = await tool_cache.cacheFile(external_path_default().join(tmpDir, hugoBinName), hugoBinName, Hugo.Name, release.tag_name, this.platform.arch);
core.addPath(cachedHugoPath);
} }
catch (e) { catch (e) {
core.warning(`Failed to cache Hugo install: ${errorMsg(e)}`); core.warning(`Failed to cache Hugo install: ${errorMsg(e)}`);
const binDir = await this.platform.ensureBinDir();
core.debug(`move binaries to binDir: ${binDir}`);
await (0,io.mv)(external_path_default().join(tmpDir, hugoBinName), binDir);
core.addPath(binDir);
} }
} }
} }
@ -49560,8 +49560,6 @@ class DartSassInstaller {
const release = await this.releaseLookup.getRelease(DartSass.Org, DartSass.Repo, cmd.version, DartSassReleaseTransformer); const release = await this.releaseLookup.getRelease(DartSass.Org, DartSass.Repo, cmd.version, DartSassReleaseTransformer);
core.debug(`Operating System: ${this.platform.os}`); core.debug(`Operating System: ${this.platform.os}`);
core.debug(`Processor Architecture: ${this.platform.arch}`); core.debug(`Processor Architecture: ${this.platform.arch}`);
const workDir = await this.platform.createWorkDir();
const binDir = await this.platform.ensureBinDir(workDir);
const tmpDir = external_node_os_namespaceObject.tmpdir(); const tmpDir = external_node_os_namespaceObject.tmpdir();
try { try {
const cachedDartSass = tool_cache.find(DartSass.Name, release.tag_name, this.platform.arch); const cachedDartSass = tool_cache.find(DartSass.Name, release.tag_name, this.platform.arch);
@ -49587,14 +49585,16 @@ class DartSassInstaller {
await tool_cache.extractTar(destPath, tmpDir); await tool_cache.extractTar(destPath, tmpDir);
} }
await (0,io.rmRF)(destPath); await (0,io.rmRF)(destPath);
core.debug(`Move binaries to binDir: ${binDir}`);
await (0,io.mv)(external_path_default().join(tmpDir, 'dart-sass'), binDir);
core.debug(`Add 'dart-sass' directory to cache`); core.debug(`Add 'dart-sass' directory to cache`);
try { try {
core.addPath(await tool_cache.cacheDir(external_path_default().join(binDir, 'dart-sass'), DartSass.Name, release.tag_name, this.platform.arch)); const cachedDartSass = await tool_cache.cacheDir(external_path_default().join(tmpDir, 'dart-sass'), DartSass.Name, release.tag_name, this.platform.arch);
core.addPath(cachedDartSass);
} }
catch (e) { catch (e) {
core.warning(`Failed to cache dart-sass directory: ${errorMsg(e)}`); core.warning(`Failed to cache dart-sass directory: ${errorMsg(e)}`);
const binDir = await this.platform.ensureBinDir();
core.debug(`Move binaries to binDir: ${binDir}`);
await (0,io.mv)(external_path_default().join(tmpDir, 'dart-sass'), binDir);
core.addPath(external_path_default().join(binDir, 'dart-sass')); core.addPath(external_path_default().join(binDir, 'dart-sass'));
} }
} }

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -34,8 +34,6 @@ export class DartSassInstaller {
core.debug(`Operating System: ${this.platform.os}`) core.debug(`Operating System: ${this.platform.os}`)
core.debug(`Processor Architecture: ${this.platform.arch}`) core.debug(`Processor Architecture: ${this.platform.arch}`)
const workDir = await this.platform.createWorkDir()
const binDir = await this.platform.ensureBinDir(workDir)
const tmpDir = os.tmpdir() const tmpDir = os.tmpdir()
try { try {
@ -73,22 +71,23 @@ export class DartSassInstaller {
await rmRF(destPath) await rmRF(destPath)
core.debug(`Move binaries to binDir: ${binDir}`)
await mv(path.join(tmpDir, 'dart-sass'), binDir)
core.debug(`Add 'dart-sass' directory to cache`) core.debug(`Add 'dart-sass' directory to cache`)
try { try {
core.addPath( const cachedDartSass = await tc.cacheDir(
await tc.cacheDir( path.join(tmpDir, 'dart-sass'),
path.join(binDir, 'dart-sass'),
DartSass.Name, DartSass.Name,
release.tag_name, release.tag_name,
this.platform.arch this.platform.arch
) )
)
core.addPath(cachedDartSass)
} catch (e) { } catch (e) {
core.warning(`Failed to cache dart-sass directory: ${errorMsg(e)}`) core.warning(`Failed to cache dart-sass directory: ${errorMsg(e)}`)
const binDir = await this.platform.ensureBinDir()
core.debug(`Move binaries to binDir: ${binDir}`)
await mv(path.join(tmpDir, 'dart-sass'), binDir)
core.addPath(path.join(binDir, 'dart-sass')) core.addPath(path.join(binDir, 'dart-sass'))
} }
} }

View file

@ -37,8 +37,6 @@ export class HugoInstaller {
core.debug(`Processor Architecture: ${this.platform.arch}`) core.debug(`Processor Architecture: ${this.platform.arch}`)
const hugoBinName = this.platform.binaryName(Hugo.CmdName) const hugoBinName = this.platform.binaryName(Hugo.CmdName)
const workDir = await this.platform.createWorkDir()
const binDir = await this.platform.ensureBinDir(workDir)
const tmpDir = os.tmpdir() const tmpDir = os.tmpdir()
try { try {
@ -76,19 +74,23 @@ export class HugoInstaller {
await rmRF(destPath) await rmRF(destPath)
core.debug(`move binaries to binDir: ${binDir}`)
await mv(path.join(tmpDir, hugoBinName), binDir)
try { try {
await tc.cacheFile( const cachedHugoPath = await tc.cacheFile(
path.join(binDir, hugoBinName), path.join(tmpDir, hugoBinName),
hugoBinName, hugoBinName,
Hugo.Name, Hugo.Name,
release.tag_name, release.tag_name,
this.platform.arch this.platform.arch
) )
core.addPath(cachedHugoPath)
} catch (e) { } catch (e) {
core.warning(`Failed to cache Hugo install: ${errorMsg(e)}`) core.warning(`Failed to cache Hugo install: ${errorMsg(e)}`)
const binDir = await this.platform.ensureBinDir()
core.debug(`move binaries to binDir: ${binDir}`)
await mv(path.join(tmpDir, hugoBinName), binDir)
core.addPath(binDir)
} }
} }
} }

View file

@ -48,10 +48,9 @@ export class Platform {
return workDir return workDir
} }
async ensureBinDir(workDir: string): Promise<string> { async ensureBinDir(): Promise<string> {
const binDir = path.join(workDir, 'bin') const binDir = path.join(this.getHomeDir(), Action.WorkDirName, 'bin')
await io.mkdirP(binDir) await io.mkdirP(binDir)
core.addPath(binDir)
core.debug(`binDir: ${binDir}`) core.debug(`binDir: ${binDir}`)
return binDir return binDir
} }