mirror of
https://github.com/rharkor/caching-for-turbo.git
synced 2025-06-08 01:37:01 +09:00
fix: load
This commit is contained in:
parent
eaf205505c
commit
b778df7dc9
5 changed files with 15 additions and 41 deletions
27
.github/workflows/ci.yml
vendored
27
.github/workflows/ci.yml
vendored
|
@ -110,30 +110,3 @@ jobs:
|
|||
|
||||
- name: Test build cache (full cache)
|
||||
run: ./check-full-turbo.sh
|
||||
|
||||
#? This step test nothing, the goal is to see if we can fetch an already saved cache from another run
|
||||
test-action-all-time-cache:
|
||||
name: GitHub Actions Test (All Time Cache)
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
id: checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
id: setup-node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: .node-version
|
||||
cache: npm
|
||||
|
||||
- name: Install Dependencies
|
||||
id: npm-ci
|
||||
run: npm ci
|
||||
|
||||
- name: Test Local Action
|
||||
uses: ./
|
||||
|
||||
- name: Test build cache
|
||||
run: npm run test
|
||||
|
|
12
dist/setup/index.js
generated
vendored
12
dist/setup/index.js
generated
vendored
|
@ -126839,8 +126839,8 @@ async function getCache(ctx, hash) {
|
|||
//* Get cache from cache API
|
||||
const client = (0, utils_1.getCacheClient)();
|
||||
const cacheKey = (0, constants_1.getCacheKey)(hash);
|
||||
const { data } = await client.query(cacheKey, constants_1.cachePath);
|
||||
ctx.log.info(`Cache lookup for ${cacheKey} (path: ${constants_1.cachePath})`);
|
||||
const { data } = await client.query((0, constants_1.getTempCachePath)(cacheKey), cacheKey);
|
||||
ctx.log.info(`Cache lookup for ${cacheKey}`);
|
||||
if (!data) {
|
||||
ctx.log.info(`Cache lookup did not return data`);
|
||||
return null;
|
||||
|
@ -126956,6 +126956,7 @@ function getCacheClient() {
|
|||
const writeStream = (0, node_fs_1.createWriteStream)(tempFile);
|
||||
await (0, stream_to_promise_1.default)(stream.pipe(writeStream));
|
||||
core.info(`Saved cache to ${tempFile}`);
|
||||
core.info(`Saving cache for key: ${key}, path: ${tempFile}`);
|
||||
await (0, cache_1.saveCache)([tempFile], key);
|
||||
core.info(`Saved cache ${key}`);
|
||||
//* Remove the temporary file
|
||||
|
@ -126965,9 +126966,8 @@ function getCacheClient() {
|
|||
handleFetchError('Unable to upload cache')(error);
|
||||
}
|
||||
};
|
||||
const query = async (key,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
path) => {
|
||||
const query = async (path, key) => {
|
||||
core.info(`Querying cache for key: ${key}, path: ${path}`);
|
||||
const keys = [key];
|
||||
core.debug('Resolved Keys:');
|
||||
core.debug(JSON.stringify(keys));
|
||||
|
@ -126983,7 +126983,7 @@ function getCacheClient() {
|
|||
const request = {
|
||||
key,
|
||||
restoreKeys: [],
|
||||
version: utils.getCacheVersion([key], compressionMethod, false)
|
||||
version: utils.getCacheVersion([path], compressionMethod, false)
|
||||
};
|
||||
const response = await twirpClient.GetCacheEntryDownloadURL(request);
|
||||
if (!response.ok) {
|
||||
|
|
2
dist/setup/index.js.map
generated
vendored
2
dist/setup/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
6
src/lib/cache/index.ts
vendored
6
src/lib/cache/index.ts
vendored
|
@ -8,7 +8,7 @@ import {
|
|||
statSync
|
||||
} from 'node:fs'
|
||||
import { getCacheClient } from './utils'
|
||||
import { cachePath, getCacheKey, getFsCachePath } from '../constants'
|
||||
import { getCacheKey, getFsCachePath, getTempCachePath } from '../constants'
|
||||
|
||||
type RequestContext = {
|
||||
log: {
|
||||
|
@ -52,8 +52,8 @@ export async function getCache(
|
|||
//* Get cache from cache API
|
||||
const client = getCacheClient()
|
||||
const cacheKey = getCacheKey(hash)
|
||||
const { data } = await client.query(cacheKey, cachePath)
|
||||
ctx.log.info(`Cache lookup for ${cacheKey} (path: ${cachePath})`)
|
||||
const { data } = await client.query(getTempCachePath(cacheKey), cacheKey)
|
||||
ctx.log.info(`Cache lookup for ${cacheKey}`)
|
||||
if (!data) {
|
||||
ctx.log.info(`Cache lookup did not return data`)
|
||||
return null
|
||||
|
|
9
src/lib/cache/utils.ts
vendored
9
src/lib/cache/utils.ts
vendored
|
@ -61,6 +61,7 @@ export function getCacheClient() {
|
|||
await streamToPromise(stream.pipe(writeStream))
|
||||
core.info(`Saved cache to ${tempFile}`)
|
||||
|
||||
core.info(`Saving cache for key: ${key}, path: ${tempFile}`)
|
||||
await saveCache([tempFile], key)
|
||||
core.info(`Saved cache ${key}`)
|
||||
|
||||
|
@ -72,13 +73,13 @@ export function getCacheClient() {
|
|||
}
|
||||
|
||||
const query = async (
|
||||
key: string,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
path: string
|
||||
path: string,
|
||||
key: string
|
||||
): Promise<{
|
||||
success: boolean
|
||||
data?: { cacheKey: string; archiveLocation: string }
|
||||
}> => {
|
||||
core.info(`Querying cache for key: ${key}, path: ${path}`)
|
||||
const keys = [key]
|
||||
|
||||
core.debug('Resolved Keys:')
|
||||
|
@ -100,7 +101,7 @@ export function getCacheClient() {
|
|||
const request: GetCacheEntryDownloadURLRequest = {
|
||||
key,
|
||||
restoreKeys: [],
|
||||
version: utils.getCacheVersion([key], compressionMethod, false)
|
||||
version: utils.getCacheVersion([path], compressionMethod, false)
|
||||
}
|
||||
|
||||
const response = await twirpClient.GetCacheEntryDownloadURL(request)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue