generated from actions/typescript-action
-
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.
update .gitignore, enhance VSCode launch configuration, and refactor …
…error handling in main.ts and testing.ts
- Loading branch information
Showing
7 changed files
with
94 additions
and
70 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 |
---|---|---|
|
@@ -104,4 +104,5 @@ __tests__/runner/* | |
# TS Docs | ||
docs | ||
|
||
# VSCode | ||
.vscode |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
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
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 |
---|---|---|
@@ -1,18 +1,30 @@ | ||
import { exec } from "@actions/exec"; | ||
import { setFailed } from "@actions/core"; | ||
import { stepResponse } from "src/main"; | ||
import { stepResponse, failedEmoji, passedEmoji, runCommand } from "src/main"; | ||
|
||
export const testing = async (): Promise<stepResponse> => { | ||
try { | ||
// Run tests and generate coverage | ||
await exec("npm run test -- --coverage"); | ||
const results = [ | ||
{ label: "Testing", command: "npm run test -- --coverage" }, | ||
{ label: "TSDoc", command: "npm run docs" }, | ||
]; | ||
|
||
// Test tsdoc | ||
await exec("npm run docs"); | ||
let commentBody = "\n"; | ||
let errorMessages = ""; | ||
|
||
return { output: "Testing complete", error: false }; | ||
} catch (error) { | ||
if (error instanceof Error) setFailed(error.message); | ||
return { output: "Testing failed", error: true }; | ||
for (const { label, command } of results) { | ||
const result = await runCommand(command, label); | ||
if (result) { | ||
commentBody += `${failedEmoji} - ${label}\n`; | ||
errorMessages += `${result}\n`; | ||
} else { | ||
commentBody += `${passedEmoji} - ${label}\n`; | ||
} | ||
} | ||
|
||
if (errorMessages) { | ||
setFailed(errorMessages.trim()); | ||
return { output: commentBody.trim(), error: true }; | ||
} else { | ||
return { output: commentBody.trim(), error: false }; | ||
} | ||
}; |