-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into renovate/lycheeverse-lychee-action-1.x
- Loading branch information
Showing
40 changed files
with
2,364 additions
and
2,145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
packages/auto-approve/src/process-checks/ruby/apiary-codegen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import {PullRequest} from '../../interfaces'; | ||
import { | ||
checkAuthor, | ||
checkTitleOrBody, | ||
reportIndividualChecks, | ||
} from '../../utils-for-pr-checking'; | ||
import {Octokit} from '@octokit/rest'; | ||
import {BaseLanguageRule} from '../base'; | ||
|
||
/** | ||
* The RubyApiaryCodegen class's checkPR function returns | ||
* true if the PR: | ||
- has an author that is 'yoshi-code-bot' | ||
- has a title that matches the regexp: /^feat: Automated regeneration of .* client$/ | ||
*/ | ||
export class RubyApiaryCodegen extends BaseLanguageRule { | ||
classRule = { | ||
author: 'yoshi-code-bot', | ||
titleRegex: /^feat: Automated regeneration of .* client$/, | ||
}; | ||
constructor(octokit: Octokit) { | ||
super(octokit); | ||
} | ||
|
||
public async checkPR(incomingPR: PullRequest): Promise<boolean> { | ||
const authorshipMatches = checkAuthor( | ||
this.classRule.author, | ||
incomingPR.author | ||
); | ||
|
||
const titleMatches = checkTitleOrBody( | ||
incomingPR.title, | ||
this.classRule.titleRegex | ||
); | ||
reportIndividualChecks( | ||
['authorshipMatches', 'titleMatches'], | ||
[authorshipMatches, titleMatches], | ||
incomingPR.repoOwner, | ||
incomingPR.repoName, | ||
incomingPR.prNumber | ||
); | ||
|
||
return authorshipMatches && titleMatches; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import {RubyApiaryCodegen} from '../src/process-checks/ruby/apiary-codegen'; | ||
import {describe, it} from 'mocha'; | ||
import assert from 'assert'; | ||
const {Octokit} = require('@octokit/rest'); | ||
|
||
const octokit = new Octokit({ | ||
auth: 'mypersonalaccesstoken123', | ||
}); | ||
describe('RubyApiaryCodegen', () => { | ||
it('should return false in checkPR if incoming PR does not match classRules', async () => { | ||
const incomingPR = { | ||
author: 'testAuthor', | ||
title: 'testTitle', | ||
fileCount: 3, | ||
changedFiles: [{filename: 'hello', sha: '2345'}], | ||
repoName: 'testRepoName', | ||
repoOwner: 'testRepoOwner', | ||
prNumber: 1, | ||
body: 'body', | ||
}; | ||
|
||
const rule = new RubyApiaryCodegen(octokit); | ||
|
||
assert.deepStrictEqual(await rule.checkPR(incomingPR), false); | ||
}); | ||
|
||
it('should return true in checkPR if incoming PR does match classRules', async () => { | ||
const incomingPR = { | ||
author: 'yoshi-code-bot', | ||
title: 'feat: Automated regeneration of admin v1 client', | ||
fileCount: 3, | ||
changedFiles: [ | ||
{ | ||
filename: 'README.md', | ||
sha: '2345', | ||
}, | ||
], | ||
repoName: 'testRepoName', | ||
repoOwner: 'testRepoOwner', | ||
prNumber: 1, | ||
body: 'body', | ||
}; | ||
|
||
const rule = new RubyApiaryCodegen(octokit); | ||
|
||
assert.ok(await rule.checkPR(incomingPR)); | ||
}); | ||
}); |
Oops, something went wrong.