Skip to content

Commit 928d3bb

Browse files
authoredJan 12, 2025··
revert(prlint): fail prlinter on codecov failures, with exemption label (#32867)
Reverts #32674
1 parent b49c116 commit 928d3bb

File tree

2 files changed

+9
-53
lines changed

2 files changed

+9
-53
lines changed
 

‎tools/@aws-cdk/prlint/lint.ts

+5-46
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,7 @@ export type GitHubPr =
1010
Endpoints['GET /repos/{owner}/{repo}/pulls/{pull_number}']['response']['data'];
1111

1212
export const CODE_BUILD_CONTEXT = 'AWS CodeBuild us-east-1 (AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv)';
13-
export const CODECOV_PREFIX = 'codecov/';
14-
15-
export const CODECOV_CHECKS = [
16-
'patch',
17-
'patch/packages/aws-cdk',
18-
'patch/packages/aws-cdk-lib/core',
19-
'project',
20-
'project/packages/aws-cdk',
21-
'project/packages/aws-cdk-lib/core'
22-
];
13+
2314
const PR_FROM_MAIN_ERROR = 'Pull requests from `main` branch of a fork cannot be accepted. Please reopen this contribution from another branch on your fork. For more information, see https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md#step-4-pull-request.';
2415

2516
/**
@@ -33,7 +24,6 @@ enum Exemption {
3324
CLI_INTEG_TESTED = 'pr-linter/cli-integ-tested',
3425
REQUEST_CLARIFICATION = 'pr/reviewer-clarification-requested',
3526
REQUEST_EXEMPTION = 'pr-linter/exemption-requested',
36-
CODECOV = "pr-linter/exempt-codecov",
3727
}
3828

3929
export interface GithubStatusEvent {
@@ -346,23 +336,14 @@ export class PullRequestLinter {
346336
* @param sha the commit sha to evaluate
347337
*/
348338
private async codeBuildJobSucceeded(sha: string): Promise<boolean> {
349-
return this.checkStatusSucceeded(sha, CODE_BUILD_CONTEXT);
350-
}
351-
352-
/**
353-
* Check a specific status check to see if it is successful for the given commit
354-
*
355-
* @param sha the commit sha to evaluate
356-
*/
357-
private async checkStatusSucceeded(sha: string, context: string): Promise<boolean> {
358-
const statuses = await this.client.paginate(this.client.repos.listCommitStatusesForRef, {
339+
const statuses = await this.client.repos.listCommitStatusesForRef({
359340
owner: this.prParams.owner,
360341
repo: this.prParams.repo,
361342
ref: sha,
362343
});
363-
let status = statuses.filter(status => status.context === context).map(status => status.state);
364-
console.log(`${context} statuses: ${status}`);
365-
return statuses.some(status => status.context === context && status.state === 'success');
344+
let status = statuses.data.filter(status => status.context === CODE_BUILD_CONTEXT).map(status => status.state);
345+
console.log("CodeBuild Commit Statuses: ", status);
346+
return statuses.data.some(status => status.context === CODE_BUILD_CONTEXT && status.state === 'success');
366347
}
367348

368349
public async validateStatusEvent(pr: GitHubPr, status: StatusEvent): Promise<void> {
@@ -594,24 +575,6 @@ export class PullRequestLinter {
594575
],
595576
});
596577

597-
const codecovTests: Test[] = [];
598-
for (const c of CODECOV_CHECKS) {
599-
const checkName = `${CODECOV_PREFIX}${c}`;
600-
const succeeded = await this.checkStatusSucceeded(sha, checkName);
601-
codecovTests.push({
602-
test: () => {
603-
const result = new TestResult();
604-
result.assessFailure(!succeeded, `${checkName} job is not succeeding`);
605-
return result;
606-
}
607-
})
608-
}
609-
610-
validationCollector.validateRuleSet({
611-
exemption: shouldExemptCodecov,
612-
testRuleSet: codecovTests,
613-
});
614-
615578
console.log("Deleting PR Linter Comment now");
616579
await this.deletePRLinterComment();
617580
try {
@@ -693,10 +656,6 @@ function fixContainsIntegTest(pr: GitHubPr, files: GitHubFile[]): TestResult {
693656
return result;
694657
}
695658

696-
function shouldExemptCodecov(pr: GitHubPr): boolean {
697-
return hasLabel(pr, Exemption.CODECOV);
698-
}
699-
700659
function shouldExemptReadme(pr: GitHubPr): boolean {
701660
return hasLabel(pr, Exemption.README);
702661
}

‎tools/@aws-cdk/prlint/test/lint.test.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -1182,13 +1182,10 @@ function configureMock(pr: Subset<linter.GitHubPr>, prFiles?: linter.GitHubFile[
11821182
const reposClient = {
11831183
listCommitStatusesForRef() {
11841184
return {
1185-
data: [
1186-
{
1187-
context: linter.CODE_BUILD_CONTEXT,
1188-
state: 'success',
1189-
},
1190-
...(linter.CODECOV_CHECKS.map(c => ({ context: `${linter.CODECOV_PREFIX}${c}`, state: 'success'})))
1191-
],
1185+
data: [{
1186+
context: linter.CODE_BUILD_CONTEXT,
1187+
state: 'success',
1188+
}],
11921189
};
11931190
},
11941191
};

0 commit comments

Comments
 (0)
Please sign in to comment.