Add option to disable cache (#85)

This commit is contained in:
Patrick Dawson 2024-07-02 21:13:28 +02:00 committed by GitHub
parent d83cb325fa
commit 46198e5e97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 35 additions and 13 deletions

View File

@ -66,6 +66,10 @@ inputs:
description: >- description: >-
True will also download the Godot Export Templates for each platform. True will also download the Godot Export Templates for each platform.
default: false default: false
cache:
description: >-
True to cache downloads.
default: true
runs: runs:
using: 'node20' using: 'node20'
main: 'dist/index.js' main: 'dist/index.js'

11
dist/index.js generated vendored
View File

@ -63,6 +63,7 @@ function run(platform) {
const godotSharpRelease = core.getBooleanInput('godot-sharp-release'); const godotSharpRelease = core.getBooleanInput('godot-sharp-release');
const checkoutDirectory = (_a = process.env['GITHUB_WORKSPACE']) !== null && _a !== void 0 ? _a : ''; const checkoutDirectory = (_a = process.env['GITHUB_WORKSPACE']) !== null && _a !== void 0 ? _a : '';
const includeTemplates = core.getBooleanInput('include-templates'); const includeTemplates = core.getBooleanInput('include-templates');
const useCache = core.getBooleanInput('cache');
const userDir = os.homedir(); const userDir = os.homedir();
const downloadsDir = path_1.default.join(userDir, downloadsRelativePath); const downloadsDir = path_1.default.join(userDir, downloadsRelativePath);
const installationDir = path_1.default.join(userDir, pathRelative); const installationDir = path_1.default.join(userDir, pathRelative);
@ -134,7 +135,13 @@ function run(platform) {
? [godotInstallationPath, exportTemplatePath] ? [godotInstallationPath, exportTemplatePath]
: [godotInstallationPath]; : [godotInstallationPath];
const cacheKey = includeTemplates ? godotUrl : `${godotUrl}-no-templates`; const cacheKey = includeTemplates ? godotUrl : `${godotUrl}-no-templates`;
const cached = yield cache.restoreCache(cachedPaths.slice(), cacheKey); let cached = undefined;
if (useCache) {
cached = yield cache.restoreCache(cachedPaths.slice(), cacheKey);
}
else {
core.info(`⏭️ Not using cache`);
}
let executables; let executables;
if (!cached) { if (!cached) {
// Download Godot // Download Godot
@ -183,12 +190,14 @@ function run(platform) {
core.info(`✅ Files shown`); core.info(`✅ Files shown`);
core.endGroup(); core.endGroup();
} }
if (useCache) {
// Save extracted Godot contents to cache // Save extracted Godot contents to cache
core.startGroup(`💾 Saving extracted Godot download to cache...`); core.startGroup(`💾 Saving extracted Godot download to cache...`);
yield cache.saveCache(cachedPaths, cacheKey); yield cache.saveCache(cachedPaths, cacheKey);
core.info(`✅ Godot saved to cache`); core.info(`✅ Godot saved to cache`);
core.endGroup(); core.endGroup();
} }
}
else { else {
core.info(`🎉 Previous Godot download found in cache!`); core.info(`🎉 Previous Godot download found in cache!`);
core.endGroup(); core.endGroup();

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -26,6 +26,7 @@ async function run(platform: Platform): Promise<void> {
const godotSharpRelease = core.getBooleanInput('godot-sharp-release') const godotSharpRelease = core.getBooleanInput('godot-sharp-release')
const checkoutDirectory = process.env['GITHUB_WORKSPACE'] ?? '' const checkoutDirectory = process.env['GITHUB_WORKSPACE'] ?? ''
const includeTemplates = core.getBooleanInput('include-templates') const includeTemplates = core.getBooleanInput('include-templates')
const useCache = core.getBooleanInput('cache')
const userDir = os.homedir() const userDir = os.homedir()
const downloadsDir = path.join(userDir, downloadsRelativePath) const downloadsDir = path.join(userDir, downloadsRelativePath)
@ -123,7 +124,13 @@ async function run(platform: Platform): Promise<void> {
? [godotInstallationPath, exportTemplatePath] ? [godotInstallationPath, exportTemplatePath]
: [godotInstallationPath] : [godotInstallationPath]
const cacheKey = includeTemplates ? godotUrl : `${godotUrl}-no-templates` const cacheKey = includeTemplates ? godotUrl : `${godotUrl}-no-templates`
const cached = await cache.restoreCache(cachedPaths.slice(), cacheKey) let cached = undefined
if (useCache) {
cached = await cache.restoreCache(cachedPaths.slice(), cacheKey)
} else {
core.info(`⏭️ Not using cache`)
}
let executables: string[] let executables: string[]
if (!cached) { if (!cached) {
@ -217,11 +224,13 @@ async function run(platform: Platform): Promise<void> {
core.endGroup() core.endGroup()
} }
if (useCache) {
// Save extracted Godot contents to cache // Save extracted Godot contents to cache
core.startGroup(`💾 Saving extracted Godot download to cache...`) core.startGroup(`💾 Saving extracted Godot download to cache...`)
await cache.saveCache(cachedPaths, cacheKey) await cache.saveCache(cachedPaths, cacheKey)
core.info(`✅ Godot saved to cache`) core.info(`✅ Godot saved to cache`)
core.endGroup() core.endGroup()
}
} else { } else {
core.info(`🎉 Previous Godot download found in cache!`) core.info(`🎉 Previous Godot download found in cache!`)
core.endGroup() core.endGroup()