diff --git a/__tests__/git.test.ts b/__tests__/git.test.ts index fba3a2da..46879efa 100644 --- a/__tests__/git.test.ts +++ b/__tests__/git.test.ts @@ -35,9 +35,8 @@ describe("git", () => { } }); - const call = await init(); + await init(); expect(execute).toBeCalledTimes(6); - expect(call).toBe("Initialization step complete..."); }); it("should execute commands if an Access Token is provided", async () => { @@ -51,10 +50,8 @@ describe("git", () => { } }); - const call = await init(); - + await init(); expect(execute).toBeCalledTimes(6); - expect(call).toBe("Initialization step complete..."); }); it("should execute commands if SSH is true", async () => { @@ -68,10 +65,9 @@ describe("git", () => { } }); - const call = await init(); + await init(); expect(execute).toBeCalledTimes(6); - expect(call).toBe("Initialization step complete..."); }); it("should fail if there is no provided GitHub Token, Access Token or SSH bool", async () => { @@ -87,10 +83,9 @@ describe("git", () => { ssh: null }); - const call = await init(); + await init(); expect(setFailed).toBeCalledTimes(1); expect(execute).toBeCalledTimes(0); - expect(call).toBe("Initialization step complete..."); }); it("should fail if the build folder begins with a /", async () => { @@ -104,11 +99,10 @@ describe("git", () => { } }); - const call = await init(); + await init(); expect(setFailed).toBeCalledTimes(1); expect(execute).toBeCalledTimes(0); - expect(call).toBe("Initialization step complete..."); }); it("should fail if the build folder begins with a ./", async () => { @@ -122,10 +116,9 @@ describe("git", () => { } }); - const call = await init(); + await init(); expect(setFailed).toBeCalledTimes(1); expect(execute).toBeCalledTimes(0); - expect(call).toBe("Initialization step complete..."); }); it("should not fail if root is used", async () => { @@ -139,10 +132,9 @@ describe("git", () => { } }); - const call = await init(); + await init(); expect(execute).toBeCalledTimes(6); - expect(call).toBe("Initialization step complete..."); }); }); @@ -158,9 +150,8 @@ describe("git", () => { } }); - const call = await generateBranch(); + await generateBranch(); expect(execute).toBeCalledTimes(6); - expect(call).toBe("Deployment branch creation step complete... ✅"); }); it("should fail if there is no branch", async () => { @@ -174,10 +165,9 @@ describe("git", () => { } }); - const call = await generateBranch(); + await generateBranch(); expect(execute).toBeCalledTimes(0); expect(setFailed).toBeCalledTimes(1); - expect(call).toBe("Deployment branch creation step complete... ✅"); }); }); diff --git a/src/git.ts b/src/git.ts index df7d78d6..9b0a1020 100644 --- a/src/git.ts +++ b/src/git.ts @@ -12,7 +12,7 @@ import { isNullOrUndefined } from "./util"; /** Generates the branch if it doesn't exist on the remote. * @returns {Promise} */ -export async function init(): Promise { +export async function init(): Promise { try { if ( isNullOrUndefined(action.accessToken) && @@ -48,14 +48,14 @@ export async function init(): Promise { } catch (error) { console.log(`There was an error initializing the repository: ${error}`); } finally { - return Promise.resolve("Initialization step complete..."); + console.log("Initialization step complete..."); } } /** Switches to the base branch. * @returns {Promise} */ -export async function switchToBaseBranch(): Promise { +export async function switchToBaseBranch(): Promise { await execute( `git checkout --progress --force ${ action.baseBranch ? action.baseBranch : action.defaultBranch @@ -69,7 +69,7 @@ export async function switchToBaseBranch(): Promise { /** Generates the branch if it doesn't exist on the remote. * @returns {Promise} */ -export async function generateBranch(): Promise { +export async function generateBranch(): Promise { try { if (isNullOrUndefined(action.branch)) { throw Error("Branch is required."); @@ -88,14 +88,14 @@ export async function generateBranch(): Promise { } catch (error) { setFailed(`There was an error creating the deployment branch: ${error} ❌`); } finally { - return Promise.resolve("Deployment branch creation step complete... ✅"); + console.log("Deployment branch creation step complete... ✅"); } } /** Runs the necessary steps to make the deployment. * @returns {Promise} */ -export async function deploy(): Promise { +export async function deploy(): Promise { const temporaryDeploymentDirectory = "gh-action-temp-deployment-folder"; const temporaryDeploymentBranch = "gh-action-temp-deployment-branch"; /* @@ -160,7 +160,7 @@ export async function deploy(): Promise { if (!hasFilesToCommit && !action.isTest) { console.log("There is nothing to commit. Exiting... ✅"); - return Promise.resolve(); + return Promise.resolve("Exiting early..."); } // Commits to GitHub. diff --git a/src/main.ts b/src/main.ts index 04440e81..beab19d9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,7 @@ import { setFailed } from "@actions/core"; import { init, deploy } from "./git"; /** Initializes and runs the action. */ -export default async function main() { +export default async function main(): Promise { try { await init(); await deploy(); diff --git a/tslint.json b/tslint.json index 44382487..0363ca3b 100644 --- a/tslint.json +++ b/tslint.json @@ -18,7 +18,7 @@ "no-implicit-dependencies": true, "no-invalid-this": true, "no-string-throw": true, - "no-unsafe-finally": false, + "no-unsafe-finally": true, "no-use-before-declare": true, "no-void-expression": [true, "ignore-arrow-function-shorthand"], "no-duplicate-imports": true,