-
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: update example with latest package
- Loading branch information
Showing
16 changed files
with
112 additions
and
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
const createConfig = require("@kcws/eslint-config") | ||
const createConfig = require("@kcws/eslint-config"); | ||
module.exports = createConfig({ | ||
cwd: __dirname, | ||
profile: "node", | ||
typescript: true, | ||
jest: true, | ||
prettier: true, | ||
ecma: "latest", | ||
}) | ||
}); |
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,2 +1,2 @@ | ||
const createConfig = require("@kcws/prettier-config") | ||
module.exports = createConfig({}) | ||
const createConfig = require("@kcws/prettier-config"); | ||
module.exports = createConfig({}); |
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 |
---|---|---|
|
@@ -2,8 +2,15 @@ | |
"name": "@kcactions/example-ts", | ||
"version": "0.1.0", | ||
"main": "lib/index.js", | ||
"homepage": "https://github.com/kc-workspace/github-actions-src/tree/main/actions/example-ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/kc-workspace/github-actions-src.git", | ||
"directory": "actions/example-ts" | ||
}, | ||
"author": { | ||
"name": "Kamontat Chantrachirathumrong", | ||
"email": "[email protected]", | ||
"url": "https://github.com/kamontat" | ||
}, | ||
"scripts": { | ||
|
@@ -18,14 +25,17 @@ | |
"@actions/github": "6.0.0", | ||
"@actions/http-client": "2.2.1", | ||
"@actions/io": "1.1.3", | ||
"@kcws/github-actions": "0.5.0" | ||
"@kcws/github-actions": "0.6.0" | ||
}, | ||
"devDependencies": { | ||
"@kcws/eslint-config": "1.21.1", | ||
"@kcws/heft-node-rig": "0.19.0", | ||
"@kcws/heft-node-rig": "0.22.0", | ||
"@kcws/prettier-config": "0.17.2", | ||
"@rushstack/heft": "0.66.18", | ||
"@types/heft-jest": "1.0.6", | ||
"@types/node": "20.14.2" | ||
}, | ||
"engines": { | ||
"node": ">=20" | ||
} | ||
} |
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,21 +1,28 @@ | ||
import actions, { context } from "." | ||
import { ContextBuilder } from "@kcws/github-actions" | ||
|
||
import app, { context } from "." | ||
|
||
describe("app", () => { | ||
it("should executes runner", async () => { | ||
const runner = jest.fn() | ||
await actions.exec(runner) | ||
await app.exec(runner) | ||
expect(runner).toHaveBeenCalledTimes(1) | ||
}) | ||
}) | ||
|
||
describe("app.context", () => { | ||
it("should contains metadata", () => { | ||
expect(context.name).not.toBe("") | ||
expect(context.version).not.toBe("") | ||
// By default package.json should not found on source code | ||
// because package.json is NOT on the same directory as source code | ||
expect(context.name).toBe("") | ||
expect(context.version).toBe("") | ||
|
||
ContextBuilder.fromContext(context) | ||
}) | ||
|
||
it("should contains plugins", () => { | ||
expect(context.use("input")).not.toBeFalsy() | ||
expect(context.use("log")).not.toBeFalsy() | ||
expect(context.use("exec")).not.toBeFalsy() | ||
}) | ||
}) |
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,16 +1,4 @@ | ||
import { AppRunner } from "@kcws/github-actions" | ||
import app from "./app" | ||
import runner from "./runners/main" | ||
|
||
import actions from "./app" | ||
|
||
const runner: AppRunner<typeof actions> = (data, context) => { | ||
const logger = context.use("log") | ||
|
||
logger.info(process.cwd()) | ||
logger.info(__dirname) | ||
logger.info("Use {0}: {1}", context.name, context.version) | ||
logger.info("hello {name}", data.input) | ||
} | ||
|
||
actions.exec(runner) | ||
|
||
export default runner | ||
app.exec(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 |
---|---|---|
@@ -1,11 +1,4 @@ | ||
import { AppRunner } from "@kcws/github-actions" | ||
import app from "./app" | ||
import runner from "./runners/post" | ||
|
||
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 | ||
app.exec(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 |
---|---|---|
@@ -1,11 +1,4 @@ | ||
import { AppRunner } from "@kcws/github-actions" | ||
import app from "./app" | ||
import runner from "./runners/pre" | ||
|
||
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 | ||
app.exec(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,22 @@ | ||
jest.mock("@actions/core") | ||
|
||
import { info } from "@actions/core" | ||
|
||
import app from "../app" | ||
import runner from "./main" | ||
|
||
describe("application runner", () => { | ||
test("should print info logs with default value", async () => { | ||
await app.exec(runner) | ||
|
||
expect(info).toHaveBeenCalled() | ||
expect(info).toHaveBeenLastCalledWith("hello world") | ||
}) | ||
|
||
test("should print info logs with custom value", async () => { | ||
await app.exec(runner, { name: "name" }) | ||
|
||
expect(info).toHaveBeenCalled() | ||
expect(info).toHaveBeenLastCalledWith("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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { AppRunner } from "@kcws/github-actions" | ||
|
||
import app from "../app" | ||
|
||
const runner: AppRunner<typeof app> = (data, context) => { | ||
const logger = context.use("log") | ||
|
||
logger.info("Use {0}: {1}", context.name, context.version) | ||
logger.info("hello {name}", data.input) | ||
} | ||
|
||
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
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,9 @@ | ||
import { AppRunner } from "@kcws/github-actions" | ||
|
||
import app from "../app" | ||
|
||
const runner: AppRunner<typeof app> = (data, context) => { | ||
context.use("log").info("hello post {name}", data.input) | ||
} | ||
|
||
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
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,9 @@ | ||
import { AppRunner } from "@kcws/github-actions" | ||
|
||
import app from "../app" | ||
|
||
const runner: AppRunner<typeof app> = (data, context) => { | ||
context.use("log").info("hello pre {name}", data.input) | ||
} | ||
|
||
export default runner |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,3 +1,2 @@ | ||
packages: | ||
- "actions/*" | ||
- "utils/*" |