Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Aug 29, 2024
1 parent b06c962 commit fa59962
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 11 deletions.
35 changes: 29 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113287,8 +113287,15 @@ const behind_1 = __nccwpck_require__(98890);
const push_1 = __nccwpck_require__(13662);
const prevCoverage_1 = __nccwpck_require__(39033);
const minimist_1 = __importDefault(__nccwpck_require__(13566));
const node_child_process_1 = __nccwpck_require__(17718);
exports.COVERAGE_DIR = ".coverage";
const run = async (isLocal) => {
try {
(0, node_child_process_1.execSync)("flutter pub get");
}
catch (e) {
console.error(e);
}
try {
const workingDirectory = isLocal ? "." : (0, core_1.getInput)("working-directory");
// Check if the working directory is different from the current directory
Expand Down Expand Up @@ -113325,9 +113332,10 @@ const run = async (isLocal) => {
: undefined;
if (createComment)
(0, comment_1.postComment)(octokit, comment, github_1.context);
await (0, push_1.push)(exports.COVERAGE_DIR);
if (analyzeStr?.error || testStr?.error || coverageStr?.error) {
(0, core_1.setFailed)(`${analyzeStr?.output}\n${testStr?.output}\n${coverageStr?.output}`);
await (0, push_1.pushChanges)(exports.COVERAGE_DIR);
const errors = [analyzeStr, testStr, coverageStr].filter((step) => step?.error);
if (errors.length > 0) {
(0, core_1.setFailed)(errors.map((step) => step?.output).join("; "));
}
}
catch (err) {
Expand Down Expand Up @@ -113806,15 +113814,15 @@ const generatePreviousCoverage = async (prev_sha, current_branch, coverage_direc
"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.push = void 0;
exports.pushChanges = void 0;
const core_1 = __nccwpck_require__(72614);
const exec_1 = __nccwpck_require__(2259);
const child_process_1 = __nccwpck_require__(32081);
const core_2 = __nccwpck_require__(72614);
/**
* Push changes to the branch
*/
const push = async (coverageDirectory) => {
const pushChanges = async (coverageDirectory) => {
(0, core_1.startGroup)("Check for changes");
let stdout = "";
try {
Expand Down Expand Up @@ -113863,7 +113871,7 @@ const push = async (coverageDirectory) => {
}
}
};
exports.push = push;
exports.pushChanges = pushChanges;


/***/ }),
Expand Down Expand Up @@ -113908,6 +113916,9 @@ const getTest = async (coverageDir) => {
failIds.push(element.testID);
}
});
if (failIds.length == 0) {
failIds = obj.filter((e) => e.hasOwnProperty("error")).map((e) => e.testID);
}
let initialString = "";
if (failIds.length > 1) {
initialString = `${failIds.length} tests failed`;
Expand Down Expand Up @@ -113941,6 +113952,10 @@ const getTest = async (coverageDir) => {
testDetails = testDetails.replace(/(?:<>'"`)/g, "");
errorString.push("<details><summary>" + testName + "</br></summary>`" + testDetails + "`</details>");
});
if (initialString == "") {
initialString = "Error running tests";
errorString.push("Unable to get test details. Run flutter test to replicate");
}
const output = `⛔️ - ${initialString}</br >
<details><summary>See details</summary>
${errorString.join("")}
Expand Down Expand Up @@ -114182,6 +114197,14 @@ module.exports = require("net");

/***/ }),

/***/ 17718:
/***/ ((module) => {

"use strict";
module.exports = require("node:child_process");

/***/ }),

/***/ 15673:
/***/ ((module) => {

Expand Down
16 changes: 12 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ import { getTest } from "./scripts/runTests";
import { createComment as getComment, postComment } from "./scripts/comment";
import { setup } from "./scripts/setup";
import { checkBranchStatus } from "./scripts/behind";
import { push } from "./scripts/push";
import { pushChanges } from "./scripts/push";
import { retrievePreviousCoverage } from "./scripts/prevCoverage";
import { Lcov } from "lcov-utils";
import minimist from "minimist";
import { execSync } from "node:child_process";

export type stepResponse = { output: string; error: boolean };
export const COVERAGE_DIR = ".coverage";

const run = async (isLocal: boolean) => {
try {
execSync("flutter pub get");
} catch (e) {
console.error(e);
}

try {
const workingDirectory = isLocal ? "." : getInput("working-directory");
// Check if the working directory is different from the current directory
Expand Down Expand Up @@ -57,10 +64,11 @@ const run = async (isLocal: boolean) => {

if (createComment) postComment(octokit, comment!, context);

await push(COVERAGE_DIR);
await pushChanges(COVERAGE_DIR);

if (analyzeStr?.error || testStr?.error || coverageStr?.error) {
setFailed(`${analyzeStr?.output}\n${testStr?.output}\n${coverageStr?.output}`);
const errors = [analyzeStr, testStr, coverageStr].filter((step) => step?.error);
if (errors.length > 0) {
setFailed(errors.map((step) => step?.output).join("; "));
}
} catch (err) {
setFailed(`Action failed with error ${err}`);
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { start } from "repl";
/**
* Push changes to the branch
*/
export const push = async (coverageDirectory: string) => {
export const pushChanges = async (coverageDirectory: string) => {
startGroup("Check for changes");
let stdout: string = "";
try {
Expand Down
8 changes: 8 additions & 0 deletions src/scripts/runTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export const getTest = async (coverageDir: string): Promise<stepResponse> => {
failIds.push(element.testID);
}
});
if (failIds.length == 0) {
failIds = obj.filter((e: any) => e.hasOwnProperty("error")).map((e: any) => e.testID);
}
let initialString = "";
if (failIds.length > 1) {
initialString = `${failIds.length} tests failed`;
Expand Down Expand Up @@ -85,6 +88,11 @@ export const getTest = async (coverageDir: string): Promise<stepResponse> => {
errorString.push("<details><summary>" + testName + "</br></summary>`" + testDetails + "`</details>");
});

if (initialString == "") {
initialString = "Error running tests";
errorString.push("Unable to get test details. Run flutter test to replicate");
}

const output = `⛔️ - ${initialString}</br >
<details><summary>See details</summary>
${errorString.join("")}
Expand Down

0 comments on commit fa59962

Please sign in to comment.