Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(github): add dependency version consistency check #3699

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,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 @@ -163,6 +164,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
94 changes: 94 additions & 0 deletions tools/custom-checks/check-dependency-version-consistency.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { CDVC } from "check-dependency-version-consistency";
import esMain from "es-main";
import { exit } from "process";

const PACKAGES_TO_BE_IGNORED_FOR_DEP_CONSISTENCY_CHECK: string[] = [
"@hyperledger/cacti-ledger-browser",
"@hyperledger/cacti-plugin-consortium-static",
"@hyperledger-cacti/cacti-plugin-copm-fabric",
"@hyperledger/cacti-plugin-ledger-connector-stellar",
"@hyperledger/cactus-api-client",
"@hyperledger/cactus-cmd-api-server",
"@hyperledger/cactus-common",
"@hyperledger/cactus-core",
"@hyperledger/cactus-core-api",
"@hyperledger/cactus-plugin-bungee-hermes",
"@hyperledger/cactus-plugin-consortium-manual",
"@hyperledger/cactus-plugin-htlc-eth-besu",
"@hyperledger/cactus-plugin-htlc-eth-besu-erc20",
"@hyperledger/cactus-plugin-keychain-aws-sm",
"@hyperledger/cactus-plugin-keychain-azure-kv",
"@hyperledger/cactus-plugin-keychain-google-sm",
"@hyperledger/cactus-plugin-keychain-memory",
"@hyperledger/cactus-plugin-keychain-memory-wasm",
"@hyperledger/cactus-plugin-keychain-vault",
"@hyperledger/cactus-plugin-ledger-connector-aries",
"@hyperledger/cactus-plugin-ledger-connector-besu",
"@hyperledger/cactus-plugin-ledger-connector-cdl",
"@hyperledger/cactus-plugin-ledger-connector-corda",
"@hyperledger/cactus-plugin-ledger-connector-ethereum",
"@hyperledger/cactus-plugin-ledger-connector-fabric",
"@hyperledger/cactus-plugin-ledger-connector-iroha2",
"@hyperledger/cactus-plugin-ledger-connector-polkadot",
"@hyperledger/cactus-plugin-ledger-connector-sawtooth",
"@hyperledger/cactus-plugin-ledger-connector-xdai",
"@hyperledger/cactus-plugin-persistence-ethereum",
"@hyperledger/cactus-plugin-persistence-fabric",
"@hyperledger/cactus-plugin-satp-hermes",
"@hyperledger/cactus-test-api-client",
"@hyperledger/cactus-test-geth-ledger",
"@hyperledger/cactus-test-plugin-consortium-manual",
"@hyperledger/cactus-test-plugin-htlc-eth-besu",
"@hyperledger/cactus-test-plugin-htlc-eth-besu-erc20",
"@hyperledger/cactus-test-plugin-ledger-connector-besu",
"@hyperledger/cactus-test-plugin-ledger-connector-ethereum",
"@hyperledger/cactus-test-tooling",
"@hyperledger/cactus-test-verifier-client",
"@hyperledger/cactus-plugin-htlc-coordinator-besu",
"@hyperledger/cactus-plugin-object-store-ipfs",
"@hyperledger/cactus-common-example-server",
"@hyperledger/cactus-example-carbon-accounting-backend",
"@hyperledger/cactus-example-carbon-accounting-business-logic-plugin",
"@hyperledger/cactus-example-carbon-accounting-frontend",
"@hyperledger/cactus-example-cbdc-bridging-backend",
"@hyperledger/cacti-example-cbdc-bridging-frontend",
"@hyperledger/cactus-example-discounted-asset-trade",
"@hyperledger/cactus-example-discounted-asset-trade-client",
"@hyperledger/cactus-example-electricity-trade",
"@hyperledger/cactus-example-supply-chain-backend",
"@hyperledger/cactus-example-supply-chain-business-logic-plugin",
"@hyperledger/cacti-weaver-protos-js",
"@hyperledger/cacti-weaver-besu-cli",
"@hyperledger/cacti-weaver-driver-fabric",
"@hyperledger/cacti-weaver-fabric-cli",
"@hyperledger/cacti-weaver-iin-agent",
"@hyperledger/cacti-weaver-besu-simpleasset",
"@hyperledger/cacti-weaver-besu-simplestate",
"@hyperledger/cacti-weaver-sdk-besu",
"@hyperledger/cactus-test-plugin-keychain-memory",
"@hyperledger/cactus-plugin-ccmodel-hephaestus",
"@hyperledger/cactus",
];

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

if (esMain(import.meta)) {
const [success, dependencyMismatchSummary] =
await checkDependencyVersionConsistency();
if (!success) {
console.log(`${dependencyMismatchSummary}`);
exit(1);
}
exit(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 @@ -11222,6 +11222,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 @@ -17310,6 +17311,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 @@ -19625,7 +19633,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 @@ -22866,6 +22874,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 @@ -26656,6 +26683,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 @@ -30331,6 +30371,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 @@ -31785,7 +31832,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 @@ -34501,6 +34548,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 @@ -35262,6 +35316,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 @@ -38346,6 +38407,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 @@ -45577,6 +45645,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 @@ -48367,6 +48444,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 @@ -50619,6 +50706,19 @@ __metadata:
languageName: node
linkType: hard

"table@npm:^6.8.1":
version: 6.9.0
resolution: "table@npm:6.9.0"
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/976da6d89841566e39628d1ba107ffab126964c9390a0a877a7c54ebb08820bf388d28fe9f8dcf354b538f19634a572a506c38a3762081640013a149cc862af9
languageName: node
linkType: hard

"tablemark@npm:^3.0.0":
version: 3.0.0
resolution: "tablemark@npm:3.0.0"
Expand Down Expand Up @@ -52116,7 +52216,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 @@ -53390,6 +53490,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
Loading