Skip to content

: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.

fix(ci): name the specific target in the Trunk lane PR comment (#94198)

Paul D'Ambra5971a7876fa1
diff --git a/.github/scripts/post-ci-sections.test.mjs b/.github/scripts/post-ci-sections.test.mjs
index ba1515b51727..00415ac7554f 100644
--- a/.github/scripts/post-ci-sections.test.mjs
+++ b/.github/scripts/post-ci-sections.test.mjs
@@ -61,13 +61,40 @@ describe('CI report section builders', () => {
},
{
name: 'describes a non-backend lane',
- input: { impactedTargets: ['fe:core'], isUniversal: false },
+ input: { impactedTargets: ['fe:core', 'node:ingestion'], isUniversal: false },
expected: {
status: 'ok',
summary: 'non-backend lane',
body: 'This PR is assigned to the non-backend lane. It does not run backend Python tests and may merge in parallel with PRs in other lanes.',
},
},
+ {
+ name: 'names the single non-backend target',
+ input: { impactedTargets: ['fe:product:desktop'], isUniversal: false },
+ expected: {
+ status: 'ok',
+ summary: 'non-backend lane (<code>fe:product:desktop</code>)',
+ body: 'This PR is assigned to the non-backend lane (<code>fe:product:desktop</code>). It does not run backend Python tests and may merge in parallel with PRs in other lanes.',
+ },
+ },
+ {
+ name: 'names the single backend Python target',
+ input: { impactedTargets: ['py:product:surveys'], isUniversal: false },
+ expected: {
+ status: 'warn',
+ summary: 'backend Python lane (<code>py:product:surveys</code>)',
+ body: 'This PR is assigned to the backend Python lane (<code>py:product:surveys</code>). It runs backend Python tests and may merge in parallel with PRs in other lanes.',
+ },
+ },
+ {
+ name: 'escapes a target before rendering it',
+ input: { impactedTargets: ['</summary><img src="x">'], isUniversal: false },
+ expected: {
+ status: 'ok',
+ summary: 'non-backend lane (<code>&lt;/summary&gt;&lt;img src=&quot;x&quot;&gt;</code>)',
+ body: 'This PR is assigned to the non-backend lane (<code>&lt;/summary&gt;&lt;img src=&quot;x&quot;&gt;</code>). It does not run backend Python tests and may merge in parallel with PRs in other lanes.',
+ },
+ },
]) {
it(testCase.name, () => {
assert.deepEqual(buildTrunkLaneSection(testCase.input), testCase.expected)
diff --git a/.github/scripts/post-trunk-lane-section.mjs b/.github/scripts/post-trunk-lane-section.mjs
index 30883c1eeaab..6f5351a848d3 100644
--- a/.github/scripts/post-trunk-lane-section.mjs
+++ b/.github/scripts/post-trunk-lane-section.mjs
@@ -3,6 +3,21 @@ import { pathToFileURL } from 'node:url'
import { gh, postSection, resolvePrContext } from '../../frontend/bin/ci-report/update-ci-report.mjs'
+function formatTarget(target) {
+ const escapedTarget = target.replace(
+ /[&<>"']/g,
+ (character) =>
+ ({
+ '&': '&amp;',
+ '<': '&lt;',
+ '>': '&gt;',
+ '"': '&quot;',
+ "'": '&#39;',
+ })[character]
+ )
+ return `<code>${escapedTarget}</code>`
+}
+
export function buildTrunkLaneSection({ impactedTargets, isUniversal }) {
if (
isUniversal ||
@@ -17,7 +32,10 @@ export function buildTrunkLaneSection({ impactedTargets, isUniversal }) {
}
const runsBackendPythonTests = impactedTargets.some((target) => target.startsWith('py:'))
- const summary = runsBackendPythonTests ? 'backend Python lane' : 'non-backend lane'
+ const laneName = runsBackendPythonTests ? 'backend Python lane' : 'non-backend lane'
+ // A single target names the exact lane; more than one collapses to the
+ // shared family name rather than listing them all.
+ const summary = impactedTargets.length === 1 ? `${laneName} (${formatTarget(impactedTargets[0])})` : laneName
return {
status: runsBackendPythonTests ? 'warn' : 'ok',