From 08316f5f4c69100fc255620013e2d35d330fb52a Mon Sep 17 00:00:00 2001 From: James Ives Date: Wed, 20 Nov 2019 09:13:01 -0500 Subject: [PATCH] Test PR (#59) * Update README.md * test setup * Update build.yml --- .github/workflows/build.yml | 2 +- __tests__/env.js | 1 + jest.config.js | 3 ++- src/constants.ts | 1 + src/git.ts | 4 ++-- 5 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 __tests__/env.js diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9c1e1cb9..ce561fc9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,5 @@ name: unit-tests -on: [push, pull_request] +on: [pull_request, push] jobs: unit-test: runs-on: ubuntu-latest diff --git a/__tests__/env.js b/__tests__/env.js new file mode 100644 index 00000000..e79aacd9 --- /dev/null +++ b/__tests__/env.js @@ -0,0 +1 @@ +process.env.UNIT_TEST = true \ No newline at end of file diff --git a/jest.config.js b/jest.config.js index 563d4ccb..6114ff66 100644 --- a/jest.config.js +++ b/jest.config.js @@ -7,5 +7,6 @@ module.exports = { transform: { '^.+\\.ts$': 'ts-jest' }, - verbose: true + verbose: true, + setupFiles: ["/__tests__/env.js"] } \ No newline at end of file diff --git a/src/constants.ts b/src/constants.ts index 12d9fe03..ef5cab82 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -6,6 +6,7 @@ const { pusher, repository } = github.context.payload; export const workspace: any = process.env.GITHUB_WORKSPACE; export const folder = core.getInput("FOLDER", { required: true }); export const root = "."; +export const isTest = process.env.UNIT_TEST; // Required action data. export const action = { diff --git a/src/git.ts b/src/git.ts index 82b92c55..4d94d58f 100644 --- a/src/git.ts +++ b/src/git.ts @@ -1,7 +1,7 @@ import * as core from "@actions/core"; import { cp } from "@actions/io"; import { execute } from "./util"; -import { workspace, action, root, repositoryPath } from "./constants"; +import { workspace, action, root, repositoryPath, isTest } from "./constants"; /** Generates the branch if it doesn't exist on the remote. * @returns {Promise} @@ -104,7 +104,7 @@ export async function deploy(): Promise { temporaryDeploymentDirectory ); - if (!hasFilesToCommit && workspace) { + if (!hasFilesToCommit && !isTest) { console.log("There is nothing to commit. Exiting..."); return Promise.resolve(); }