-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refactor code and use helpers lib for create github actions
- Loading branch information
Showing
13 changed files
with
291 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import actions, { context } from "." | ||
|
||
describe("app", () => { | ||
it("should executes runner", async () => { | ||
const runner = jest.fn() | ||
await actions.exec(runner) | ||
expect(runner).toHaveBeenCalledTimes(1) | ||
}) | ||
}) | ||
|
||
describe("app.context", () => { | ||
it("should contains metadata", () => { | ||
expect(context.name).not.toBe("") | ||
expect(context.version).not.toBe("") | ||
}) | ||
|
||
it("should contains plugins", () => { | ||
expect(context.use("input")).not.toBeFalsy() | ||
expect(context.use("log")).not.toBeFalsy() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { | ||
ContextBuilder, | ||
InputContextPlugin, | ||
LogContextPlugin, | ||
Actions, | ||
ExecContextPlugin, | ||
} from "@kcws/github-actions" | ||
|
||
export const context = ContextBuilder.builder() | ||
.setName("example-ts") | ||
.setVersion("v1.0.0") | ||
.addPlugin(new LogContextPlugin()) | ||
.addPlugin(new InputContextPlugin()) | ||
.addPlugin(new ExecContextPlugin()) | ||
.build() | ||
|
||
export default Actions.builder(context, context => { | ||
return { | ||
name: context.use("input").optionalString("name") ?? "world", | ||
} | ||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
import { greeting } from "./next" | ||
jest.mock("@actions/core") | ||
|
||
describe("hello", () => { | ||
test("naming", () => { | ||
expect(greeting).toEqual("world") | ||
import { info } from "@actions/core" | ||
|
||
import { context } from "./app" | ||
import runner from "./index" | ||
|
||
describe("application runner", () => { | ||
test("should print info logs", async () => { | ||
await runner({ input: { name: "name" } }, context) | ||
expect(info).toHaveBeenCalledTimes(1) | ||
expect(info).toHaveBeenCalledWith("hello name") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import actions from "./core/actions" | ||
import { AppRunner } from "@kcws/github-actions" | ||
|
||
actions.exec((data, context) => { | ||
import actions from "./app" | ||
|
||
const runner: AppRunner<typeof actions> = (data, context) => { | ||
context.use("log").info("hello {name}", data.input) | ||
}) | ||
} | ||
|
||
actions.exec(runner) | ||
|
||
export default runner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
jest.mock("@actions/core") | ||
|
||
import { info } from "@actions/core" | ||
|
||
import { context } from "./app" | ||
import runner from "./post" | ||
|
||
describe("[post-hook] application runner", () => { | ||
test("should print info logs", async () => { | ||
await runner({ input: { name: "name" } }, context) | ||
expect(info).toHaveBeenCalledTimes(1) | ||
expect(info).toHaveBeenCalledWith("hello post name") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import actions from "./core/actions" | ||
import { AppRunner } from "@kcws/github-actions" | ||
|
||
actions.exec((data, context) => { | ||
import actions from "./app" | ||
|
||
const runner: AppRunner<typeof actions> = (data, context) => { | ||
context.use("log").info("hello post {name}", data.input) | ||
}) | ||
} | ||
|
||
actions.exec(runner) | ||
|
||
export default runner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
jest.mock("@actions/core") | ||
|
||
import { info } from "@actions/core" | ||
|
||
import { context } from "./app" | ||
import runner from "./pre" | ||
|
||
describe("[pre-hook] application runner", () => { | ||
test("should print info logs", async () => { | ||
await runner({ input: { name: "name" } }, context) | ||
expect(info).toHaveBeenCalledTimes(1) | ||
expect(info).toHaveBeenCalledWith("hello pre name") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import actions from "./core/actions" | ||
import { AppRunner } from "@kcws/github-actions" | ||
|
||
actions.exec((data, context) => { | ||
import actions from "./app" | ||
|
||
const runner: AppRunner<typeof actions> = (data, context) => { | ||
context.use("log").info("hello pre {name}", data.input) | ||
}) | ||
} | ||
|
||
actions.exec(runner) | ||
|
||
export default runner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.