mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-19 19:46:17 +02:00
v0.10.0
This commit is contained in:
parent
9d956bc62d
commit
0b4a0a4930
4 changed files with 26 additions and 13 deletions
12
dist/restore/index.js
vendored
12
dist/restore/index.js
vendored
|
@ -43295,7 +43295,7 @@ class CacheService {
|
||||||
restoreCache(paths, primaryKey, restoreKeys) {
|
restoreCache(paths, primaryKey, restoreKeys) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
restoreKeys = restoreKeys || [];
|
restoreKeys = restoreKeys || [];
|
||||||
const keys = [primaryKey, ...restoreKeys];
|
const keys = [primaryKey, ...restoreKeys].map(x => this.formatKey(x));
|
||||||
core.debug("Resolved Keys:");
|
core.debug("Resolved Keys:");
|
||||||
core.debug(JSON.stringify(keys));
|
core.debug(JSON.stringify(keys));
|
||||||
const compressionMethod = yield utils.getCompressionMethod();
|
const compressionMethod = yield utils.getCompressionMethod();
|
||||||
|
@ -43331,6 +43331,7 @@ class CacheService {
|
||||||
}
|
}
|
||||||
saveCache(paths, key) {
|
saveCache(paths, key) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const formattedKey = this.formatKey(key);
|
||||||
const compressionMethod = yield utils.getCompressionMethod();
|
const compressionMethod = yield utils.getCompressionMethod();
|
||||||
const cachePaths = yield utils.resolvePaths(paths);
|
const cachePaths = yield utils.resolvePaths(paths);
|
||||||
core.debug("Cache Paths:");
|
core.debug("Cache Paths:");
|
||||||
|
@ -43344,8 +43345,8 @@ class CacheService {
|
||||||
yield tar_1.listTar(archivePath, compressionMethod);
|
yield tar_1.listTar(archivePath, compressionMethod);
|
||||||
}
|
}
|
||||||
core.info(`Archive Size: ${filesize_1.default(fs_1.default.statSync(archivePath).size)}`);
|
core.info(`Archive Size: ${filesize_1.default(fs_1.default.statSync(archivePath).size)}`);
|
||||||
core.debug(`Saving Cache (ID: ${key})`);
|
core.debug(`Saving Cache (ID: ${formattedKey})`);
|
||||||
yield this.uploadToS3(key, archivePath);
|
yield this.uploadToS3(formattedKey, archivePath);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
// Try to delete the archive to save space
|
// Try to delete the archive to save space
|
||||||
|
@ -43356,7 +43357,7 @@ class CacheService {
|
||||||
core.debug(`Failed to delete archive: ${error}`);
|
core.debug(`Failed to delete archive: ${error}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return key;
|
return formattedKey;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
uploadToS3(key, archivePath) {
|
uploadToS3(key, archivePath) {
|
||||||
|
@ -43451,6 +43452,9 @@ class CacheService {
|
||||||
.replace("/", "-")
|
.replace("/", "-")
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
}
|
}
|
||||||
|
formatKey(key) {
|
||||||
|
return key.replace(/[^\w\s]/gi, "-");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exports.CacheService = CacheService;
|
exports.CacheService = CacheService;
|
||||||
|
|
||||||
|
|
12
dist/save/index.js
vendored
12
dist/save/index.js
vendored
|
@ -43295,7 +43295,7 @@ class CacheService {
|
||||||
restoreCache(paths, primaryKey, restoreKeys) {
|
restoreCache(paths, primaryKey, restoreKeys) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
restoreKeys = restoreKeys || [];
|
restoreKeys = restoreKeys || [];
|
||||||
const keys = [primaryKey, ...restoreKeys];
|
const keys = [primaryKey, ...restoreKeys].map(x => this.formatKey(x));
|
||||||
core.debug("Resolved Keys:");
|
core.debug("Resolved Keys:");
|
||||||
core.debug(JSON.stringify(keys));
|
core.debug(JSON.stringify(keys));
|
||||||
const compressionMethod = yield utils.getCompressionMethod();
|
const compressionMethod = yield utils.getCompressionMethod();
|
||||||
|
@ -43331,6 +43331,7 @@ class CacheService {
|
||||||
}
|
}
|
||||||
saveCache(paths, key) {
|
saveCache(paths, key) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const formattedKey = this.formatKey(key);
|
||||||
const compressionMethod = yield utils.getCompressionMethod();
|
const compressionMethod = yield utils.getCompressionMethod();
|
||||||
const cachePaths = yield utils.resolvePaths(paths);
|
const cachePaths = yield utils.resolvePaths(paths);
|
||||||
core.debug("Cache Paths:");
|
core.debug("Cache Paths:");
|
||||||
|
@ -43344,8 +43345,8 @@ class CacheService {
|
||||||
yield tar_1.listTar(archivePath, compressionMethod);
|
yield tar_1.listTar(archivePath, compressionMethod);
|
||||||
}
|
}
|
||||||
core.info(`Archive Size: ${filesize_1.default(fs_1.default.statSync(archivePath).size)}`);
|
core.info(`Archive Size: ${filesize_1.default(fs_1.default.statSync(archivePath).size)}`);
|
||||||
core.debug(`Saving Cache (ID: ${key})`);
|
core.debug(`Saving Cache (ID: ${formattedKey})`);
|
||||||
yield this.uploadToS3(key, archivePath);
|
yield this.uploadToS3(formattedKey, archivePath);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
// Try to delete the archive to save space
|
// Try to delete the archive to save space
|
||||||
|
@ -43356,7 +43357,7 @@ class CacheService {
|
||||||
core.debug(`Failed to delete archive: ${error}`);
|
core.debug(`Failed to delete archive: ${error}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return key;
|
return formattedKey;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
uploadToS3(key, archivePath) {
|
uploadToS3(key, archivePath) {
|
||||||
|
@ -43451,6 +43452,9 @@ class CacheService {
|
||||||
.replace("/", "-")
|
.replace("/", "-")
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
}
|
}
|
||||||
|
formatKey(key) {
|
||||||
|
return key.replace(/[^\w\s]/gi, "-");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exports.CacheService = CacheService;
|
exports.CacheService = CacheService;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "0.9.0",
|
"version": "0.10.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Cache dependencies and build outputs",
|
"description": "Cache dependencies and build outputs",
|
||||||
"main": "dist/restore/index.js",
|
"main": "dist/restore/index.js",
|
||||||
|
|
|
@ -38,7 +38,7 @@ export class CacheService {
|
||||||
restoreKeys: string[]
|
restoreKeys: string[]
|
||||||
): Promise<string | undefined> {
|
): Promise<string | undefined> {
|
||||||
restoreKeys = restoreKeys || [];
|
restoreKeys = restoreKeys || [];
|
||||||
const keys = [primaryKey, ...restoreKeys];
|
const keys = [primaryKey, ...restoreKeys].map(x => this.formatKey(x));
|
||||||
|
|
||||||
core.debug("Resolved Keys:");
|
core.debug("Resolved Keys:");
|
||||||
core.debug(JSON.stringify(keys));
|
core.debug(JSON.stringify(keys));
|
||||||
|
@ -85,6 +85,7 @@ export class CacheService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveCache(paths: string[], key: string): Promise<string> {
|
async saveCache(paths: string[], key: string): Promise<string> {
|
||||||
|
const formattedKey: string = this.formatKey(key);
|
||||||
const compressionMethod = await utils.getCompressionMethod();
|
const compressionMethod = await utils.getCompressionMethod();
|
||||||
|
|
||||||
const cachePaths = await utils.resolvePaths(paths);
|
const cachePaths = await utils.resolvePaths(paths);
|
||||||
|
@ -109,8 +110,8 @@ export class CacheService {
|
||||||
`Archive Size: ${filesize(fs.statSync(archivePath).size)}`
|
`Archive Size: ${filesize(fs.statSync(archivePath).size)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
core.debug(`Saving Cache (ID: ${key})`);
|
core.debug(`Saving Cache (ID: ${formattedKey})`);
|
||||||
await this.uploadToS3(key, archivePath);
|
await this.uploadToS3(formattedKey, archivePath);
|
||||||
} finally {
|
} finally {
|
||||||
// Try to delete the archive to save space
|
// Try to delete the archive to save space
|
||||||
try {
|
try {
|
||||||
|
@ -120,7 +121,7 @@ export class CacheService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return key;
|
return formattedKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async uploadToS3(
|
private async uploadToS3(
|
||||||
|
@ -218,4 +219,8 @@ export class CacheService {
|
||||||
.replace("/", "-")
|
.replace("/", "-")
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private formatKey(key: string): string {
|
||||||
|
return key.replace(/[^\w\s]/gi, "-");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue