Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax


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

Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/major-version-approval.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Major Version Release Requires 2+ yoshi-php Approvals
name: Major Version Release Requires 2+ Approvals

on:
pull_request:
Expand All @@ -23,7 +23,7 @@ jobs:
env:
GH_TOKEN: ${{ secrets.SPLIT_TOKEN }}
with:
script: |
script: |
const { execSync } = require('child_process');

const requiredApprovals = 2;
Expand All @@ -44,31 +44,31 @@ jobs:
.map(review => review.user.login)
);
if (approvals.size < requiredApprovals) {
core.setFailed(`Requires ${requiredApprovals}+ approvals from the yoshi-php team. Only ${approvals.size} total approvals found.`)
core.setFailed(`Requires ${requiredApprovals}+ approvals, only ${approvals.size} total approvals found.`)
core.error('RE-RUN THIS WORKFLOW AFTER THE APPROVAL REQUIREMENTS ARE MET')
return;
}
core.info(`Total approval count: ${approvals.size}`);

// 2. Get team members
core.info('Fetching yoshi-php team members...');
const teamMembersCmd = `gh api --paginate orgs/googleapis/teams/yoshi-php/members --jq '.[].login'`;
core.info('Fetching cloud-sdk-php-team team members...');
const teamMembersCmd = `gh api --paginate orgs/googleapis/teams/cloud-sdk-php-team/members --jq '.[].login'`;
const teamMembersOutput = execSync(teamMembersCmd, { encoding: 'utf8', env: process.env });
if (!teamMembersOutput.trim()) {
core.error('Could not fetch any members for the yoshi-php team.');
core.error('Could not fetch any members for the cloud-sdk-php-team team.');
}
const teamMembers = new Set(teamMembersOutput.trim().split('\n'));

// 3. Compare
const matchingApprovals = [...approvals].filter(login => teamMembers.has(login));
const count = matchingApprovals.length;

core.info(`Found ${count} approval(s) from the yoshi-php team.`);
core.info(`Found ${count} approval(s) from the cloud-sdk-php-team team.`);

if (count >= requiredApprovals) {
core.info(`Success: Requirement of ${requiredApprovals}+ yoshi-php approvals met with ${count} approvals.`);
core.info(`Success: Requirement of ${requiredApprovals}+ approvals met with ${count} approvals.`);
} else {
core.setFailed(`Requires ${requiredApprovals}+ approvals from the yoshi-php team. Only ${count} yoshi-php approvals found.`);
core.setFailed(`Requires ${requiredApprovals}+ approvals, only ${count} cloud-sdk-php-team approvals found.`);
core.error('RE-RUN THIS WORKFLOW AFTER THE APPROVAL REQUIREMENTS ARE MET')
}
} catch (error) {
Expand Down
10 changes: 6 additions & 4 deletions dev/src/Command/RepoComplianceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
class RepoComplianceCommand extends Command
{
private const PACKAGIST_USERNAME = 'google-cloud';
public const PHP_TEAM = 'cloud-sdk-php-team';
private GitHub $github;
private Packagist $packagist;

Expand Down Expand Up @@ -145,7 +146,7 @@ private function checkTeamCompliance(array $details)
{
return !empty(array_filter(
explode("\n", $details['teams']),
fn ($team) => $team === 'yoshi-php: admin'
fn ($team) => $team === (self::PHP_TEAM . ': admin')
));
}

Expand Down Expand Up @@ -200,11 +201,12 @@ private function askFixTeamCompliance(InputInterface $input, OutputInterface $ou
return false;
}
$question = new ConfirmationQuestion(sprintf(
'Repo %s does not have "yoshi-php" as an admin. Would you like to add it? (Y/n)',
$repoName
'Repo %s does not have "%s" as an admin. Would you like to add it? (Y/n)',
$repoName,
self::PHP_TEAM,
), true);
if ($this->getHelper('question')->ask($input, $output, $question)) {
return $this->github->updateTeamPermission('googleapis', 'yoshi-php', $repoName, 'admin');
return $this->github->updateTeamPermission('googleapis', self::PHP_TEAM, $repoName, 'admin');
}
return false;
}
Expand Down
9 changes: 5 additions & 4 deletions dev/src/Command/RepoSplitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class RepoSplitCommand extends Command
const PARENT_TAG_NAME = 'https://github.com/%s/releases/tag/%s';
const EXEC_DIR = '.split';
const TOKEN_ENV = 'GH_OAUTH_TOKEN';
private const PHP_TEAM = RepoComplianceCommand::PHP_TEAM;

private string $rootPath;

Expand Down Expand Up @@ -393,13 +394,13 @@ private function processComponent(
}
}

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

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

return false;
}
Expand Down
Loading