Skip to content

Commit f6c24cf

Browse files
committed
fix import
1 parent fed6564 commit f6c24cf

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

dist/index.js

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30564,14 +30564,14 @@ exports.postComment = postComment;
3056430564
const core_1 = __nccwpck_require__(2614);
3056530565
const SIGNATURE = `<sub>Created with <a href='https://github.com/ZebraDevs/flutter-code-quality'>Flutter code quality action</a></sub>`;
3056630566
const createComment = (analyze, test, coverage, behindBy) => {
30567-
const isSuccess = !analyze.error && !test.error && !coverage.error && !behindBy.error;
30567+
const isSuccess = !analyze?.error && !test?.error && !coverage?.error && !behindBy?.error;
3056830568
let output = `<h2>PR Checks complete</h2>
3056930569
<ul>
3057030570
<li>✅ - Linting / Formatting</li>
30571-
<li>${analyze.output.replaceAll("`|\"|'|<|>", "")}</li>
30572-
<li>${test.output.replaceAll("`|\"|'|<|>", "")}</li>
30573-
${isSuccess ? "<li>✅ - Branch is not behind</li>" : ""}
30574-
<li>${coverage.output.replaceAll("`|\"|'|<|>", "")}</li>
30571+
${analyze ? `<li>${analyze?.output.replaceAll("`|\"|'|<|>", "")}</li>` : ""}
30572+
${test ? `<li>${test?.output.replaceAll("`|\"|'|<|>", "")}</li>` : ""}
30573+
${behindBy && isSuccess ? "<li>✅ - Branch is not behind</li>" : ""}
30574+
${coverage ? `<li>${coverage?.output.replaceAll("`|\"|'|<|>", "")}</li>` : ""}
3057530575
</ul>
3057630576

3057730577
${SIGNATURE}
@@ -30685,7 +30685,7 @@ const getCoverage = (oldCoverage) => {
3068530685
};
3068630686
exports.getCoverage = getCoverage;
3068730687
const getOldCoverage = () => {
30688-
let value;
30688+
let value = 0;
3068930689
(0, core_1.startGroup)("Retrieving existing coverage value");
3069030690
try {
3069130691
const contents = (0, node_fs_1.readFileSync)("coverage/lcov.info", "utf8");
@@ -33153,18 +33153,26 @@ const push_1 = __nccwpck_require__(3662);
3315333153
const run = async () => {
3315433154
try {
3315533155
const token = process.env.GITHUB_TOKEN || (0, core_1.getInput)("token");
33156+
const runTests = (0, core_1.getInput)("run-tests");
33157+
const runAnalyze = (0, core_1.getInput)("run-analyze");
33158+
const runCoverage = (0, core_1.getInput)("run-coverage");
33159+
const runBehindBy = (0, core_1.getInput)("run-behind-by");
33160+
const createComment = (0, core_1.getInput)("create-comment");
3315633161
const octokit = (0, github_1.getOctokit)(token);
33157-
const behindByStr = await (0, behind_1.checkBranchStatus)(octokit, github_1.context);
33162+
const behindByStr = runBehindBy ? await (0, behind_1.checkBranchStatus)(octokit, github_1.context) : undefined;
3315833163
await (0, setup_1.setup)();
33159-
const oldCoverage = (0, coverage_1.getOldCoverage)();
33160-
const analyzeStr = await (0, analyze_1.getAnalyze)();
33161-
const testStr = await (0, runTests_1.getTest)();
33162-
const coverageStr = (0, coverage_1.getCoverage)(oldCoverage);
33163-
const comment = (0, comment_1.createComment)(analyzeStr, testStr, coverageStr, behindByStr);
33164-
(0, comment_1.postComment)(octokit, comment, github_1.context);
33164+
const oldCoverage = runCoverage ? (0, coverage_1.getOldCoverage)() : undefined;
33165+
const analyzeStr = runAnalyze ? await (0, analyze_1.getAnalyze)() : undefined;
33166+
const testStr = runTests ? await (0, runTests_1.getTest)() : undefined;
33167+
const coverageStr = runCoverage ? (0, coverage_1.getCoverage)(oldCoverage) : undefined;
33168+
const comment = createComment
33169+
? (0, comment_1.createComment)(analyzeStr, testStr, coverageStr, behindByStr)
33170+
: undefined;
33171+
if (createComment)
33172+
(0, comment_1.postComment)(octokit, comment, github_1.context);
3316533173
await (0, push_1.push)();
33166-
if (analyzeStr.error || testStr.error || coverageStr.error) {
33167-
(0, core_1.setFailed)(`${analyzeStr.output}\n${testStr.output}\n${coverageStr.output}`);
33174+
if (analyzeStr?.error || testStr?.error || coverageStr?.error) {
33175+
(0, core_1.setFailed)(`${analyzeStr?.output}\n${testStr?.output}\n${coverageStr?.output}`);
3316833176
}
3316933177
}
3317033178
catch (err) {

src/main.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getInput, setFailed } from "@actions/core";
1+
import { getBooleanInput, getInput, setFailed } from "@actions/core";
22
import { getAnalyze } from "./scripts/analyze";
33
import { getOctokit, context } from "@actions/github";
44
import { getCoverage, getOldCoverage } from "./scripts/coverage";
@@ -14,11 +14,11 @@ export type stepResponse = { output: string; error: boolean };
1414
const run = async () => {
1515
try {
1616
const token = process.env.GITHUB_TOKEN || getInput("token");
17-
const runTests = getInput("run-tests");
18-
const runAnalyze = getInput("run-analyze");
19-
const runCoverage = getInput("run-coverage");
20-
const runBehindBy = getInput("run-behind-by");
21-
const createComment = getInput("create-comment");
17+
const runTests = getBooleanInput("run-tests");
18+
const runAnalyze = getBooleanInput("run-analyze");
19+
const runCoverage = getBooleanInput("run-coverage");
20+
const runBehindBy = getBooleanInput("run-behind-by");
21+
const createComment = getBooleanInput("create-comment");
2222

2323
const octokit = getOctokit(token);
2424
const behindByStr: stepResponse | undefined = runBehindBy ? await checkBranchStatus(octokit, context) : undefined;

0 commit comments

Comments
 (0)