Skip to content

Commit f39bba5

Browse files
committed
Merge branch 'main' into remove-onyx-connect-in-EmojiUtils-CardMessageUtils
2 parents 3d3b42d + 2c1e107 commit f39bba5

400 files changed

Lines changed: 8033 additions & 6002 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/javascript/postTestCoverageComment/index.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11633,18 +11633,32 @@ function generateCoverageData(coverage, changedFiles, baseCoverage) {
1163311633
// If not found, try to find by matching the end of the path
1163411634
if (!fileCoverage) {
1163511635
const coverageKeys = Object.keys(coverage).filter((key) => key !== 'total');
11636-
const matchingKey = coverageKeys.find((key) => key.endsWith(file) || key.endsWith(file.replace(/^src\//, '')));
11636+
// Try multiple matching strategies
11637+
const normalizedFile = file.startsWith('src/') ? file : `src/${file}`;
11638+
const matchingKey = coverageKeys.find((key) => {
11639+
const normalizedKey = key.replace(/\\/g, '/'); // Handle Windows paths
11640+
return normalizedKey === normalizedFile || normalizedKey === file || (normalizedKey.includes(file) && normalizedKey.split('/').pop() === file.split('/').pop());
11641+
});
1163711642
if (matchingKey) {
1163811643
fileCoverage = coverage[matchingKey];
1163911644
}
1164011645
}
11646+
// For files without coverage data, still include them with 0% coverage if they should have coverage
11647+
const shouldHaveCoverage = !file.endsWith('.d.ts') && !file.includes('/types.ts') && !file.match(/\.(stories|spec|test)\.(ts|tsx|js|jsx)$/);
11648+
const noCoverageFiles = shouldHaveCoverage
11649+
? {
11650+
file,
11651+
coverage: 0,
11652+
lines: '0/0',
11653+
}
11654+
: null;
1164111655
return fileCoverage
1164211656
? {
1164311657
file,
1164411658
coverage: fileCoverage.lines.pct,
1164511659
lines: `${fileCoverage.lines.covered}/${fileCoverage.lines.total}`,
1164611660
}
11647-
: null;
11661+
: noCoverageFiles;
1164811662
})
1164911663
.filter((item) => item !== null)
1165011664
.sort((a, b) => b.coverage - a.coverage);
@@ -11702,7 +11716,7 @@ function getNestedValue(obj, nestPath) {
1170211716
*/
1170311717
function getCoverageStatus(current, baseline) {
1170411718
const diff = current - (baseline ?? 0);
11705-
if (!baseline || Math.abs(diff) < 0.01) {
11719+
if (baseline === undefined || baseline === null || Math.abs(diff) < 0.01) {
1170611720
return { emoji: '', status: '', diff: 0 };
1170711721
}
1170811722
if (diff > 0) {
@@ -11715,7 +11729,7 @@ function getCoverageStatus(current, baseline) {
1171511729
*/
1171611730
function calculateChange(current, baseline) {
1171711731
const diff = current - baseline;
11718-
if (!baseline || Math.abs(diff) < 0.01) {
11732+
if (baseline === undefined || baseline === null || Math.abs(diff) < 0.01) {
1171911733
return '0.0%';
1172011734
}
1172111735
// Negative sign is already handled by the diff calculation
@@ -11752,7 +11766,8 @@ function generateCoverageSection(coverageData, artifactUrl, workflowRunId) {
1175211766
{{#hasChangedFiles}}
1175311767
| File | Coverage | Lines |
1175411768
|------|----------|-------|
11755-
{{#changedFiles}}| \`{{displayFile}}\` | {{coverage}}% | {{lines}} |{{/changedFiles}}
11769+
{{#changedFiles}}| \`{{displayFile}}\` | {{coverage}}% | {{lines}} |
11770+
{{/changedFiles}}
1175611771
{{/hasChangedFiles}}
1175711772
{{^hasChangedFiles}}*No coverage changed files found.*{{/hasChangedFiles}}
1175811773
**🔄 Overall Coverage Summary**

.github/actions/javascript/postTestCoverageComment/postTestCoverageComment.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,37 @@ function generateCoverageData(coverage: CoverageSummary, changedFiles: string[],
142142
// If not found, try to find by matching the end of the path
143143
if (!fileCoverage) {
144144
const coverageKeys = Object.keys(coverage).filter((key) => key !== 'total');
145-
const matchingKey = coverageKeys.find((key) => key.endsWith(file) || key.endsWith(file.replace(/^src\//, '')));
145+
146+
// Try multiple matching strategies
147+
const normalizedFile = file.startsWith('src/') ? file : `src/${file}`;
148+
const matchingKey = coverageKeys.find((key) => {
149+
const normalizedKey = key.replace(/\\/g, '/'); // Handle Windows paths
150+
return normalizedKey === normalizedFile || normalizedKey === file || (normalizedKey.includes(file) && normalizedKey.split('/').pop() === file.split('/').pop());
151+
});
152+
146153
if (matchingKey) {
147154
fileCoverage = coverage[matchingKey];
148155
}
149156
}
157+
158+
// For files without coverage data, still include them with 0% coverage if they should have coverage
159+
const shouldHaveCoverage = !file.endsWith('.d.ts') && !file.includes('/types.ts') && !file.match(/\.(stories|spec|test)\.(ts|tsx|js|jsx)$/);
160+
161+
const noCoverageFiles = shouldHaveCoverage
162+
? {
163+
file,
164+
coverage: 0,
165+
lines: '0/0',
166+
}
167+
: null;
168+
150169
return fileCoverage
151170
? {
152171
file,
153172
coverage: fileCoverage.lines.pct,
154173
lines: `${fileCoverage.lines.covered}/${fileCoverage.lines.total}`,
155174
}
156-
: null;
175+
: noCoverageFiles;
157176
})
158177
.filter((item): item is NonNullable<typeof item> => item !== null)
159178
.sort((a, b) => b.coverage - a.coverage);
@@ -221,7 +240,7 @@ function getNestedValue(obj: TemplateData, nestPath: string) {
221240
*/
222241
function getCoverageStatus(current: number, baseline?: number): {emoji: string; status: string; diff: number} {
223242
const diff = current - (baseline ?? 0);
224-
if (!baseline || Math.abs(diff) < 0.01) {
243+
if (baseline === undefined || baseline === null || Math.abs(diff) < 0.01) {
225244
return {emoji: '', status: '', diff: 0};
226245
}
227246
if (diff > 0) {
@@ -235,7 +254,7 @@ function getCoverageStatus(current: number, baseline?: number): {emoji: string;
235254
*/
236255
function calculateChange(current: number, baseline: number): string {
237256
const diff = current - baseline;
238-
if (!baseline || Math.abs(diff) < 0.01) {
257+
if (baseline === undefined || baseline === null || Math.abs(diff) < 0.01) {
239258
return '0.0%';
240259
}
241260
// Negative sign is already handled by the diff calculation
@@ -274,7 +293,8 @@ function generateCoverageSection(coverageData: CoverageData, artifactUrl: string
274293
{{#hasChangedFiles}}
275294
| File | Coverage | Lines |
276295
|------|----------|-------|
277-
{{#changedFiles}}| \`{{displayFile}}\` | {{coverage}}% | {{lines}} |{{/changedFiles}}
296+
{{#changedFiles}}| \`{{displayFile}}\` | {{coverage}}% | {{lines}} |
297+
{{/changedFiles}}
278298
{{/hasChangedFiles}}
279299
{{^hasChangedFiles}}*No coverage changed files found.*{{/hasChangedFiles}}
280300
**🔄 Overall Coverage Summary**

.github/actions/javascript/proposalPoliceComment/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11639,6 +11639,7 @@ async function run() {
1163911639
console.log('commentsResponse', commentsResponse);
1164011640
core.endGroup();
1164111641
let didFindDuplicate = false;
11642+
let originalProposal;
1164211643
for (const previousProposal of commentsResponse) {
1164311644
const isProposal = !!previousProposal.body?.includes(CONST_1.default.PROPOSAL_KEYWORD);
1164411645
const previousProposalCreatedAt = new Date(previousProposal.created_at).getTime();
@@ -11664,13 +11665,14 @@ async function run() {
1166411665
if (similarityPercentage >= 90) {
1166511666
console.log(`Found duplicate with ${similarityPercentage}% similarity.`);
1166611667
didFindDuplicate = true;
11668+
originalProposal = previousProposal;
1166711669
break;
1166811670
}
1166911671
}
1167011672
}
1167111673
if (didFindDuplicate) {
1167211674
const duplicateCheckWithdrawMessage = proposalPolice_1.default.getDuplicateCheckWithdrawMessage();
11673-
const duplicateCheckNoticeMessage = proposalPolice_1.default.getDuplicateCheckNoticeMessage(newProposalAuthor);
11675+
const duplicateCheckNoticeMessage = proposalPolice_1.default.getDuplicateCheckNoticeMessage(newProposalAuthor, originalProposal?.html_url);
1167411676
// If a duplicate proposal is detected, update the comment to withdraw it
1167511677
console.log('ProposalPolice™ withdrawing duplicated proposal...');
1167611678
await GithubUtils_1.default.octokit.issues.updateComment({
@@ -12557,8 +12559,9 @@ const PROPOSAL_POLICE_TEMPLATES = {
1255712559
getDuplicateCheckWithdrawMessage: () => {
1255812560
return '#### 🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.';
1255912561
},
12560-
getDuplicateCheckNoticeMessage: (proposalAuthor) => {
12561-
return `⚠️ @${proposalAuthor} Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.`;
12562+
getDuplicateCheckNoticeMessage: (proposalAuthor, originalProposalURL) => {
12563+
const existingProposalWithURL = originalProposalURL ? `[existing proposal](${originalProposalURL})` : 'existing proposal';
12564+
return `⚠️ @${proposalAuthor} Your proposal is a duplicate of an already ${existingProposalWithURL} and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.`;
1256212565
},
1256312566
};
1256412567
exports["default"] = PROPOSAL_POLICE_TEMPLATES;

.github/actions/javascript/proposalPoliceComment/proposalPoliceComment.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {context} from '@actions/github';
44
import type {IssueCommentCreatedEvent, IssueCommentEditedEvent, IssueCommentEvent} from '@octokit/webhooks-types';
55
import {format} from 'date-fns';
66
import {toZonedTime} from 'date-fns-tz';
7+
import type {TupleToUnion} from 'type-fest';
78
import {convertToNumber} from '@github/libs/ActionUtils';
89
import CONST from '@github/libs/CONST';
910
import GithubUtils from '@github/libs/GithubUtils';
@@ -91,6 +92,7 @@ async function run() {
9192
core.endGroup();
9293

9394
let didFindDuplicate = false;
95+
let originalProposal: TupleToUnion<typeof commentsResponse> | undefined;
9496
for (const previousProposal of commentsResponse) {
9597
const isProposal = !!previousProposal.body?.includes(CONST.PROPOSAL_KEYWORD);
9698
const previousProposalCreatedAt = new Date(previousProposal.created_at).getTime();
@@ -117,14 +119,15 @@ async function run() {
117119
if (similarityPercentage >= 90) {
118120
console.log(`Found duplicate with ${similarityPercentage}% similarity.`);
119121
didFindDuplicate = true;
122+
originalProposal = previousProposal;
120123
break;
121124
}
122125
}
123126
}
124127

125128
if (didFindDuplicate) {
126129
const duplicateCheckWithdrawMessage = PROPOSAL_POLICE_TEMPLATES.getDuplicateCheckWithdrawMessage();
127-
const duplicateCheckNoticeMessage = PROPOSAL_POLICE_TEMPLATES.getDuplicateCheckNoticeMessage(newProposalAuthor);
130+
const duplicateCheckNoticeMessage = PROPOSAL_POLICE_TEMPLATES.getDuplicateCheckNoticeMessage(newProposalAuthor, originalProposal?.html_url);
128131
// If a duplicate proposal is detected, update the comment to withdraw it
129132
console.log('ProposalPolice™ withdrawing duplicated proposal...');
130133
await GithubUtils.octokit.issues.updateComment({

.github/actions/javascript/waitforJestTests/index.js

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11579,32 +11579,38 @@ async function waitForJestTests() {
1157911579
const maxWaitTime = 30 * 60 * 1000; // 30 minutes
1158011580
const pollInterval = 10 * 1000; // 10 seconds
1158111581
const startTime = Date.now();
11582-
// Get PR number and SHA (backwards compatible with manual dispatch)
11582+
// Get PR number from either context or manual input
1158311583
let prNumber;
11584-
let headSha;
11584+
const inputsPRNumber = github_1.context.payload.inputs?.pr_number;
1158511585
if (github_1.context.payload.pull_request?.number) {
11586+
// Regular PR context
1158611587
prNumber = github_1.context.payload.pull_request.number;
11587-
headSha = github_1.context.sha;
11588-
console.log(`Using PR context - PR #${prNumber}, SHA: ${headSha}`);
11588+
console.log(`Using PR context - PR #${prNumber}`);
11589+
}
11590+
else if (inputsPRNumber) {
11591+
// Manual workflow dispatch
11592+
prNumber = Number(inputsPRNumber);
11593+
console.log(`Using manual dispatch - PR #${prNumber}`);
1158911594
}
1159011595
else {
11591-
prNumber = Number(github_1.context.payload.inputs?.pr_number ?? '0');
11592-
if (!prNumber) {
11593-
core.setFailed('PR number is required when pull_request context is not available.');
11594-
return;
11595-
}
11596-
// Get PR details to find the head SHA
11597-
console.log(`Using workflow inputs - Getting details for PR #${prNumber}`);
11598-
const prResponse = await GithubUtils_1.default.octokit.pulls.get({
11599-
owner: github_1.context.repo.owner,
11600-
repo: github_1.context.repo.repo,
11601-
pull_number: prNumber,
11602-
});
11603-
headSha = prResponse.data.head.sha;
11604-
console.log(`PR #${prNumber} head SHA: ${headSha}`);
11596+
core.setFailed('PR number is required but not available in context or inputs.');
11597+
return;
1160511598
}
11606-
console.log(`Looking for test workflow runs for PR #${github_1.context.payload.pull_request?.number}`);
11607-
console.log(`Head SHA: ${github_1.context.sha}`);
11599+
if (!prNumber) {
11600+
core.setFailed('Invalid PR number.');
11601+
return;
11602+
}
11603+
// Single API call to get PR details and extract headSha
11604+
console.log(`Getting PR details for PR #${prNumber}...`);
11605+
const prResponse = await GithubUtils_1.default.octokit.pulls.get({
11606+
owner: github_1.context.repo.owner,
11607+
repo: github_1.context.repo.repo,
11608+
pull_number: prNumber,
11609+
});
11610+
const headSha = prResponse.data.head.sha;
11611+
console.log(`PR #${prNumber} head SHA: ${headSha}`);
11612+
console.log(`Looking for test workflow runs for PR #${prNumber}`);
11613+
console.log(`Head SHA: ${headSha}`);
1160811614
while (Date.now() - startTime < maxWaitTime) {
1160911615
// Get all recent workflow runs for this repo
1161011616
const workflows = await GithubUtils_1.default.listWorkflowRunsForRepo({
@@ -11617,7 +11623,7 @@ async function waitForJestTests() {
1161711623
// Check if it's the Jest Unit Tests workflow specifically
1161811624
const isTestWorkflow = run.name === CONST_1.default.TEST_WORKFLOW_NAME || run.path === CONST_1.default.TEST_WORKFLOW_PATH;
1161911625
// Check if it's for our PR's head SHA
11620-
const matchesSHA = run.head_sha === github_1.context.sha;
11626+
const matchesSHA = run.head_sha === headSha;
1162111627
// For manual dispatch or when no PR context, be more flexible with event types
1162211628
// For regular PR events, maintain existing strict logic
1162311629
const isValidEvent = github_1.context.payload.pull_request
@@ -11646,7 +11652,7 @@ async function waitForJestTests() {
1164611652
});
1164711653
const inProgressTestRuns = inProgressWorkflows.data.workflow_runs.filter((run) => {
1164811654
const isTestWorkflow = run.name === CONST_1.default.TEST_WORKFLOW_NAME || run.path === CONST_1.default.TEST_WORKFLOW_PATH;
11649-
const matchesSHA = run.head_sha === github_1.context.sha;
11655+
const matchesSHA = run.head_sha === headSha;
1165011656
const isValidEvent = github_1.context.payload.pull_request
1165111657
? run.event === CONST_1.default.RUN_EVENT.PULL_REQUEST || run.event === CONST_1.default.RUN_EVENT.PULL_REQUEST_TARGET
1165211658
: run.event === CONST_1.default.RUN_EVENT.PULL_REQUEST || run.event === CONST_1.default.RUN_EVENT.PULL_REQUEST_TARGET || run.event === CONST_1.default.RUN_EVENT.PUSH;
@@ -11660,7 +11666,7 @@ async function waitForJestTests() {
1166011666
console.log('No matching test workflow runs found, checking if tests are required...');
1166111667
// Check if there might be no test workflow triggered
1166211668
// This could happen if the PR doesn't have testable changes
11663-
const allRecentRuns = workflows.data.workflow_runs.filter((run) => run.head_sha === github_1.context.sha);
11669+
const allRecentRuns = workflows.data.workflow_runs.filter((run) => run.head_sha === headSha);
1166411670
console.log(`Found ${allRecentRuns.length} workflow runs for this SHA.`);
1166511671
// Assume tests passed if no workflow runs exist
1166611672
if (allRecentRuns.length === 0) {

0 commit comments

Comments
 (0)