mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-05-20 14:44:46 +00:00
Enhancement: Allow usage when GITHUB_REF or ACTIONS_CACHE_REF are defined
This commit is contained in:
parent
16a133d9a7
commit
77fd223211
7 changed files with 792 additions and 638 deletions
|
@ -4,7 +4,7 @@ import { promises as fs } from "fs";
|
|||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
|
||||
import { Events, Outputs, RefKey, State } from "../src/constants";
|
||||
import { Events, Outputs, RefKeys, State } from "../src/constants";
|
||||
import { ArtifactCacheEntry } from "../src/contracts";
|
||||
import * as actionUtils from "../src/utils/actionUtils";
|
||||
|
||||
|
@ -19,7 +19,8 @@ function getTempDir(): string {
|
|||
|
||||
afterEach(() => {
|
||||
delete process.env[Events.Key];
|
||||
delete process.env[RefKey];
|
||||
|
||||
RefKeys.forEach(refKey => delete process.env[refKey]);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
|
@ -326,16 +327,23 @@ test("resolvePaths exclusion pattern returns not found", async () => {
|
|||
}
|
||||
});
|
||||
|
||||
test("isValidEvent returns true for event that has a ref", () => {
|
||||
const event = Events.Push;
|
||||
process.env[Events.Key] = event;
|
||||
process.env[RefKey] = "ref/heads/feature";
|
||||
|
||||
const isValidEvent = actionUtils.isValidEvent();
|
||||
|
||||
expect(isValidEvent).toBe(true);
|
||||
const refKeySet = RefKeys.map(refKey => {
|
||||
return [refKey];
|
||||
});
|
||||
|
||||
test.each(refKeySet)(
|
||||
"isValidEvent returns true for event that has a ref",
|
||||
refKey => {
|
||||
const event = Events.Push;
|
||||
process.env[Events.Key] = event;
|
||||
process.env[refKey] = "ref/heads/feature";
|
||||
|
||||
const isValidEvent = actionUtils.isValidEvent();
|
||||
|
||||
expect(isValidEvent).toBe(true);
|
||||
}
|
||||
);
|
||||
|
||||
test("unlinkFile unlinks file", async () => {
|
||||
const testDirectory = await fs.mkdtemp("unlinkFileTest");
|
||||
const testFile = path.join(testDirectory, "test.txt");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue