Make the cache units tests better
This commit is contained in:
@@ -55,10 +55,8 @@ jobs:
|
||||
shell: bash
|
||||
run: packages/cache/__tests__/create-cache-files.sh ${{ runner.os }} ~/test-cache
|
||||
|
||||
# We're using node -e to call the functions directly available in the @actions/cache package
|
||||
- name: Save cache using saveCache()
|
||||
run: |
|
||||
node -e "(async () => { const cache = await import('./packages/cache/lib/cache.js'); await cache.saveCache(['test-cache','~/test-cache'],'test-${{ runner.os }}-${{ github.run_id }}'); })().catch(e => { console.error(e); process.exit(1); })"
|
||||
run: node packages/cache/__tests__/save-cache.mjs ${{ runner.os }} ${{ github.run_id }}
|
||||
|
||||
- name: Delete cache folders before restoring
|
||||
shell: bash
|
||||
@@ -67,8 +65,7 @@ jobs:
|
||||
rm -rf ~/test-cache
|
||||
|
||||
- name: Restore cache using restoreCache() with http-client
|
||||
run: |
|
||||
node -e "(async () => { const cache = await import('./packages/cache/lib/cache.js'); await cache.restoreCache(['test-cache','~/test-cache'],'test-${{ runner.os }}-${{ github.run_id }}',[],{useAzureSdk: false}); })().catch(e => { console.error(e); process.exit(1); })"
|
||||
run: node packages/cache/__tests__/restore-cache.mjs ${{ runner.os }} ${{ github.run_id }} false
|
||||
|
||||
- name: Verify cache restored with http-client
|
||||
shell: bash
|
||||
@@ -83,8 +80,7 @@ jobs:
|
||||
rm -rf ~/test-cache
|
||||
|
||||
- name: Restore cache using restoreCache() with Azure SDK
|
||||
run: |
|
||||
node -e "(async () => { const cache = await import('./packages/cache/lib/cache.js'); await cache.restoreCache(['test-cache','~/test-cache'],'test-${{ runner.os }}-${{ github.run_id }}'); })().catch(e => { console.error(e); process.exit(1); })"
|
||||
run: node packages/cache/__tests__/restore-cache.mjs ${{ runner.os }} ${{ github.run_id }} true
|
||||
|
||||
- name: Verify cache restored with Azure SDK
|
||||
shell: bash
|
||||
|
||||
@@ -52,10 +52,8 @@ jobs:
|
||||
shell: bash
|
||||
run: packages/cache/__tests__/create-cache-files.sh ${{ runner.os }} ~/test-cache
|
||||
|
||||
# We're using node -e to call the functions directly available in the @actions/cache package
|
||||
- name: Save cache using saveCache()
|
||||
run: |
|
||||
node -e "(async () => { const cache = await import('./packages/cache/lib/cache.js'); await cache.saveCache(['test-cache','~/test-cache'],'test-${{ runner.os }}-${{ github.run_id }}'); })().catch(e => { console.error(e); process.exit(1); })"
|
||||
run: node packages/cache/__tests__/save-cache.mjs ${{ runner.os }} ${{ github.run_id }}
|
||||
|
||||
- name: Delete cache folders before restoring
|
||||
shell: bash
|
||||
@@ -64,8 +62,7 @@ jobs:
|
||||
rm -rf ~/test-cache
|
||||
|
||||
- name: Restore cache using restoreCache() with http-client
|
||||
run: |
|
||||
node -e "(async () => { const cache = await import('./packages/cache/lib/cache.js'); await cache.restoreCache(['test-cache','~/test-cache'],'test-${{ runner.os }}-${{ github.run_id }}',[],{useAzureSdk: false}); })().catch(e => { console.error(e); process.exit(1); })"
|
||||
run: node packages/cache/__tests__/restore-cache.mjs ${{ runner.os }} ${{ github.run_id }} false
|
||||
|
||||
- name: Verify cache restored with http-client
|
||||
shell: bash
|
||||
@@ -80,8 +77,7 @@ jobs:
|
||||
rm -rf ~/test-cache
|
||||
|
||||
- name: Restore cache using restoreCache() with Azure SDK
|
||||
run: |
|
||||
node -e "(async () => { const cache = await import('./packages/cache/lib/cache.js'); await cache.restoreCache(['test-cache','~/test-cache'],'test-${{ runner.os }}-${{ github.run_id }}'); })().catch(e => { console.error(e); process.exit(1); })"
|
||||
run: node packages/cache/__tests__/restore-cache.mjs ${{ runner.os }} ${{ github.run_id }} true
|
||||
|
||||
- name: Verify cache restored with Azure SDK
|
||||
shell: bash
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env node
|
||||
// Helper script to restore cache for e2e testing
|
||||
import * as cache from '../lib/cache.js'
|
||||
|
||||
const [prefix, runId, useAzureSdk] = process.argv.slice(2)
|
||||
|
||||
if (!prefix || !runId) {
|
||||
console.error('Usage: restore-cache.mjs <prefix> <runId> [useAzureSdk]')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const key = `test-${prefix}-${runId}`
|
||||
const paths = ['test-cache', '~/test-cache']
|
||||
const options = {useAzureSdk: useAzureSdk !== 'false'}
|
||||
|
||||
console.log(`Restoring cache with key: ${key}`)
|
||||
console.log(`Paths: ${paths.join(', ')}`)
|
||||
console.log(`Using Azure SDK: ${options.useAzureSdk}`)
|
||||
|
||||
const restoredKey = await cache.restoreCache(paths, key, [], options)
|
||||
|
||||
if (restoredKey) {
|
||||
console.log(`Cache restored with key: ${restoredKey}`)
|
||||
} else {
|
||||
console.error('Cache not found')
|
||||
process.exit(1)
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env node
|
||||
// Helper script to save cache for e2e testing
|
||||
import * as cache from '../lib/cache.js'
|
||||
|
||||
const [prefix, runId] = process.argv.slice(2)
|
||||
|
||||
if (!prefix || !runId) {
|
||||
console.error('Usage: save-cache.mjs <prefix> <runId>')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const key = `test-${prefix}-${runId}`
|
||||
const paths = ['test-cache', '~/test-cache']
|
||||
|
||||
console.log(`Saving cache with key: ${key}`)
|
||||
console.log(`Paths: ${paths.join(', ')}`)
|
||||
|
||||
const cacheId = await cache.saveCache(paths, key)
|
||||
console.log(`Cache saved with ID: ${cacheId}`)
|
||||
Reference in New Issue
Block a user