This commit is contained in:
Josh Gross 2019-11-13 10:27:25 -05:00
parent 7c937ff3b3
commit 38a34c1c26
3 changed files with 9 additions and 9 deletions

View file

@ -302,7 +302,7 @@ test("restore with a pull request event and cache found", async () => {
archiveLocation: "https://www.example.com/download"
};
const getCacheMock = jest.spyOn(cacheHttpClient, "getCacheEntry");
getCacheMock.mockImplementation(_ => {
getCacheMock.mockImplementation(() => {
return Promise.resolve(cacheEntry);
});
const tempPath = "/foo/bar";

View file

@ -13,8 +13,8 @@ export enum State {
CacheResult = "CACHE_RESULT"
}
export namespace Events {
export const Key = "GITHUB_EVENT_NAME";
export const Push = "push";
export const PullRequest = "pull_request";
export enum Events {
Key = "GITHUB_EVENT_NAME",
Push = "push",
PullRequest = "pull_request"
}

View file

@ -85,6 +85,10 @@ export function resolvePath(filePath: string): string {
return path.resolve(filePath);
}
export function getSupportedEvents(): string[] {
return [Events.Push, Events.PullRequest];
}
// Currently the cache token is only authorized for push and pull_request events
// All other events will fail when reading and saving the cache
// See GitHub Context https://help.github.com/actions/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#github-context
@ -92,7 +96,3 @@ export function isValidEvent(): boolean {
const githubEvent = process.env[Events.Key] || "";
return getSupportedEvents().includes(githubEvent);
}
export function getSupportedEvents(): string[] {
return [Events.Push, Events.PullRequest];
}