-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Action fails when previous commit had a failing test (#32)
- Loading branch information
1 parent
1a53f5d
commit e411b2e
Showing
4 changed files
with
45 additions
and
26 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 |
---|---|---|
|
@@ -113322,7 +113322,7 @@ const run = async (isLocal) => { | |
: undefined; | ||
if (createComment) | ||
(0, comment_1.postComment)(octokit, comment, github_1.context); | ||
await (0, push_1.push)(); | ||
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}`); | ||
} | ||
|
@@ -113687,6 +113687,7 @@ const artifact_1 = __nccwpck_require__(26984); | |
const core_1 = __nccwpck_require__(72614); | ||
const core_2 = __nccwpck_require__(72614); | ||
const adm_zip_1 = __importDefault(__nccwpck_require__(98154)); | ||
const runTests_1 = __nccwpck_require__(99054); | ||
const ARTIFACT_NAME = "coverage"; | ||
/** | ||
* Retrieve previous coverage report from the base branch | ||
|
@@ -113768,13 +113769,22 @@ exports.retrievePreviousCoverage = retrievePreviousCoverage; | |
const generatePreviousCoverage = async (prev_sha, current_branch, coverage_directory) => { | ||
const artifact = new artifact_1.DefaultArtifactClient(); | ||
await (0, exec_1.exec)(`git checkout ${prev_sha}`); | ||
await (0, exec_1.exec)(`flutter test --coverage --coverage-path ${coverage_directory}/lcov.info`); | ||
const report = await (0, utils_1.importLcov)(coverage_directory); | ||
const { id, size } = await artifact.uploadArtifact(ARTIFACT_NAME + "-" + prev_sha, [`${coverage_directory}/${utils_1.COV_FILE}`], ".", {}); | ||
(0, core_2.debug)(`Artifact uploaded with id: ${id} and size: ${size}`); | ||
await (0, exec_1.exec)(`git reset --hard`); | ||
await (0, exec_1.exec)(`git checkout ${current_branch}`); | ||
return report; | ||
let report; | ||
try { | ||
await (0, runTests_1.getTest)(coverage_directory); | ||
report = await (0, utils_1.importLcov)(coverage_directory); | ||
const { id, size } = await artifact.uploadArtifact(ARTIFACT_NAME + "-" + prev_sha, [`${coverage_directory}/${utils_1.COV_FILE}`], ".", {}); | ||
(0, core_2.debug)(`Artifact uploaded with id: ${id} and size: ${size}`); | ||
} | ||
catch (e) { | ||
console.error("Failed to run tests"); | ||
} | ||
finally { | ||
await (0, exec_1.exec)(`git reset --hard`); | ||
await (0, exec_1.exec)(`git clean -d -f .`); | ||
await (0, exec_1.exec)(`git checkout ${current_branch}`); | ||
return report; | ||
} | ||
}; | ||
|
||
|
||
|
@@ -113794,7 +113804,7 @@ const core_2 = __nccwpck_require__(72614); | |
/** | ||
* Push changes to the branch | ||
*/ | ||
const push = async () => { | ||
const push = async (coverageDirectory) => { | ||
(0, core_1.startGroup)("Check for changes"); | ||
let stdout = ""; | ||
try { | ||
|
@@ -113812,7 +113822,7 @@ const push = async () => { | |
(0, core_1.startGroup)("Push changes"); | ||
await (0, exec_1.exec)('git config --global user.name "github-actions"'); | ||
await (0, exec_1.exec)('git config --global user.email "[email protected]"'); | ||
await (0, exec_1.exec)("git add -A"); | ||
await (0, exec_1.exec)(`git add -A -- ':!${coverageDirectory}'`); | ||
(0, child_process_1.execSync)(`git commit -m 'chore(automated): Lint commit and format' `); | ||
await (0, exec_1.exec)("git push -f"); | ||
(0, core_2.debug)("Changes pushed onto branch"); | ||
|
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ import { debug } from "@actions/core"; | |
/** | ||
* Push changes to the branch | ||
*/ | ||
export const push = async () => { | ||
export const push = async (coverageDirectory: string) => { | ||
startGroup("Check for changes"); | ||
let stdout: string = ""; | ||
try { | ||
|
@@ -24,7 +24,7 @@ export const push = async () => { | |
startGroup("Push changes"); | ||
await exec('git config --global user.name "github-actions"'); | ||
await exec('git config --global user.email "[email protected]"'); | ||
await exec("git add -A"); | ||
await exec(`git add -A -- ':!${coverageDirectory}'`); | ||
execSync(`git commit -m 'chore(automated): Lint commit and format' `); | ||
await exec("git push -f"); | ||
debug("Changes pushed onto branch"); | ||
|