Skip to content

Commit

Permalink
ci(github): add dependency version consistency check
Browse files Browse the repository at this point in the history
    Primary Changes
    ---------------
    1. Added a new custom check which checks if there
       are any inconsistency with the dependency version,
       which is already being used with an exsisting package.

    Changes needed to incorporate 1)
    -------------------------------
    2. Added a new dependency in the root package.json
    3. Added a new npm script in the root package.json
    4. Updated the lock file for the dependency inclusion

Fixes #3612

Signed-off-by: jagpreetsinghsasan <[email protected]>
  • Loading branch information
jagpreetsinghsasan committed Nov 19, 2024
1 parent 394323e commit 976495b
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 3 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"tools:validate-bundle-names": "TS_NODE_PROJECT=./tools/tsconfig.json node --trace-deprecation --experimental-modules --abort-on-uncaught-exception --loader ts-node/esm --experimental-specifier-resolution=node ./tools/validate-bundle-names.js",
"tools:bump-openapi-spec-dep-versions": "TS_NODE_PROJECT=./tools/tsconfig.json node --trace-deprecation --experimental-modules --abort-on-uncaught-exception --loader ts-node/esm --experimental-specifier-resolution=node ./tools/bump-openapi-spec-dep-versions.ts",
"tools:bundle-open-api-tpl-files": "TS_NODE_PROJECT=./tools/tsconfig.json node --trace-deprecation --experimental-modules --abort-on-uncaught-exception --loader ts-node/esm --experimental-specifier-resolution=node ./tools/bundle-open-api-tpl-files.ts",
"tools:check-dependency-version-consistency": "TS_NODE_PROJECT=./tools/tsconfig.json node --trace-deprecation --experimental-modules --abort-on-uncaught-exception --loader ts-node/esm --experimental-specifier-resolution=node ./tools/custom-checks/check-dependency-version-consistency.ts",
"tools:create-production-only-archive": "TS_NODE_PROJECT=./tools/tsconfig.json node --trace-deprecation --experimental-modules --abort-on-uncaught-exception --loader ts-node/esm --experimental-specifier-resolution=node ./tools/create-production-only-archive.ts",
"tools:download-file-to-disk": "TS_NODE_PROJECT=./tools/tsconfig.json node --trace-deprecation --experimental-modules --abort-on-uncaught-exception --loader ts-node/esm --experimental-specifier-resolution=node ./tools/download-file-to-disk.ts",
"tools:get-latest-sem-ver-git-tag": "TS_NODE_PROJECT=./tools/tsconfig.json node --abort-on-uncaught-exception --loader ts-node/esm --experimental-specifier-resolution=node --no-warnings ./tools/get-latest-sem-ver-git-tag.ts",
Expand Down Expand Up @@ -158,6 +159,7 @@
"adm-zip": "0.5.10",
"benchmark": "2.1.4",
"buffer": "6.0.3",
"check-dependency-version-consistency": "4.1.0",
"cpy-cli": "4.2.0",
"cross-env": "7.0.3",
"crypto-browserify": "3.12.0",
Expand Down
17 changes: 17 additions & 0 deletions tools/custom-checks/check-dependency-version-consistency.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { CDVC } from "check-dependency-version-consistency";

export async function checkDependencyVersionConsistency(): Promise<
[boolean, string[]]
> {
const errors: string[] = [];
const cdvc = new CDVC(process.cwd(), {
fix: false,
});
errors.push(
cdvc.toMismatchSummary(),
);
return [errors.length === 0, errors];
}

const dependencyMismatchSummary = await checkDependencyVersionConsistency();
console.log(dependencyMismatchSummary[1][0])
7 changes: 7 additions & 0 deletions tools/custom-checks/run-custom-checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from "./check-missing-node-deps";
import { getAllPkgDirs } from "./get-all-pkg-dirs";
import { runAttwOnTgz } from "./run-attw-on-tgz";
import { checkDependencyVersionConsistency } from "./check-dependency-version-consistency";

export async function runCustomChecks(
argv: string[],
Expand Down Expand Up @@ -74,6 +75,12 @@ export async function runCustomChecks(
overallSuccess = overallSuccess && success;
}

{
const [success, errors] = await checkDependencyVersionConsistency();
overallErrors = overallErrors.concat(errors);
overallSuccess = overallSuccess && success;
}

{
const [success, errors] = await runAttwOnTgz();
overallErrors = overallErrors.concat(errors);
Expand Down
113 changes: 110 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11147,6 +11147,7 @@ __metadata:
adm-zip: "npm:0.5.10"
benchmark: "npm:2.1.4"
buffer: "npm:6.0.3"
check-dependency-version-consistency: "npm:4.1.0"
cpy-cli: "npm:4.2.0"
cross-env: "npm:7.0.3"
crypto-browserify: "npm:3.12.0"
Expand Down Expand Up @@ -17235,6 +17236,13 @@ __metadata:
languageName: node
linkType: hard

"@types/js-yaml@npm:^4.0.5":
version: 4.0.9
resolution: "@types/js-yaml@npm:4.0.9"
checksum: 10/a0ce595db8a987904badd21fc50f9f444cb73069f4b95a76cc222e0a17b3ff180669059c763ec314bc4c3ce284379177a9da80e83c5f650c6c1310cafbfaa8e6
languageName: node
linkType: hard

"@types/json-schema@npm:*, @types/json-schema@npm:^7.0.8":
version: 7.0.9
resolution: "@types/json-schema@npm:7.0.9"
Expand Down Expand Up @@ -19550,7 +19558,7 @@ __metadata:
languageName: node
linkType: hard

"ajv@npm:8.17.1, ajv@npm:^8.10.0, ajv@npm:^8.14.0":
"ajv@npm:8.17.1, ajv@npm:^8.0.1, ajv@npm:^8.10.0, ajv@npm:^8.14.0":
version: 8.17.1
resolution: "ajv@npm:8.17.1"
dependencies:
Expand Down Expand Up @@ -22853,6 +22861,25 @@ __metadata:
languageName: node
linkType: hard

"check-dependency-version-consistency@npm:4.1.0":
version: 4.1.0
resolution: "check-dependency-version-consistency@npm:4.1.0"
dependencies:
"@types/js-yaml": "npm:^4.0.5"
chalk: "npm:^5.2.0"
commander: "npm:^10.0.1"
edit-json-file: "npm:^1.7.0"
globby: "npm:^13.1.4"
js-yaml: "npm:^4.1.0"
semver: "npm:^7.5.1"
table: "npm:^6.8.1"
type-fest: "npm:^3.11.0"
bin:
check-dependency-version-consistency: dist/bin/check-dependency-version-consistency.js
checksum: 10/8ee74466e317f0c8e3ddff366882818122057c311ffbf4377ec5f09e0cbf9fdbdb79abafcf017ebcc498a3dd2b268a41015c1a80a0f8b3f2c36b1000113b1eff
languageName: node
linkType: hard

"check-error@npm:^1.0.2":
version: 1.0.2
resolution: "check-error@npm:1.0.2"
Expand Down Expand Up @@ -26636,6 +26663,19 @@ __metadata:
languageName: node
linkType: hard

"edit-json-file@npm:^1.7.0":
version: 1.8.0
resolution: "edit-json-file@npm:1.8.0"
dependencies:
find-value: "npm:^1.0.12"
iterate-object: "npm:^1.3.4"
r-json: "npm:^1.2.10"
set-value: "npm:^4.1.0"
w-json: "npm:^1.3.10"
checksum: 10/611e62414a15b1d6e44261d1fd370fa6f080f4a93ff6ee4ec0b103a545984dbb0aa8a68f2c7856cbb63948c2c2df6b2b12d98140d3e040f3ce12cffdc51de7a3
languageName: node
linkType: hard

"ee-first@npm:1.1.1":
version: 1.1.1
resolution: "ee-first@npm:1.1.1"
Expand Down Expand Up @@ -30272,6 +30312,13 @@ __metadata:
languageName: node
linkType: hard

"find-value@npm:^1.0.12":
version: 1.0.12
resolution: "find-value@npm:1.0.12"
checksum: 10/5cab63c88e5090744de582c8c331c05b134f3501935da270f24c95b395c4fea3e7d0df5e9cfdd6c2a25b80ac7cde3bc06d6dd388e4fdc6cd52f6580ed95e14e1
languageName: node
linkType: hard

"findit@npm:^2.0.0":
version: 2.0.0
resolution: "findit@npm:2.0.0"
Expand Down Expand Up @@ -31726,7 +31773,7 @@ __metadata:
languageName: node
linkType: hard

"globby@npm:^13.1.2":
"globby@npm:^13.1.2, globby@npm:^13.1.4":
version: 13.2.2
resolution: "globby@npm:13.2.2"
dependencies:
Expand Down Expand Up @@ -34426,6 +34473,13 @@ __metadata:
languageName: node
linkType: hard

"is-primitive@npm:^3.0.1":
version: 3.0.1
resolution: "is-primitive@npm:3.0.1"
checksum: 10/c4da6a6e6d487f31d85b9259b67695fffcc75dca6c9612b0a002e3050c734227b9911be09b877539ec6309710229c19f4edd0f9e26ed2a67924ee0916baf0bed
languageName: node
linkType: hard

"is-promise@npm:^2.1.0":
version: 2.2.2
resolution: "is-promise@npm:2.2.2"
Expand Down Expand Up @@ -35187,6 +35241,13 @@ __metadata:
languageName: node
linkType: hard

"iterate-object@npm:^1.3.4":
version: 1.3.4
resolution: "iterate-object@npm:1.3.4"
checksum: 10/4378555000600ec749f82c85323232a12d533491ea1168de6249f2105cefd0c6a30df9fc2c5bfdc47f6386d0c920e99b2c49a58e2e0ec8f19342bee69ba05905
languageName: node
linkType: hard

"iterator.prototype@npm:^1.1.2":
version: 1.1.2
resolution: "iterator.prototype@npm:1.1.2"
Expand Down Expand Up @@ -38271,6 +38332,13 @@ __metadata:
languageName: node
linkType: hard

"lodash.truncate@npm:^4.4.2":
version: 4.4.2
resolution: "lodash.truncate@npm:4.4.2"
checksum: 10/7a495616121449e5d2288c606b1025d42ab9979e8c93ba885e5c5802ffd4f1ebad4428c793ccc12f73e73237e85a9f5b67dd6415757546fbd5a4653ba83e25ac
languageName: node
linkType: hard

"lodash.uniq@npm:^4.5.0":
version: 4.5.0
resolution: "lodash.uniq@npm:4.5.0"
Expand Down Expand Up @@ -45494,6 +45562,15 @@ __metadata:
languageName: node
linkType: hard

"r-json@npm:^1.2.10":
version: 1.3.0
resolution: "r-json@npm:1.3.0"
dependencies:
w-json: "npm:1.3.10"
checksum: 10/ebe24b41e9f855af9f61747d7f3a511a78bc11c1841eaf3cbf98b385e91a0a982a3f724e2bf24d737642efc9b510585b5c54d25c098cc6850bdad15a22b36636
languageName: node
linkType: hard

"race-signal@npm:^1.0.0":
version: 1.0.1
resolution: "race-signal@npm:1.0.1"
Expand Down Expand Up @@ -48289,6 +48366,16 @@ __metadata:
languageName: node
linkType: hard

"set-value@npm:^4.1.0":
version: 4.1.0
resolution: "set-value@npm:4.1.0"
dependencies:
is-plain-object: "npm:^2.0.4"
is-primitive: "npm:^3.0.1"
checksum: 10/67eebb0d78be89242478daf8ab5357c59a35add1d7bdccdb56236e6004128a79bdf298c952e286b60b63ed17b24dcdb399734fbdacc9b76e7fd2e3e01546a42e
languageName: node
linkType: hard

"setimmediate@npm:1.0.4":
version: 1.0.4
resolution: "setimmediate@npm:1.0.4"
Expand Down Expand Up @@ -50541,6 +50628,19 @@ __metadata:
languageName: node
linkType: hard

"table@npm:^6.8.1":
version: 6.8.2
resolution: "table@npm:6.8.2"
dependencies:
ajv: "npm:^8.0.1"
lodash.truncate: "npm:^4.4.2"
slice-ansi: "npm:^4.0.0"
string-width: "npm:^4.2.3"
strip-ansi: "npm:^6.0.1"
checksum: 10/2946162eb87a91b9bf4283214d26830db96f09cf517eff18e7501d47a4770c529b432bb54c9394337c3dfd6c8dbf66581f76edb37e9838beb6ec394080af4ac2
languageName: node
linkType: hard

"tablemark@npm:^3.0.0":
version: 3.0.0
resolution: "tablemark@npm:3.0.0"
Expand Down Expand Up @@ -52038,7 +52138,7 @@ __metadata:
languageName: node
linkType: hard

"type-fest@npm:^3.8.0":
"type-fest@npm:^3.11.0, type-fest@npm:^3.8.0":
version: 3.13.1
resolution: "type-fest@npm:3.13.1"
checksum: 10/9a8a2359ada34c9b3affcaf3a8f73ee14c52779e89950db337ce66fb74c3399776c697c99f2532e9b16e10e61cfdba3b1c19daffb93b338b742f0acd0117ce12
Expand Down Expand Up @@ -53312,6 +53412,13 @@ __metadata:
languageName: node
linkType: hard

"w-json@npm:1.3.10, w-json@npm:^1.3.10":
version: 1.3.10
resolution: "w-json@npm:1.3.10"
checksum: 10/bf3dfa4e8e2429fcf2b0456ba396245a0be719ff4fb04eec971536c3586cae7489c5ca5801848ecfbc2a454f37829a132f428acf9d457cebe43d5c70348e7a7b
languageName: node
linkType: hard

"w3c-hr-time@npm:^1.0.2":
version: 1.0.2
resolution: "w3c-hr-time@npm:1.0.2"
Expand Down

0 comments on commit 976495b

Please sign in to comment.