Skip to content

Log files in cache directory #396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 43 additions & 2 deletions src/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,50 @@ export async function download(
}
if (useGitHubCache) {
// Move file to GitHub cache directory
core.debug(`Copying ${destFilePath} to ${cacheDirectory}`)
const cachePath = `${cacheDirectory}/${destFileName}`
core.debug(`Moving ${destFilePath} to ${cachePath}`)
await io.mkdirP(cacheDirectory)
await io.mv(destFilePath, 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.`
)
//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}`)
// 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}`
)
// 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) {
Expand Down
Loading