Skip to content

Commit 53e704b

Browse files
authored
feat(dev): add release:verify and repo:compliance --new-packagist-token, reorganize all commands (#8756)
1 parent 5d20399 commit 53e704b

22 files changed

Lines changed: 409 additions & 138 deletions

.github/workflows/release.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,10 @@ jobs:
6969
--packagist-username=${{ vars.PACKAGIST_USERNAME }} \
7070
--packagist-token=${{ secrets.PACKAGIST_TOKEN }} \
7171
--packagist-safe-token=${{ secrets.PACKAGIST_SAFE_TOKEN }}
72+
- name: Verify all releases made it to Packagist
73+
uses: nick-invision/retry-action@v1
74+
with:
75+
command: |
76+
./dev/google-cloud verify-release
77+
timeout_minutes: 1
78+
max_attempts: 3

dev/README.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,31 @@
33
The `dev` component features helpful development tools. Run `dev/google-cloud`
44
for a list of all available commands:
55

6-
| Command | Description |
7-
| ---------------------- | ---------------------------------------------------------------- |
8-
| `new-component` | Generate a new library |
9-
| `update-component` | Update an existing component |
10-
| `add-sample-to-readme` | Add a sample from the component's `samples/` dir to its README |
11-
| `component-info` | List component information |
12-
| `docfx` | Generate DocFX YAML |
13-
| `release-info` | List components and versions for a monorepo release |
14-
| `split` | Split `google-cloud-php` into sub repositories and tag a release |
15-
6+
```sh
7+
$ ./google-cloud
8+
Available commands:
9+
completion Dump the shell completion script
10+
docfx Generate DocFX yaml from a phpdoc strucutre.xml
11+
help Display help for a command
12+
list List commands
13+
component
14+
component:add-version Add a new version to an existing Component
15+
component:info [info] list info of a component or the whole library
16+
component:new Add a new Component
17+
component:update:deps update a dependency across all components
18+
component:update:gencode Update one or all components using Owlbot
19+
component:update:readme-sample Add a sample to a component
20+
release
21+
release:info list information for a google-cloud-php release
22+
release:verify Verifies the package version from packagist.
23+
repo
24+
repo:compliance ensure all github repositories meet compliance
25+
repo:split [split] Split subtree and push to various remotes.
26+
```
1627

1728
Additionally, there are scripts in the `sh` directory which are used in our CI:
1829

1930
| Command | Description |
2031
| ------------------- | --------------------------- |
2132
| `sh/static-analysis`| Run phpstan static ananlysis|
33+
| `sh/style-fix` | Run phpcs style check |

dev/google-cloud

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@ if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
2222

2323
require __DIR__ . '/vendor/autoload.php';
2424

25+
use Google\Cloud\Dev\Command\ComponentAddVersionCommand;
2526
use Google\Cloud\Dev\Command\ComponentInfoCommand;
27+
use Google\Cloud\Dev\Command\ComponentNewCommand;
28+
use Google\Cloud\Dev\Command\ComponentUpdateGencodeCommand;
29+
use Google\Cloud\Dev\Command\ComponentUpdateReadmeSampleCommand;
30+
use Google\Cloud\Dev\Command\ComponentUpdateDepsCommand;
2631
use Google\Cloud\Dev\Command\DocFxCommand;
27-
use Google\Cloud\Dev\Command\NewComponentCommand;
28-
use Google\Cloud\Dev\Command\AddVersionCommand;
29-
use Google\Cloud\Dev\Command\RepoInfoCommand;
3032
use Google\Cloud\Dev\Command\ReleaseInfoCommand;
31-
use Google\Cloud\Dev\Command\SplitCommand;
32-
use Google\Cloud\Dev\Command\UpdateComponentCommand;
33-
use Google\Cloud\Dev\Command\UpdateDepsCommand;
34-
use Google\Cloud\Dev\Command\UpdateReadmeSampleCommand;
33+
use Google\Cloud\Dev\Command\ReleaseVerifyCommand;
34+
use Google\Cloud\Dev\Command\RepoComplianceCommand;
35+
use Google\Cloud\Dev\Command\RepoSplitCommand;
3536
use Symfony\Component\Console\Application;
3637

3738
if (!class_exists(Application::class)) {
@@ -46,13 +47,14 @@ $rootDirectory = realpath(__DIR__ . '/../') . '/';
4647

4748
$app = new Application;
4849
$app->add(new ComponentInfoCommand());
50+
$app->add(new ComponentAddVersionCommand($rootDirectory));
51+
$app->add(new ComponentNewCommand($rootDirectory));
52+
$app->add(new ComponentUpdateGencodeCommand($rootDirectory));
53+
$app->add(new ComponentUpdateReadmeSampleCommand($rootDirectory));
54+
$app->add(new ComponentUpdateDepsCommand());
4955
$app->add(new DocFxCommand());
50-
$app->add(new NewComponentCommand($rootDirectory));
51-
$app->add(new AddVersionCommand($rootDirectory));
52-
$app->add(new RepoInfoCommand());
5356
$app->add(new ReleaseInfoCommand());
54-
$app->add(new SplitCommand($rootDirectory));
55-
$app->add(new UpdateComponentCommand($rootDirectory));
56-
$app->add(new UpdateDepsCommand());
57-
$app->add(new UpdateReadmeSampleCommand($rootDirectory));
57+
$app->add(new ReleaseVerifyCommand());
58+
$app->add(new RepoComplianceCommand());
59+
$app->add(new RepoSplitCommand($rootDirectory));
5860
$app->run();

dev/src/Command/AddVersionCommand.php renamed to dev/src/Command/ComponentAddVersionCommand.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,23 @@
2525
use Symfony\Component\Console\Output\OutputInterface;
2626
use Symfony\Component\Yaml\Yaml;
2727
use RuntimeException;
28-
use Google\Cloud\Dev\Component;
2928

3029
/**
3130
* Add a Component
3231
* @internal
3332
*/
34-
class AddVersionCommand extends Command
33+
class ComponentAddVersionCommand extends Command
3534
{
3635
private const OWL_BOT_REGEX='/.*\/\(([\w|]+)\).*/';
3736

3837
protected function configure()
3938
{
40-
$this->setName('add-version')
39+
$this->setName('component:add-version')
4140
->setDescription('Add a new version to an existing Component')
4241
->addArgument('component', InputArgument::REQUIRED, 'Component to add the version to.')
4342
->addArgument('version', InputArgument::REQUIRED, 'The new version to add.')
4443
->addOption(
45-
'no-update-component',
44+
'no-update',
4645
null,
4746
InputOption::VALUE_NONE,
4847
'Do not run the update-component command after adding the component skeleton'
@@ -96,31 +95,34 @@ protected function execute(InputInterface $input, OutputInterface $output)
9695
}
9796

9897
// Run "update-component" command to generate the new version and add its sample to the README
99-
if ($input->getOption('no-update-component')) {
98+
if ($input->getOption('no-update')) {
10099
// nothing left to do
101-
$output->writeln('Skipping component update: "--no-update-component" flag set');
100+
$output->writeln('Skipping component update: "--no-update" flag set');
102101
return 0;
103102
}
104103

105104
$args = [
106105
'component' => $componentName,
107106
'--timeout' => $input->getOption('timeout'),
108107
];
109-
if (!$this->getApplication()->has('update-component')) {
108+
if (!$this->getApplication()->has('component:update:gencode')) {
110109
throw new \RuntimeException(
111-
'Application does not have an update-component command. '
112-
. 'Run with --no-update-component to skip this.'
110+
'Application does not have an component:update:gencode command. '
111+
. 'Run with --no-update to skip this.'
113112
);
114113
}
115-
$updateCommand = $this->getApplication()->find('update-component');
114+
$updateCommand = $this->getApplication()->find('component:update:gencode');
116115
$returnCode = $updateCommand->run(new ArrayInput($args), $output);
117116
if ($returnCode !== Command::SUCCESS) {
118117
return $returnCode;
119118
}
120-
// Run "update-readme-sample" command to ensure our README contains the latest version's sample.
119+
// Run "component:update:readme-sample" command to ensure our README contains the latest version's sample.
121120
$updateReadmeSampleArgs = ['--component' => [$componentName], '--update' => true];
122-
if (!$updateReadmeSampleCommand = $this->getApplication()->find('update-readme-sample')) {
123-
throw new \RuntimeException('Application does not have an add-samples-to-readme command.');
121+
if (!$updateReadmeSampleCommand = $this->getApplication()->find('component:update::readme-sample')) {
122+
throw new \RuntimeException(
123+
'Application does not have an component:update::readme-sample command. '
124+
. 'Run with --no-update to skip this.'
125+
);
124126
}
125127
return $updateReadmeSampleCommand->run(new ArrayInput($updateReadmeSampleArgs), $output);
126128
}

dev/src/Command/ComponentInfoCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use Symfony\Component\Console\Command\Command;
2424
use Symfony\Component\Console\Helper\Table;
2525
use Symfony\Component\Console\Input\InputInterface;
26-
use Symfony\Component\Console\Input\InputArgument;
2726
use Symfony\Component\Console\Input\InputOption;
2827
use Symfony\Component\Console\Output\OutputInterface;
2928
use GuzzleHttp\Client;
@@ -73,7 +72,7 @@ class ComponentInfoCommand extends Command
7372

7473
protected function configure()
7574
{
76-
$this->setName('component-info')
75+
$this->setName('component:info')
7776
->setAliases(['info'])
7877
->setDescription('list info of a component or the whole library')
7978
->addOption('component', 'c', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'get info for a single component', [])
Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@
3636
use Twig\Environment;
3737
use RuntimeException;
3838
use Exception;
39-
use Google\Cloud\Dev\Component;
4039

4140
/**
4241
* Add a Component
4342
* @internal
4443
*/
45-
class NewComponentCommand extends Command
44+
class ComponentNewCommand extends Command
4645
{
4746
private const TEMPLATE_DIR = __DIR__ . '/../../templates';
4847
private const COPY_FILES = [
@@ -75,14 +74,14 @@ public function __construct($rootPath, ?Client $httpClient = null)
7574

7675
protected function configure()
7776
{
78-
$this->setName('new-component')
77+
$this->setName('component:new')
7978
->setDescription('Add a new Component')
8079
->addArgument('proto', InputArgument::REQUIRED, 'Path to service proto.')
8180
->addOption(
82-
'no-update-component',
81+
'no-update',
8382
null,
8483
InputOption::VALUE_NONE,
85-
'Do not run the update-component command after adding the component skeleton'
84+
'Do not run the component:update:gencode command after adding the component skeleton'
8685
)
8786
->addOption(
8887
'timeout',
@@ -231,25 +230,33 @@ protected function execute(InputInterface $input, OutputInterface $output)
231230
$composer->updateMainComposer();
232231
$composer->createComponentComposer($new->displayName, $new->githubRepo);
233232

234-
if (!$input->getOption('no-update-component')) {
233+
if (!$input->getOption('no-update')) {
235234
$args = [
236235
'component' => $new->componentName,
237236
'--timeout' => $timeout,
238237
];
239-
if (!$this->getApplication()->has('update-component')) {
238+
if (!$this->getApplication()->has('component:update:gencode')) {
240239
throw new \RuntimeException(
241-
'Application does not have an update-component command. '
242-
. 'Run with --no-update-component to skip this.'
240+
'Application does not have an component:update:gencode command. '
241+
. 'Run with --no-update to skip this.'
243242
);
244243
}
245-
$updateCommand = $this->getApplication()->find('update-component');
244+
$updateCommand = $this->getApplication()->find('component:update:gencode');
246245
$returnCode = $updateCommand->run(new ArrayInput($args), $output);
247246
if ($returnCode !== Command::SUCCESS) {
248247
return $returnCode;
249248
}
250-
$updateReadmeSampleArgs = ['--component' => [$new->componentName]];
251-
$updateReadmeSampleCommand = $this->getApplication()->find('update-readme-sample');
252-
$returnCode = $updateReadmeSampleCommand->run(new ArrayInput($updateReadmeSampleArgs), $output);
249+
if (!$this->getApplication()->has('component:update:readme-sample')) {
250+
throw new \RuntimeException(
251+
'Application does not have an component:update:readme-sample command. '
252+
. 'Run with --no-update to skip this.'
253+
);
254+
}
255+
$updateReadmeSampleCommand = $this->getApplication()->find('component:update:readme-sample');
256+
$returnCode = $updateReadmeSampleCommand->run(
257+
new ArrayInput(['--component' => [$new->componentName]]),
258+
$output
259+
);
253260
if ($returnCode !== Command::SUCCESS) {
254261
return $returnCode;
255262
}

dev/src/Command/UpdateDepsCommand.php renamed to dev/src/Command/ComponentUpdateDepsCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
*
3131
* @internal
3232
*/
33-
class UpdateDepsCommand extends Command
33+
class ComponentUpdateDepsCommand extends Command
3434
{
3535
protected function configure()
3636
{
37-
$this->setName('update-deps')
37+
$this->setName('component:update:deps')
3838
->setDescription('update a dependency across all components')
3939
->addArgument('package', InputArgument::REQUIRED, 'Package name to update, e.g. "google/gax"')
4040
->addArgument('version', InputArgument::OPTIONAL, 'Package version to update to, e.g. "1.4.0"', '')

dev/src/Command/UpdateComponentCommand.php renamed to dev/src/Command/ComponentUpdateGencodeCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*
3737
* @internal
3838
*/
39-
class UpdateComponentCommand extends Command
39+
class ComponentUpdateGencodeCommand extends Command
4040
{
4141
private const OWLBOT_CLI_IMAGE = 'gcr.io/cloud-devrel-public-resources/owlbot-cli:latest';
4242

@@ -57,7 +57,7 @@ public function __construct($rootPath, ?RunProcess $runProcess = null)
5757

5858
protected function configure()
5959
{
60-
$this->setName('update-component')
60+
$this->setName('component:update:gencode')
6161
->setDescription('Update one or all components using Owlbot')
6262
->addArgument(
6363
'component',

dev/src/Command/UpdateReadmeSampleCommand.php renamed to dev/src/Command/ComponentUpdateReadmeSampleCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* Add a Component
2828
* @internal
2929
*/
30-
class UpdateReadmeSampleCommand extends Command
30+
class ComponentUpdateReadmeSampleCommand extends Command
3131
{
3232
private $rootPath;
3333

@@ -43,7 +43,7 @@ public function __construct(string $rootPath)
4343

4444
protected function configure()
4545
{
46-
$this->setName('update-readme-sample')
46+
$this->setName('component:update:readme-sample')
4747
->setDescription('Add a sample to a component')
4848
->addOption('component', 'c', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Add to the readme of the specified component', [])
4949
->addOption('update', '', InputOption::VALUE_NONE, 'updates the sample in the readme if it exists');

dev/src/Command/DocFxCommand.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
use Symfony\Component\Console\Command\Command;
2121
use Symfony\Component\Console\Input\InputInterface;
22-
use Symfony\Component\Console\Input\InputArgument;
2322
use Symfony\Component\Console\Input\InputOption;
2423
use Symfony\Component\Console\Output\OutputInterface;
2524
use Symfony\Component\Process\Process;

0 commit comments

Comments
 (0)