Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
| e4cf4085dd |
5 changed files with 745 additions and 670 deletions
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
|
|
@ -12,9 +12,6 @@ jobs:
|
|||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install yarn
|
||||
run: npm i -g yarn
|
||||
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
|
|
@ -41,9 +38,6 @@ jobs:
|
|||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install yarn
|
||||
run: npm i -g yarn
|
||||
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@
|
|||
"@typescript-eslint/eslint-plugin": "^6.4.1",
|
||||
"@typescript-eslint/parser": "^6.4.1",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
"eslint-plugin-prettier": "^5.0.0",
|
||||
"jest": "^29.6.4",
|
||||
"prettier": "^3.0.2",
|
||||
"ts-jest": "^29.1.1",
|
||||
|
|
|
|||
42
src/index.ts
42
src/index.ts
|
|
@ -48,40 +48,6 @@ export const validate = async (argv: Argv) => {
|
|||
}
|
||||
};
|
||||
|
||||
async function isGitRepo() {
|
||||
const isGit = await exec(`git rev-parse --is-inside-work-tree`);
|
||||
return isGit.code === 0;
|
||||
}
|
||||
|
||||
async function isSaplingRepo() {
|
||||
const isSapling = await exec(`sl root`);
|
||||
return isSapling.code === 0;
|
||||
}
|
||||
|
||||
async function getDiff(): Promise<string | undefined> {
|
||||
if (await isGitRepo()) {
|
||||
const diffText = await exec(`git diff origin/HEAD...HEAD`);
|
||||
if (diffText.code > 0) {
|
||||
error("Error loading the diff\n\n" + diffText.stderr);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return diffText.stdout;
|
||||
}
|
||||
|
||||
if (await isSaplingRepo()) {
|
||||
const diffText = await exec(`sl diff -g -r '. % public()'`);
|
||||
if (diffText.code > 0) {
|
||||
error("Error loading the diff\n\n" + diffText.stderr);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return diffText.stdout;
|
||||
}
|
||||
|
||||
error("Unable to get a diff no repo was found\n");
|
||||
}
|
||||
|
||||
export const run = async (argv = process.argv) => {
|
||||
const parsed: Argv = await yargs(hideBin(argv)).options(options).argv;
|
||||
const validationError = await validate(parsed);
|
||||
|
|
@ -96,12 +62,12 @@ export const run = async (argv = process.argv) => {
|
|||
return lcovDiff(baseCoverage, compareCoverage);
|
||||
}
|
||||
|
||||
const diffText = await getDiff();
|
||||
if (!diffText) {
|
||||
return;
|
||||
const diffText = await exec(`git diff origin/HEAD...HEAD`);
|
||||
if (diffText.code > 0) {
|
||||
return error("Error loading the diff\n\n" + diffText.stderr);
|
||||
}
|
||||
|
||||
const diff = parseDiff.default(diffText);
|
||||
const diff = parseDiff.default(diffText.stdout);
|
||||
|
||||
const { percentage } = report(diff, baseCoverage);
|
||||
process.exit(percentage > 90 ? 0 : 1);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
const getCoverageForFile = (file: any, coverage: any) => {
|
||||
for (const cov of coverage) {
|
||||
const report: { [k: number]: number } = {};
|
||||
if (cov.file.replace("./", "") === file.to) {
|
||||
if (cov.file === file.to) {
|
||||
for (const detail of cov.lines.details) {
|
||||
report[detail.line] = detail.hit;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue