From db0c092ee08010cb1963c2e23d48898d4004aa5b Mon Sep 17 00:00:00 2001 From: Jimver Date: Tue, 3 Jun 2025 21:55:44 +0000 Subject: [PATCH 01/12] Log files in cache directory --- src/downloader.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/downloader.ts b/src/downloader.ts index 51217fd2..23f93ddd 100644 --- a/src/downloader.ts +++ b/src/downloader.ts @@ -88,6 +88,15 @@ export async function download( core.debug(`Copying ${destFilePath} to ${cacheDirectory}`) await io.mkdirP(cacheDirectory) await io.mv(destFilePath, cacheDirectory) + if (core.isDebug()) { + // List files in cache directory + const filesInCacheDirectory = await ( + await glob.create(`${cacheDirectory}/**`) + ).glob() + core.debug( + `Files in cache directory: ${cacheDirectory}: ${filesInCacheDirectory}` + ) + } // Save cache directory to GitHub cache const cacheId = await cache.saveCache([cacheDirectory], cacheKey) if (cacheId !== -1) { From 616412e650f02fe12649d57e245b82b433520215 Mon Sep 17 00:00:00 2001 From: Jimver Date: Tue, 3 Jun 2025 21:59:46 +0000 Subject: [PATCH 02/12] Remove log guard --- src/downloader.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/downloader.ts b/src/downloader.ts index 23f93ddd..9daa899e 100644 --- a/src/downloader.ts +++ b/src/downloader.ts @@ -88,15 +88,13 @@ export async function download( core.debug(`Copying ${destFilePath} to ${cacheDirectory}`) await io.mkdirP(cacheDirectory) await io.mv(destFilePath, cacheDirectory) - if (core.isDebug()) { - // List files in cache directory - const filesInCacheDirectory = await ( - await glob.create(`${cacheDirectory}/**`) - ).glob() - core.debug( - `Files in cache directory: ${cacheDirectory}: ${filesInCacheDirectory}` - ) - } + // List files in cache directory + const filesInCacheDirectory = await ( + await glob.create(`${cacheDirectory}/**`) + ).glob() + core.debug( + `Files in cache directory: ${cacheDirectory}: ${filesInCacheDirectory}` + ) // Save cache directory to GitHub cache const cacheId = await cache.saveCache([cacheDirectory], cacheKey) if (cacheId !== -1) { From 4afe547c12770a292608828788442e41c4c2c62d Mon Sep 17 00:00:00 2001 From: Jimver Date: Tue, 3 Jun 2025 22:04:27 +0000 Subject: [PATCH 03/12] Improve log message and bundle for CI --- .github/workflows/CI.yml | 4 ++++ src/downloader.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3a8dfa4f..b106f81e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -63,6 +63,10 @@ jobs: id: npm-ci-test run: npm run ci-test + - name: Bundle + id: npm-bundle + run: npm run bundle + - name: Run the action on this runner with method ${{matrix.method}} uses: ./ with: diff --git a/src/downloader.ts b/src/downloader.ts index 9daa899e..4b3c1d11 100644 --- a/src/downloader.ts +++ b/src/downloader.ts @@ -85,7 +85,7 @@ export async function download( } if (useGitHubCache) { // Move file to GitHub cache directory - core.debug(`Copying ${destFilePath} to ${cacheDirectory}`) + core.debug(`Moving ${destFilePath} to ${cacheDirectory}`) await io.mkdirP(cacheDirectory) await io.mv(destFilePath, cacheDirectory) // List files in cache directory From 9f5fde2109537b13d872db9c2895574aef3213cb Mon Sep 17 00:00:00 2001 From: Jimver Date: Tue, 3 Jun 2025 22:10:34 +0000 Subject: [PATCH 04/12] Move using full path name --- src/downloader.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/downloader.ts b/src/downloader.ts index 4b3c1d11..dc181995 100644 --- a/src/downloader.ts +++ b/src/downloader.ts @@ -86,8 +86,9 @@ export async function download( if (useGitHubCache) { // Move file to GitHub cache directory core.debug(`Moving ${destFilePath} to ${cacheDirectory}`) + const cachePath = `${cacheDirectory}/${destFilePath}` await io.mkdirP(cacheDirectory) - await io.mv(destFilePath, cacheDirectory) + await io.mv(destFilePath, cachePath) // List files in cache directory const filesInCacheDirectory = await ( await glob.create(`${cacheDirectory}/**`) From e29d481999b3234801c0d3486483b1b28473ff64 Mon Sep 17 00:00:00 2001 From: Jimver Date: Tue, 3 Jun 2025 22:11:58 +0000 Subject: [PATCH 05/12] Improve log file path --- src/downloader.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/downloader.ts b/src/downloader.ts index dc181995..44829471 100644 --- a/src/downloader.ts +++ b/src/downloader.ts @@ -85,8 +85,8 @@ export async function download( } if (useGitHubCache) { // Move file to GitHub cache directory - core.debug(`Moving ${destFilePath} to ${cacheDirectory}`) const cachePath = `${cacheDirectory}/${destFilePath}` + core.debug(`Moving ${destFilePath} to ${cachePath}`) await io.mkdirP(cacheDirectory) await io.mv(destFilePath, cachePath) // List files in cache directory From 1c60517e10dc21878d2fbf40ab8394b77bca1371 Mon Sep 17 00:00:00 2001 From: Jimver Date: Tue, 3 Jun 2025 22:18:28 +0000 Subject: [PATCH 06/12] Add test file to cachePath --- src/downloader.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/downloader.ts b/src/downloader.ts index 44829471..59deb9b6 100644 --- a/src/downloader.ts +++ b/src/downloader.ts @@ -89,6 +89,13 @@ export async function download( core.debug(`Moving ${destFilePath} to ${cachePath}`) await io.mkdirP(cacheDirectory) await io.mv(destFilePath, cachePath) + // Create test file in cacheDirectory + const testFilePath = `${cacheDirectory}/test.txt` + core.debug(`Creating test file at ${testFilePath}`) + await fs.promises.writeFile( + testFilePath, + `This is a test file to verify that the cache directory is working correctly.` + ) // List files in cache directory const filesInCacheDirectory = await ( await glob.create(`${cacheDirectory}/**`) From 7d8dee3f8fabf187e18565b6617762f1df4a55da Mon Sep 17 00:00:00 2001 From: Jimver Date: Tue, 3 Jun 2025 22:22:15 +0000 Subject: [PATCH 07/12] Fix cache path --- src/downloader.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/downloader.ts b/src/downloader.ts index 59deb9b6..d0b368aa 100644 --- a/src/downloader.ts +++ b/src/downloader.ts @@ -85,7 +85,7 @@ export async function download( } if (useGitHubCache) { // Move file to GitHub cache directory - const cachePath = `${cacheDirectory}/${destFilePath}` + const cachePath = `${cacheDirectory}/${destFileName}` core.debug(`Moving ${destFilePath} to ${cachePath}`) await io.mkdirP(cacheDirectory) await io.mv(destFilePath, cachePath) From a16caff28cb101b2f86a719fb857dd47da87cb0b Mon Sep 17 00:00:00 2001 From: Jimver Date: Tue, 3 Jun 2025 22:24:29 +0000 Subject: [PATCH 08/12] List files using readdir --- src/downloader.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/downloader.ts b/src/downloader.ts index d0b368aa..d5c33082 100644 --- a/src/downloader.ts +++ b/src/downloader.ts @@ -96,10 +96,8 @@ export async function download( testFilePath, `This is a test file to verify that the cache directory is working correctly.` ) - // List files in cache directory - const filesInCacheDirectory = await ( - await glob.create(`${cacheDirectory}/**`) - ).glob() + // List files in cache directory using fs.promises + const filesInCacheDirectory = await fs.promises.readdir(cacheDirectory) core.debug( `Files in cache directory: ${cacheDirectory}: ${filesInCacheDirectory}` ) From 4f92b0f9d8aef87c9a36c8a7ff5d02df2465667c Mon Sep 17 00:00:00 2001 From: Jimver Date: Tue, 3 Jun 2025 22:34:00 +0000 Subject: [PATCH 09/12] Log absolute paths --- src/downloader.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/downloader.ts b/src/downloader.ts index d5c33082..de425497 100644 --- a/src/downloader.ts +++ b/src/downloader.ts @@ -96,11 +96,23 @@ export async function download( testFilePath, `This is a test file to verify that the cache directory is working correctly.` ) + // Get absolute path to the cache directory + const absoluteCacheDirectory = await fs.promises.realpath(cacheDirectory) + core.debug(`Absolute path to cache directory: ${absoluteCacheDirectory}`) + // Get absolute path to the test file + const absoluteTestFilePath = await fs.promises.realpath(testFilePath) + core.debug(`Absolute path to test file: ${absoluteTestFilePath}`) // List files in cache directory using fs.promises const filesInCacheDirectory = await fs.promises.readdir(cacheDirectory) core.debug( `Files in cache directory: ${cacheDirectory}: ${filesInCacheDirectory}` ) + // List files in cache directory using glob + const globber = await glob.create(`${cacheDirectory}/*`) + const filesInCacheDirectoryGlob = await globber.glob() + core.debug( + `Files in cache directory (glob): ${cacheDirectory}: ${filesInCacheDirectoryGlob}` + ) // Save cache directory to GitHub cache const cacheId = await cache.saveCache([cacheDirectory], cacheKey) if (cacheId !== -1) { From 40cdad089cf0ed42908fba5ebe0adb220d108f54 Mon Sep 17 00:00:00 2001 From: Jimver Date: Wed, 4 Jun 2025 19:44:03 +0000 Subject: [PATCH 10/12] Downgrade glob --- package-lock.json | 9 +++++---- package.json | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index d987694b..df0ceff4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@actions/cache": "^4.0.3", "@actions/core": "^1.11.1", "@actions/exec": "^1.1.1", - "@actions/glob": "^0.5.0", + "@actions/glob": "^0.4.0", "@actions/io": "^1.1.3", "@actions/tool-cache": "^2.0.2", "@types/semver": "^7.7.0", @@ -136,9 +136,10 @@ } }, "node_modules/@actions/glob": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.5.0.tgz", - "integrity": "sha512-tST2rjPvJLRZLuT9NMUtyBjvj9Yo0MiJS3ow004slMvm8GFM+Zv9HvMJ7HWzfUyJnGrJvDsYkWBaaG3YKXRtCw==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.4.0.tgz", + "integrity": "sha512-+eKIGFhsFa4EBwaf/GMyzCdWrXWymGXfFmZU3FHQvYS8mPcHtTtZONbkcqqUMzw9mJ/pImEBFET1JNifhqGsAQ==", + "license": "MIT", "dependencies": { "@actions/core": "^1.9.1", "minimatch": "^3.0.4" diff --git a/package.json b/package.json index 53a2be59..5c6382b9 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@actions/cache": "^4.0.3", "@actions/core": "^1.11.1", "@actions/exec": "^1.1.1", - "@actions/glob": "^0.5.0", + "@actions/glob": "^0.4.0", "@actions/io": "^1.1.3", "@actions/tool-cache": "^2.0.2", "@types/semver": "^7.7.0", From d3ae05e19d25a3463216983ef24813616281202a Mon Sep 17 00:00:00 2001 From: Jimver Date: Wed, 4 Jun 2025 19:50:31 +0000 Subject: [PATCH 11/12] Update back to glob 0.5.0 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index df0ceff4..72031118 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@actions/cache": "^4.0.3", "@actions/core": "^1.11.1", "@actions/exec": "^1.1.1", - "@actions/glob": "^0.4.0", + "@actions/glob": "^0.5.0", "@actions/io": "^1.1.3", "@actions/tool-cache": "^2.0.2", "@types/semver": "^7.7.0", @@ -136,9 +136,9 @@ } }, "node_modules/@actions/glob": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.4.0.tgz", - "integrity": "sha512-+eKIGFhsFa4EBwaf/GMyzCdWrXWymGXfFmZU3FHQvYS8mPcHtTtZONbkcqqUMzw9mJ/pImEBFET1JNifhqGsAQ==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.5.0.tgz", + "integrity": "sha512-tST2rjPvJLRZLuT9NMUtyBjvj9Yo0MiJS3ow004slMvm8GFM+Zv9HvMJ7HWzfUyJnGrJvDsYkWBaaG3YKXRtCw==", "license": "MIT", "dependencies": { "@actions/core": "^1.9.1", diff --git a/package.json b/package.json index 5c6382b9..53a2be59 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "@actions/cache": "^4.0.3", "@actions/core": "^1.11.1", "@actions/exec": "^1.1.1", - "@actions/glob": "^0.4.0", + "@actions/glob": "^0.5.0", "@actions/io": "^1.1.3", "@actions/tool-cache": "^2.0.2", "@types/semver": "^7.7.0", From 28418509c8b348945e2e06aeac8ee23d4096d42e Mon Sep 17 00:00:00 2001 From: Jimver Date: Wed, 4 Jun 2025 19:50:45 +0000 Subject: [PATCH 12/12] Add test file in current directory --- src/downloader.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/downloader.ts b/src/downloader.ts index de425497..a2ab99bb 100644 --- a/src/downloader.ts +++ b/src/downloader.ts @@ -96,6 +96,13 @@ export async function download( testFilePath, `This is a test file to verify that the cache directory is working correctly.` ) + //create test file in current directory + const testFileCurrentPath = `test.txt` + core.debug(`Creating test file at ${testFileCurrentPath}`) + await fs.promises.writeFile( + testFileCurrentPath, + `This is a test file to verify that the current directory is working correctly.` + ) // Get absolute path to the cache directory const absoluteCacheDirectory = await fs.promises.realpath(cacheDirectory) core.debug(`Absolute path to cache directory: ${absoluteCacheDirectory}`) @@ -113,6 +120,15 @@ export async function download( core.debug( `Files in cache directory (glob): ${cacheDirectory}: ${filesInCacheDirectoryGlob}` ) + // List files in current directory using fs.promises + const filesInCurrentDirectory = await fs.promises.readdir('.') + core.debug(`Files in current directory: ${filesInCurrentDirectory}`) + // List files in current directory using glob + const globberCurrent = await glob.create(`./*`) + const filesInCurrentDirectoryGlob = await globberCurrent.glob() + core.debug( + `Files in current directory (glob): ${filesInCurrentDirectoryGlob}` + ) // Save cache directory to GitHub cache const cacheId = await cache.saveCache([cacheDirectory], cacheKey) if (cacheId !== -1) {