Compare commits
1 commit
0.x
...
renovate/p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
250016d8bf |
4 changed files with 8 additions and 48 deletions
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
|
|
@ -12,9 +12,6 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install yarn
|
|
||||||
run: npm i -g yarn
|
|
||||||
|
|
||||||
- name: Set up Node
|
- name: Set up Node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
|
|
@ -41,9 +38,6 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install yarn
|
|
||||||
run: npm i -g yarn
|
|
||||||
|
|
||||||
- name: Set up Node
|
- name: Set up Node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
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) => {
|
export const run = async (argv = process.argv) => {
|
||||||
const parsed: Argv = await yargs(hideBin(argv)).options(options).argv;
|
const parsed: Argv = await yargs(hideBin(argv)).options(options).argv;
|
||||||
const validationError = await validate(parsed);
|
const validationError = await validate(parsed);
|
||||||
|
|
@ -96,12 +62,12 @@ export const run = async (argv = process.argv) => {
|
||||||
return lcovDiff(baseCoverage, compareCoverage);
|
return lcovDiff(baseCoverage, compareCoverage);
|
||||||
}
|
}
|
||||||
|
|
||||||
const diffText = await getDiff();
|
const diffText = await exec(`git diff origin/HEAD...HEAD`);
|
||||||
if (!diffText) {
|
if (diffText.code > 0) {
|
||||||
return;
|
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);
|
const { percentage } = report(diff, baseCoverage);
|
||||||
process.exit(percentage > 90 ? 0 : 1);
|
process.exit(percentage > 90 ? 0 : 1);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
const getCoverageForFile = (file: any, coverage: any) => {
|
const getCoverageForFile = (file: any, coverage: any) => {
|
||||||
for (const cov of coverage) {
|
for (const cov of coverage) {
|
||||||
const report: { [k: number]: number } = {};
|
const report: { [k: number]: number } = {};
|
||||||
if (cov.file.replace("./", "") === file.to) {
|
if (cov.file === file.to) {
|
||||||
for (const detail of cov.lines.details) {
|
for (const detail of cov.lines.details) {
|
||||||
report[detail.line] = detail.hit;
|
report[detail.line] = detail.hit;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2498,9 +2498,9 @@ prettier-linter-helpers@^1.0.0:
|
||||||
fast-diff "^1.1.2"
|
fast-diff "^1.1.2"
|
||||||
|
|
||||||
prettier@^3.0.2:
|
prettier@^3.0.2:
|
||||||
version "3.0.2"
|
version "3.3.3"
|
||||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.2.tgz#78fcecd6d870551aa5547437cdae39d4701dca5b"
|
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.3.3.tgz#30c54fe0be0d8d12e6ae61dbb10109ea00d53105"
|
||||||
integrity sha512-o2YR9qtniXvwEZlOKbveKfDQVyqxbEIWn48Z8m3ZJjBjcCmUy3xZGIv+7AkaeuaTr6yPXJjwv07ZWlsWbEy1rQ==
|
integrity sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==
|
||||||
|
|
||||||
pretty-format@^29.0.0, pretty-format@^29.7.0:
|
pretty-format@^29.0.0, pretty-format@^29.7.0:
|
||||||
version "29.7.0"
|
version "29.7.0"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue