From 5781c5074ad3f29c70991198b2f0c29aeb22cad6 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 7 Aug 2026 18:54:29 +0200 Subject: [PATCH 1/2] chore: remove `lodash` from the list of deps --- lib/ci/failure_aggregator.js | 34 ++++++++++++++++------------------ package-lock.json | 2 -- package.json | 1 - 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/lib/ci/failure_aggregator.js b/lib/ci/failure_aggregator.js index 5cec214a..3a3b3c2c 100644 --- a/lib/ci/failure_aggregator.js +++ b/lib/ci/failure_aggregator.js @@ -1,4 +1,3 @@ -import _ from 'lodash'; import chalk from 'chalk'; import { getMachineUrl, parsePRFromURL } from '../links.js'; @@ -15,6 +14,11 @@ import { const { FAILURE_TYPES_NAME } = CIFailureParser; +function uniqBy(array, key) { + const seen = new Set(); + return array.filter((item) => !seen.has(item[key]) && seen.add(item[key])); +} + export class FailureAggregator { constructor(cli, data) { this.cli = cli; @@ -24,26 +28,21 @@ export class FailureAggregator { } aggregate() { - const failures = this.failures; - const groupedByReason = _.chain(failures) - .groupBy(getHighlight) - .toPairs() - .sortBy(0) - .value(); + const groupedByReason = Object.groupBy(this.failures, getHighlight); const data = []; - for (const item of groupedByReason) { - const [reason, failures] = item; + for (const reason of Object.keys(groupedByReason).sort()) { + const failures = groupedByReason[reason]; // Uncomment this and redirect stderr away to see matched highlights // console.log('HIGHLIGHT', reason); // If multiple sub builds of one PR are failed by the same reason, // we'll only take one of those builds, as that might be a genuine failure - const prs = _.chain(failures) - .uniqBy('source') - .sortBy((f) => parseJobFromURL(f.upstream).jobid) - .map((item) => ({ source: item.source, upstream: item.upstream })) - .value(); - const machines = _.uniqBy( + const prs = uniqBy(failures, 'source') + .sort((a, b) => + parseJobFromURL(a.upstream).jobid - parseJobFromURL(b.upstream).jobid + ) + .map((item) => ({ source: item.source, upstream: item.upstream })); + const machines = uniqBy( failures.map(f => ({ hostname: f.builtOn, url: f.url })), 'hostname'); data.push({ @@ -51,10 +50,9 @@ export class FailureAggregator { }); } - const groupedByType = _.groupBy(data, 'type'); + const groupedByType = Object.groupBy(data, ({ type }) => type); for (const type of Object.keys(groupedByType)) { - groupedByType[type] = - _.sortBy(groupedByType[type], r => 0 - (r.prs.length)); + groupedByType[type].sort((a, b) => b.prs.length - a.prs.length); } this.aggregates = groupedByType; return groupedByType; diff --git a/package-lock.json b/package-lock.json index c6e75218..49b18152 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,6 @@ "git-secure-tag", "js-yaml", "listr2", - "lodash", "ora", "replace-in-file", "semver", @@ -47,7 +46,6 @@ "git-secure-tag": "^2.3.1", "js-yaml": "^5.2.1", "listr2": "^9.0.5", - "lodash": "^4.17.21", "ora": "^9.0.0", "replace-in-file": "^8.3.0", "semver": "^7.7.1", diff --git a/package.json b/package.json index fe6c1185..740c36cb 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,6 @@ "git-secure-tag": "^2.3.1", "js-yaml": "^5.2.1", "listr2": "^9.0.5", - "lodash": "^4.17.21", "ora": "^9.0.0", "replace-in-file": "^8.3.0", "semver": "^7.7.1", From c62c608f301909086e2c63519b26668b75e685fb Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 7 Aug 2026 20:01:23 +0200 Subject: [PATCH 2/2] fixup! chore: remove `lodash` from the list of deps --- lib/ci/failure_aggregator.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/ci/failure_aggregator.js b/lib/ci/failure_aggregator.js index 3a3b3c2c..eaa429f2 100644 --- a/lib/ci/failure_aggregator.js +++ b/lib/ci/failure_aggregator.js @@ -38,10 +38,8 @@ export class FailureAggregator { // If multiple sub builds of one PR are failed by the same reason, // we'll only take one of those builds, as that might be a genuine failure const prs = uniqBy(failures, 'source') - .sort((a, b) => - parseJobFromURL(a.upstream).jobid - parseJobFromURL(b.upstream).jobid - ) - .map((item) => ({ source: item.source, upstream: item.upstream })); + .map(({ source, upstream }) => ({ source, upstream, _id: parseJobFromURL(upstream).jobid })) + .sort((a, b) => a._id - b._id); const machines = uniqBy( failures.map(f => ({ hostname: f.builtOn, url: f.url })), 'hostname'); @@ -51,8 +49,8 @@ export class FailureAggregator { } const groupedByType = Object.groupBy(data, ({ type }) => type); - for (const type of Object.keys(groupedByType)) { - groupedByType[type].sort((a, b) => b.prs.length - a.prs.length); + for (const group of Object.value(groupedByType)) { + group.sort((a, b) => b.prs.length - a.prs.length); } this.aggregates = groupedByType; return groupedByType;