Skip to content

Commit

Permalink
test cache
Browse files Browse the repository at this point in the history
  • Loading branch information
nha committed Jan 29, 2024
1 parent cd349d1 commit 761d2af
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/check_url.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,14 @@ jobs:

- name: Check if bb runs fine from cache
run: bb --version

- name: Test Cache
run: |
if [ -z "${{ steps.setup-babashka-1.outputs.cache-hit }}" ]; then
echo "Cache-hit output not set in first run. Failing the job."
exit 1
elif [ "${{ steps.setup-babashka-2.outputs.cache-hit }}" != "true" ]; then
echo "Cache not used in the second run. Failing the job."
exit 1
fi
shell: bash
11 changes: 11 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,14 @@ jobs:

- name: Check bb runs
run: bb --version

- name: Test Cache
run: |
if [ -z "${{ steps.setup-babashka-1.outputs.cache-hit }}" ]; then
echo "Cache-hit output not set in first run. Failing the job."
exit 1
elif [ "${{ steps.setup-babashka-2.outputs.cache-hit }}" != "true" ]; then
echo "Cache not used in the second run. Failing the job."
exit 1
fi
shell: bash
13 changes: 8 additions & 5 deletions .github/workflows/self_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ jobs:
with:
babashka-version: ${{ matrix.babashka-version }}

- name: Check if bb runs fine from cache
run: bb --version

- name: Test Cache
run: |
if [ "${{ steps.setup-babashka-1.outputs.cache-hit }}" != "true" ] && [ "${{ steps.setup-babashka-2.outputs.cache-hit }}" != "true" ]; then
echo "Cache not used. Failing the job."
if [ -z "${{ steps.setup-babashka-1.outputs.cache-hit }}" ]; then
echo "Cache-hit output not set in first run. Failing the job."
exit 1
elif [ "${{ steps.setup-babashka-2.outputs.cache-hit }}" != "true" ]; then
echo "Cache not used in the second run. Failing the job."
exit 1
fi
shell: bash

- name: Check if bb runs fine from cache
run: bb --version
8 changes: 2 additions & 6 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,13 @@ export async function installFromUrl(

if (!folder) {
core.error(`Unsupported babashka-url ${url}`)
core.setFailed(
'babashka-url format is unknown. Must me .tar.gz, .zip or .7z'
)
core.setFailed('babashka-url format is unknown. Must me .tar.gz, .zip or .7z')
return
} else {
const stats = fs.statSync(folder)
const fileSizeInBytes = stats.size
const fileSizeInMegabytes = fileSizeInBytes / (1024 * 1024)
core.debug(
`Extracted folder ${folder} is ${fileSizeInMegabytes}MB, isDir:${stats.isDirectory()}, isFile:${stats.isFile()}`
)
core.debug(`Extracted folder ${folder} is ${fileSizeInMegabytes}MB, isDir:${stats.isDirectory()}, isFile:${stats.isFile()}`)
const extractedFiles = fs.readdirSync(folder)
core.debug(`Extracted files are ${extractedFiles}`)
}
Expand Down

0 comments on commit 761d2af

Please sign in to comment.