:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(ci): split the renovate digest lookup per manager (#118627)
Raúl Negrón-Oterob41c04a5422c
diff --git a/.github/scripts/renovate-dashboard-digest.mjs b/.github/scripts/renovate-dashboard-digest.mjsindex aeed6db9be18..1e9c95bee173 100644--- a/.github/scripts/renovate-dashboard-digest.mjs+++ b/.github/scripts/renovate-dashboard-digest.mjs@@ -1,4 +1,5 @@-import { readFileSync } from 'node:fs'+import { readFileSync, readdirSync } from 'node:fs'+import { join } from 'node:path'import { pathToFileURL } from 'node:url'import {@@ -16,12 +17,19 @@ const ECOSYSTEMS = { npm: 'npm', pep621: 'python', cargo: 'rust', gomod: 'go', 'const UPDATE_TYPES = ['major', 'minor', 'patch']const COLUMNS = [...UPDATE_TYPES, 'other', 'total']-export function summarize(report) {- const repository = Object.values(report.repositories ?? {})[0]+export function summarize(reportsByManager) {+ const packageFilesByManager = Object.entries(reportsByManager).flatMap(([manager, report]) => {+ const packageFiles = Object.entries(Object.values(report.repositories ?? {})[0]?.packageFiles ?? {})+ // Renovate exits 0 when a lookup aborts, leaving no package files.+ if (packageFiles.length === 0) {+ throw new Error(`The Renovate lookup for ${manager} did not complete`)+ }+ return packageFiles+ })const branches = new Map()const deprecated = new Set()const lookupWarnings = new Set()- for (const [manager, packageFiles] of Object.entries(repository?.packageFiles ?? {})) {+ for (const [manager, packageFiles] of packageFilesByManager) {for (const dep of packageFiles.flatMap((packageFile) => packageFile.deps)) {const depKey = `${manager}:${dep.depName}`if (dep.deprecationMessage) {@@ -44,10 +52,6 @@ export function summarize(report) {pending[manager][type] += 1pending[manager].total += 1}- // Renovate exits 0 when a lookup aborts.- if (branches.size === 0) {- throw new Error('The Renovate report lists no pending updates, so the lookup did not complete')- }return { pending, deprecated: deprecated.size, lookupWarnings: lookupWarnings.size }}@@ -56,7 +60,10 @@ export function buildBlocks({ pending, deprecated, lookupWarnings }, day) {const totals = Object.fromEntries(COLUMNS.map((column) => [column, managers.reduce((sum, manager) => sum + pending[manager][column], 0)]))- const row = (label, counts) => [cell(label), ...COLUMNS.map((column) => cell(counts[column].toLocaleString('en-US')))]+ const row = (label, counts) => [+ cell(label),+ ...COLUMNS.map((column) => cell(counts[column].toLocaleString('en-US'))),+ ]const repoUrl = `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}`const footer = [`${deprecated} deprecated`,@@ -85,7 +92,14 @@ export function buildBlocks({ pending, deprecated, lookupWarnings }, day) {}async function main() {- const summary = summarize(JSON.parse(readFileSync(process.env.RENOVATE_REPORT_PATH, 'utf8')))+ const reportsDir = process.env.RENOVATE_REPORTS_DIR+ const reportsByManager = Object.fromEntries(+ readdirSync(reportsDir).map((artifact) => [+ artifact.replace(/^renovate-report-/, ''),+ JSON.parse(readFileSync(join(reportsDir, artifact, 'renovate-report.json'), 'utf8')),+ ])+ )+ const summary = summarize(reportsByManager)const blocks = buildBlocks(summary, new Date().toISOString().slice(0, 10))if (DRY_RUN) {console.info(JSON.stringify(blocks, null, 2))diff --git a/.github/scripts/renovate-dashboard-digest.test.mjs b/.github/scripts/renovate-dashboard-digest.test.mjsindex 20661a33eec7..c4d45714b51b 100644--- a/.github/scripts/renovate-dashboard-digest.test.mjs+++ b/.github/scripts/renovate-dashboard-digest.test.mjs@@ -4,51 +4,50 @@ import { describe, it } from 'node:test'import { summarize } from './renovate-dashboard-digest.mjs'const update = (branchName, updateType) => ({ branchName, updateType })+const report = (packageFiles) => ({ repositories: { local: { packageFiles } } })-const REPORT = {- repositories: {- local: {- packageFiles: {- npm: [+const REPORTS = {+ npm: report({+ npm: [+ {+ packageFile: 'package.json',+ deps: [+ { depName: 'widget', updates: [update('renovate/widget-5.x', 'major')] },{- packageFile: 'package.json',- deps: [- { depName: 'widget', updates: [update('renovate/widget-5.x', 'major')] },- {- depName: 'gadget',- deprecationMessage: 'use gizmo',- updates: [update('renovate/gadget-2.x', 'minor'), update('renovate/gadget-3.x', 'major')],- },- { depName: 'pinned', updates: [] },- ],- },- {- packageFile: 'apps/web/package.json',- deps: [- { depName: 'react', updates: [update('renovate/react-monorepo', 'patch')] },- { depName: 'react-dom', updates: [update('renovate/react-monorepo', 'minor')] },- { depName: 'widget', updates: [update('renovate/widget-5.x', 'major')] },- { depName: 'gadget', deprecationMessage: 'use gizmo', updates: [] },- ],+ depName: 'gadget',+ deprecationMessage: 'use gizmo',+ updates: [update('renovate/gadget-2.x', 'minor'), update('renovate/gadget-3.x', 'major')],},+ { depName: 'pinned', updates: [] },],- 'github-actions': [- {- packageFile: '.github/workflows/build.yml',- deps: [- { depName: 'acme/setup', warnings: [{ message: 'Could not determine new digest' }] },- { depName: 'acme/deploy', updates: [update('renovate/github-actions', 'digest')] },- ],- },+ },+ {+ packageFile: 'apps/web/package.json',+ deps: [+ { depName: 'react', updates: [update('renovate/react-monorepo', 'patch')] },+ { depName: 'react-dom', updates: [update('renovate/react-monorepo', 'minor')] },+ { depName: 'widget', updates: [update('renovate/widget-5.x', 'major')] },+ { depName: 'gadget', deprecationMessage: 'use gizmo', updates: [] },+ ],+ },+ ],+ }),+ 'github-actions': report({+ 'github-actions': [+ {+ packageFile: '.github/workflows/build.yml',+ deps: [+ { depName: 'acme/setup', warnings: [{ message: 'Could not determine new digest' }] },+ { depName: 'acme/deploy', updates: [update('renovate/github-actions', 'digest')] },],},- },- },+ ],+ }),}describe('renovate dashboard digest', () => {it('counts each branch once, under its riskiest update type', () => {- assert.deepEqual(summarize(REPORT), {+ assert.deepEqual(summarize(REPORTS), {pending: {npm: { major: 2, minor: 2, patch: 0, other: 0, total: 4 },'github-actions': { major: 0, minor: 0, patch: 0, other: 1, total: 1 },@@ -58,7 +57,7 @@ describe('renovate dashboard digest', () => {})})- it('refuses a report with no updates instead of posting an empty table', () => {- assert.throws(() => summarize({ repositories: { local: { packageFiles: {} } } }), /did not complete/)+ it('refuses to post partial numbers when one manager lookup aborted', () => {+ assert.throws(() => summarize({ ...REPORTS, cargo: report({}) }), /lookup for cargo did not complete/)})})diff --git a/.github/workflows/renovate-dashboard-digest.yml b/.github/workflows/renovate-dashboard-digest.ymlindex 8cd1bbe574c8..286687198e59 100644--- a/.github/workflows/renovate-dashboard-digest.yml+++ b/.github/workflows/renovate-dashboard-digest.yml@@ -28,6 +28,12 @@ jobs:if: >-github.repository == 'PostHog/posthog' &&(github.event_name != 'workflow_dispatch' || github.ref == 'refs/heads/master')+ # One Renovate process for every manager keeps its event loop so busy that large+ # npm downloads overrun the 60s request timeout, and that error aborts the whole lookup.+ strategy:+ matrix:+ # Keep in sync with enabledManagers in .github/renovate.json5.+ manager: [npm, github-actions, cargo, pep621, gomod, custom.regex]steps:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2with:@@ -42,14 +48,16 @@ jobs:GITHUB_COM_TOKEN: ${{ secrets.GITHUB_TOKEN }}RENOVATE_REPORT_TYPE: fileRENOVATE_REPORT_PATH: ${{ runner.temp }}/renovate-report.json+ RENOVATE_FORCE: '{"enabledManagers": ["${{ matrix.manager }}"]}'LOG_LEVEL: warnnpm_config_ignore_scripts: 'true'run: npx --yes [email protected] --platform=local --dry-run=lookup- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1with:- name: renovate-report+ name: renovate-report-${{ matrix.manager }}path: ${{ runner.temp }}/renovate-report.json+ if-no-files-found: errorretention-days: 7post:@@ -72,12 +80,12 @@ jobs:- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0with:- name: renovate-report- path: ${{ runner.temp }}+ pattern: renovate-report-*+ path: ${{ runner.temp }}/renovate-reports- name: Post the digestenv:- RENOVATE_REPORT_PATH: ${{ runner.temp }}/renovate-report.json+ RENOVATE_REPORTS_DIR: ${{ runner.temp }}/renovate-reportsSLACK_BOT_TOKEN: ${{ secrets.SLACK_DEVEX_BOT_TOKEN }}SLACK_CHANNEL: ${{ inputs.channel }}DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }}