Skip to content

Commit 1047f3f

Browse files
authored
chore(dev): fix repo compliance check and major version check (#8920)
1 parent 30e82e8 commit 1047f3f

4 files changed

Lines changed: 21 additions & 18 deletions

File tree

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax
66

77

8-
# The yoshi-php team is the default owner for anything not
8+
# The cloud-sdk-php-team team is the default owner for anything not
99
# explicitly taken by someone else.
1010
* @googleapis/cloud-sdk-php-team
1111

.github/workflows/major-version-approval.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Major Version Release Requires 2+ yoshi-php Approvals
1+
name: Major Version Release Requires 2+ Approvals
22

33
on:
44
pull_request:
@@ -23,7 +23,7 @@ jobs:
2323
env:
2424
GH_TOKEN: ${{ secrets.SPLIT_TOKEN }}
2525
with:
26-
script: |
26+
script: |
2727
const { execSync } = require('child_process');
2828
2929
const requiredApprovals = 2;
@@ -44,31 +44,31 @@ jobs:
4444
.map(review => review.user.login)
4545
);
4646
if (approvals.size < requiredApprovals) {
47-
core.setFailed(`Requires ${requiredApprovals}+ approvals from the yoshi-php team. Only ${approvals.size} total approvals found.`)
47+
core.setFailed(`Requires ${requiredApprovals}+ approvals, only ${approvals.size} total approvals found.`)
4848
core.error('RE-RUN THIS WORKFLOW AFTER THE APPROVAL REQUIREMENTS ARE MET')
4949
return;
5050
}
5151
core.info(`Total approval count: ${approvals.size}`);
5252
5353
// 2. Get team members
54-
core.info('Fetching yoshi-php team members...');
55-
const teamMembersCmd = `gh api --paginate orgs/googleapis/teams/yoshi-php/members --jq '.[].login'`;
54+
core.info('Fetching cloud-sdk-php-team team members...');
55+
const teamMembersCmd = `gh api --paginate orgs/googleapis/teams/cloud-sdk-php-team/members --jq '.[].login'`;
5656
const teamMembersOutput = execSync(teamMembersCmd, { encoding: 'utf8', env: process.env });
5757
if (!teamMembersOutput.trim()) {
58-
core.error('Could not fetch any members for the yoshi-php team.');
58+
core.error('Could not fetch any members for the cloud-sdk-php-team team.');
5959
}
6060
const teamMembers = new Set(teamMembersOutput.trim().split('\n'));
6161
6262
// 3. Compare
6363
const matchingApprovals = [...approvals].filter(login => teamMembers.has(login));
6464
const count = matchingApprovals.length;
6565
66-
core.info(`Found ${count} approval(s) from the yoshi-php team.`);
66+
core.info(`Found ${count} approval(s) from the cloud-sdk-php-team team.`);
6767
6868
if (count >= requiredApprovals) {
69-
core.info(`Success: Requirement of ${requiredApprovals}+ yoshi-php approvals met with ${count} approvals.`);
69+
core.info(`Success: Requirement of ${requiredApprovals}+ approvals met with ${count} approvals.`);
7070
} else {
71-
core.setFailed(`Requires ${requiredApprovals}+ approvals from the yoshi-php team. Only ${count} yoshi-php approvals found.`);
71+
core.setFailed(`Requires ${requiredApprovals}+ approvals, only ${count} cloud-sdk-php-team approvals found.`);
7272
core.error('RE-RUN THIS WORKFLOW AFTER THE APPROVAL REQUIREMENTS ARE MET')
7373
}
7474
} catch (error) {

dev/src/Command/RepoComplianceCommand.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
class RepoComplianceCommand extends Command
3939
{
4040
private const PACKAGIST_USERNAME = 'google-cloud';
41+
public const PHP_TEAM = 'cloud-sdk-php-team';
4142
private GitHub $github;
4243
private Packagist $packagist;
4344

@@ -145,7 +146,7 @@ private function checkTeamCompliance(array $details)
145146
{
146147
return !empty(array_filter(
147148
explode("\n", $details['teams']),
148-
fn ($team) => $team === 'yoshi-php: admin'
149+
fn ($team) => $team === (self::PHP_TEAM . ': admin')
149150
));
150151
}
151152

@@ -200,11 +201,12 @@ private function askFixTeamCompliance(InputInterface $input, OutputInterface $ou
200201
return false;
201202
}
202203
$question = new ConfirmationQuestion(sprintf(
203-
'Repo %s does not have "yoshi-php" as an admin. Would you like to add it? (Y/n)',
204-
$repoName
204+
'Repo %s does not have "%s" as an admin. Would you like to add it? (Y/n)',
205+
$repoName,
206+
self::PHP_TEAM,
205207
), true);
206208
if ($this->getHelper('question')->ask($input, $output, $question)) {
207-
return $this->github->updateTeamPermission('googleapis', 'yoshi-php', $repoName, 'admin');
209+
return $this->github->updateTeamPermission('googleapis', self::PHP_TEAM, $repoName, 'admin');
208210
}
209211
return false;
210212
}

dev/src/Command/RepoSplitCommand.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class RepoSplitCommand extends Command
4545
const PARENT_TAG_NAME = 'https://github.com/%s/releases/tag/%s';
4646
const EXEC_DIR = '.split';
4747
const TOKEN_ENV = 'GH_OAUTH_TOKEN';
48+
private const PHP_TEAM = RepoComplianceCommand::PHP_TEAM;
4849

4950
private string $rootPath;
5051

@@ -393,13 +394,13 @@ private function processComponent(
393394
}
394395
}
395396

396-
// Ensure "yoshi-php" is an admin
397-
$ret = $github->updateTeamPermission('googleapis', 'yoshi-php', $repoName, 'admin');
397+
// Add team permission
398+
$ret = $github->updateTeamPermission('googleapis', self::PHP_TEAM, $repoName, 'admin');
398399

399400
if ($ret) {
400-
$output->writeln(sprintf('<comment>%s</comment>: Added "yoshi-php" as admin.', $componentId));
401+
$output->writeln(sprintf('<comment>%s</comment>: Added "%s" as admin.', $componentId, self::PHP_TEAM));
401402
} else {
402-
$output->writeln(sprintf('<error>%s</error>: Unable to add "yoshi-php" as admin.', $componentId));
403+
$output->writeln(sprintf('<error>%s</error>: Unable to add "%s" as admin.', $componentId, self::PHP_TEAM));
403404

404405
return false;
405406
}

0 commit comments

Comments
 (0)