diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 90acfc7..305571f 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -37,5 +37,5 @@ jobs: git config --global user.name "github-actions" git config --global user.email "github-actions@github.com" git add -A - git commit -m 'ci(automated commit): lint format and import sort' + git commit -m 'ci(automated commit): Build bundled file' git push diff --git a/.gitignore b/.gitignore index bc5bcde..eb986de 100644 --- a/.gitignore +++ b/.gitignore @@ -156,13 +156,14 @@ migrate_working_dir/ # Flutter/Dart/Pub related **/doc/api/ **/ios/Flutter/.last_build_id -.dart_tool/ +**/.dart_tool/ .flutter-plugins .flutter-plugins-dependencies .pub-cache/ .pub/ build/ - - - -**/docs/addver \ No newline at end of file +**/docs/addver +*/package_config_subset +tests/pass_repo/.dart_tool/package_config_subset +tests/pass_repo/.dart_tool/package_config.json +tests/pass_repo/build/test_cache/build/cache.dill.track.dill diff --git a/dist/index.js b/dist/index.js index 3ca252b..1f8f232 100644 --- a/dist/index.js +++ b/dist/index.js @@ -30776,8 +30776,7 @@ const getTest = async () => { const obj = JSON.parse(objStr); let failIds = []; obj.forEach((element) => { - if (element.type == "testDone" && - element.result.toLowerCase() == "error") { + if (element.type == "testDone" && element.result.toLowerCase() == "error") { failIds.push(element.testID); } }); @@ -30791,18 +30790,14 @@ const getTest = async () => { const errorString = []; failIds.forEach((e1) => { const allEntries = obj.filter((e) => (e.hasOwnProperty("testID") && e.testID == e1) || - (e.hasOwnProperty("test") && - e.test.hasOwnProperty("id") && - e.test.id == e1)); + (e.hasOwnProperty("test") && e.test.hasOwnProperty("id") && e.test.id == e1)); const entry1 = allEntries.find((e) => e.hasOwnProperty("test") && e.test.hasOwnProperty("id")); let testName = "Error getting test name"; if (entry1) { testName = entry1.test.name.split("/test/").slice(-1); } const entry2 = allEntries.find((e) => e.hasOwnProperty("stackTrace") && e.stackTrace.length > 1); - const entry3 = allEntries.find((e) => e.hasOwnProperty("message") && - e.message.length > 1 && - e.message.includes("EXCEPTION CAUGHT BY FLUTTER")); + const entry3 = allEntries.find((e) => e.hasOwnProperty("message") && e.message.length > 1 && e.message.includes("EXCEPTION CAUGHT BY FLUTTER")); const entry4 = allEntries.find((e) => e.hasOwnProperty("error") && e.error.length > 1); let testDetails = "Unable to get test details. Run flutter test to replicate"; if (entry2) { @@ -30814,11 +30809,7 @@ const getTest = async () => { else if (entry4) { testDetails = entry4.error; } - errorString.push("
" + - testName + - "
`" + - testDetails + - "`
"); + errorString.push("
" + testName + "
`" + testDetails + "`
"); }); const output = `⛔️ - ${initialString}
See details @@ -33152,17 +33143,25 @@ const setup_1 = __nccwpck_require__(9346); const behind_1 = __nccwpck_require__(8890); const push_1 = __nccwpck_require__(3662); const run = async () => { - const token = process.env.GITHUB_TOKEN || (0, core_1.getInput)("token"); - const octokit = (0, github_1.getOctokit)(token); - const behindByStr = await (0, behind_1.checkBranchStatus)(octokit, github_1.context); - await (0, setup_1.setup)(); - const oldCoverage = (0, coverage_1.getOldCoverage)(); - const analyzeStr = await (0, analyze_1.getAnalyze)(); - const testStr = await (0, runTests_1.getTest)(); - const coverageStr = await (0, coverage_1.getCoverage)(oldCoverage); - const comment = (0, comment_1.createComment)(analyzeStr, testStr, coverageStr, behindByStr); - (0, comment_1.postComment)(octokit, comment, github_1.context); - await (0, push_1.push)(); + try { + const token = process.env.GITHUB_TOKEN || (0, core_1.getInput)("token"); + const octokit = (0, github_1.getOctokit)(token); + const behindByStr = await (0, behind_1.checkBranchStatus)(octokit, github_1.context); + await (0, setup_1.setup)(); + const oldCoverage = (0, coverage_1.getOldCoverage)(); + const analyzeStr = await (0, analyze_1.getAnalyze)(); + const testStr = await (0, runTests_1.getTest)(); + const coverageStr = await (0, coverage_1.getCoverage)(oldCoverage); + const comment = (0, comment_1.createComment)(analyzeStr, testStr, coverageStr, behindByStr); + (0, comment_1.postComment)(octokit, comment, github_1.context); + await (0, push_1.push)(); + if (analyzeStr.error || testStr.error || coverageStr.error) { + (0, core_1.setFailed)(`${analyzeStr.output}\n${testStr.output}\n${coverageStr.output}`); + } + } + catch (err) { + (0, core_1.setFailed)(`Action failed with error ${err}`); + } }; run(); diff --git a/src/main.ts b/src/main.ts index 0ebe432..9d3e478 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,4 @@ -import { getInput } from "@actions/core"; +import { getInput, setFailed } from "@actions/core"; import { getAnalyze } from "./scripts/analyze"; import { getOctokit, context } from "@actions/github"; import { getCoverage, getOldCoverage } from "./scripts/coverage"; @@ -11,17 +11,28 @@ import { push } from "./scripts/push"; export type stepResponse = { output: string; error: boolean }; const run = async () => { - const token = process.env.GITHUB_TOKEN || getInput("token"); - const octokit = getOctokit(token); - const behindByStr = await checkBranchStatus(octokit, context); - await setup(); - const oldCoverage: number | undefined = getOldCoverage(); - const analyzeStr: stepResponse = await getAnalyze(); - const testStr: stepResponse = await getTest(); - const coverageStr: stepResponse = await getCoverage(oldCoverage); - const comment = createComment(analyzeStr, testStr, coverageStr, behindByStr); - postComment(octokit, comment, context); - await push(); + try { + const token = process.env.GITHUB_TOKEN || getInput("token"); + const octokit = getOctokit(token); + const behindByStr = await checkBranchStatus(octokit, context); + await setup(); + const oldCoverage: number | undefined = getOldCoverage(); + + const analyzeStr: stepResponse = await getAnalyze(); + const testStr: stepResponse = await getTest(); + const coverageStr: stepResponse = await getCoverage(oldCoverage); + + const comment = createComment(analyzeStr, testStr, coverageStr, behindByStr); + + postComment(octokit, comment, context); + await push(); + + if (analyzeStr.error || testStr.error || coverageStr.error) { + setFailed(`${analyzeStr.output}\n${testStr.output}\n${coverageStr.output}`); + } + } catch (err) { + setFailed(`Action failed with error ${err}`); + } }; run(); diff --git a/src/scripts/analyze.ts b/src/scripts/analyze.ts index a129817..0bc04c9 100644 --- a/src/scripts/analyze.ts +++ b/src/scripts/analyze.ts @@ -57,9 +57,9 @@ export const getAnalyze = async (): Promise => { const output = `${ANALYZE_FAILURE}; ${issuesFound}
See details - ${errorString.join( - "" - )}${warningString.join("")}${infoString.join("")}
TypeFile nameDetails
+ TypeFile nameDetails${errorString.join("")}${warningString.join( + "" + )}${infoString.join("")}
`; response = { output: output, error: true }; @@ -84,6 +84,4 @@ export const getErrEmoji = (errType: analyzeErrTypes) => { }; export const generateTableRow = (err: analyzeDetails, type: analyzeErrTypes) => - `${getErrEmoji(type)}Error${err.file}${ - err.details - }`; + `${getErrEmoji(type)}Error${err.file}${err.details}`; diff --git a/src/scripts/comment.ts b/src/scripts/comment.ts index d3e77da..8798115 100644 --- a/src/scripts/comment.ts +++ b/src/scripts/comment.ts @@ -11,8 +11,7 @@ export const createComment = ( coverage: stepResponse, behindBy: stepResponse ): string => { - const isSuccess = - !analyze.error && !test.error && !coverage.error && !behindBy.error; + const isSuccess = !analyze.error && !test.error && !coverage.error && !behindBy.error; let output = `

PR Checks complete