Compare commits
2 commits
renovate/n
...
0.x
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e3d0b5a9d | |||
| 7610b3bef5 |
4 changed files with 54 additions and 21 deletions
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
|
|
@ -12,6 +12,9 @@ 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:
|
||||||
|
|
@ -38,6 +41,9 @@ 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,6 +48,40 @@ 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);
|
||||||
|
|
@ -62,12 +96,12 @@ export const run = async (argv = process.argv) => {
|
||||||
return lcovDiff(baseCoverage, compareCoverage);
|
return lcovDiff(baseCoverage, compareCoverage);
|
||||||
}
|
}
|
||||||
|
|
||||||
const diffText = await exec(`git diff origin/HEAD...HEAD`);
|
const diffText = await getDiff();
|
||||||
if (diffText.code > 0) {
|
if (!diffText) {
|
||||||
return error("Error loading the diff\n\n" + diffText.stderr);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const diff = parseDiff.default(diffText.stdout);
|
const diff = parseDiff.default(diffText);
|
||||||
|
|
||||||
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 === file.to) {
|
if (cov.file.replace("./", "") === 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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
25
yarn.lock
25
yarn.lock
|
|
@ -758,16 +758,14 @@
|
||||||
undici-types "~5.26.4"
|
undici-types "~5.26.4"
|
||||||
|
|
||||||
"@types/node@^20.5.0":
|
"@types/node@^20.5.0":
|
||||||
version "20.16.5"
|
version "20.5.6"
|
||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.16.5.tgz#d43c7f973b32ffdf9aa7bd4f80e1072310fd7a53"
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.5.6.tgz#5e9aaa86be03a09decafd61b128d6cec64a5fe40"
|
||||||
integrity sha512-VwYCweNo3ERajwy0IUlqqcyZ8/A7Zwa9ZP3MnENWcB11AejO+tLy3pu850goUW2FC/IJMdZUfKpX/yxL1gymCA==
|
integrity sha512-Gi5wRGPbbyOTX+4Y2iULQ27oUPrefaB0PxGQJnfyWN3kvEDGM3mIB5M/gQLmitZf7A9FmLeaqxD3L1CXpm3VKQ==
|
||||||
dependencies:
|
|
||||||
undici-types "~6.19.2"
|
|
||||||
|
|
||||||
"@types/semver@^7.5.0":
|
"@types/semver@^7.5.0":
|
||||||
version "7.5.8"
|
version "7.5.6"
|
||||||
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.8.tgz#8268a8c57a3e4abd25c165ecd36237db7948a55e"
|
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.6.tgz#c65b2bfce1bec346582c07724e3f8c1017a20339"
|
||||||
integrity sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==
|
integrity sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==
|
||||||
|
|
||||||
"@types/stack-utils@^2.0.0":
|
"@types/stack-utils@^2.0.0":
|
||||||
version "2.0.3"
|
version "2.0.3"
|
||||||
|
|
@ -780,9 +778,9 @@
|
||||||
integrity sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==
|
integrity sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==
|
||||||
|
|
||||||
"@types/yargs@^17.0.8":
|
"@types/yargs@^17.0.8":
|
||||||
version "17.0.33"
|
version "17.0.32"
|
||||||
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.33.tgz#8c32303da83eec050a84b3c7ae7b9f922d13e32d"
|
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.32.tgz#030774723a2f7faafebf645f4e5a48371dca6229"
|
||||||
integrity sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==
|
integrity sha512-xQ67Yc/laOG5uMfX/093MRlGGCIBzZMarVa+gfNKJxWAIgykYpVGkBdbqEzGDDfCrVUj6Hiff4mTZ5BA6TmAog==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@types/yargs-parser" "*"
|
"@types/yargs-parser" "*"
|
||||||
|
|
||||||
|
|
@ -2839,11 +2837,6 @@ undici-types@~5.26.4:
|
||||||
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
|
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
|
||||||
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==
|
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==
|
||||||
|
|
||||||
undici-types@~6.19.2:
|
|
||||||
version "6.19.8"
|
|
||||||
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02"
|
|
||||||
integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==
|
|
||||||
|
|
||||||
update-browserslist-db@^1.0.13:
|
update-browserslist-db@^1.0.13:
|
||||||
version "1.0.13"
|
version "1.0.13"
|
||||||
resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz#3c5e4f5c083661bd38ef64b6328c26ed6c8248c4"
|
resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz#3c5e4f5c083661bd38ef64b6328c26ed6c8248c4"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue