feat: [Gax] Add script to download and generate the showcase client and download the showcase server#9347
feat: [Gax] Add script to download and generate the showcase client and download the showcase server#9347Hectorhammett wants to merge 11 commits into
Conversation
67b386e to
f5c0273
Compare
bshaffer
left a comment
There was a problem hiding this comment.
Looks great! Most of what I have is nits - I think we have a lot of opportunities to simplify this.
| private string $rootDirectory; | ||
| private Filesystem $fs; | ||
|
|
||
| public function __construct(string $rootDirectory) |
There was a problem hiding this comment.
nit but everywhere else this is $rootPath
| ) | ||
| ->addOption( | ||
| 'showcase-path', | ||
| 'p', |
There was a problem hiding this comment.
nit but, I'd say just make all of the aliases null (except for out-dir), as p and a aren't exactly intuitive
| 'Gax' | ||
| ) | ||
| ->addOption( | ||
| 'generator-path', |
There was a problem hiding this comment.
nit, can we call this gapic-generator-path?
| $outDir = $input->getOption('out-dir'); | ||
| $targetDir = $this->rootDirectory . trim($outDir, '/'); | ||
| $conformanceDir = $targetDir . '/tests/Conformance'; | ||
| $tmpOutputDir = $conformanceDir . '/tmp_out'; |
There was a problem hiding this comment.
I'd say make this a temporary file in the filesystem, e.g.
| $tmpOutputDir = $conformanceDir . '/tmp_out'; | |
| $tmpOutputDir = tempnam(sys_get_temp_dir(), 'showcase_out'); |
|
|
||
| $outDir = $input->getOption('out-dir'); | ||
| $targetDir = $this->rootDirectory . trim($outDir, '/'); | ||
| $conformanceDir = $targetDir . '/tests/Conformance'; |
There was a problem hiding this comment.
This should not be hardcoded, but rather part of the out-dir by default
| $conformanceDir = $targetDir . '/tests/Conformance'; |
| $allProtoFiles = glob($schemaDir . '/*.proto'); | ||
| $generatorProtoFiles = array_values(array_filter( | ||
| $allProtoFiles, | ||
| fn ($file) => !str_ends_with($file, 'messaging.proto') |
There was a problem hiding this comment.
why are we explicitly excluding the messaging client? Please leave a comment explaining it
| '--descriptor_set_out=' . $descFile, | ||
| ], $generatorProtoFiles, [ | ||
| $googleapisPath . '/google/cloud/common_resources.proto', | ||
| ]); |
There was a problem hiding this comment.
nit but, can we just do this?
| '--descriptor_set_out=' . $descFile, | |
| ], $generatorProtoFiles, [ | |
| $googleapisPath . '/google/cloud/common_resources.proto', | |
| ]); | |
| '--descriptor_set_out=' . $descFile, | |
| $googleapisPath . '/google/cloud/common_resources.proto' | |
| ], $generatorProtoFiles); |
|
|
||
| $serviceYaml = file_exists($schemaDir . '/showcase_v1beta1.yaml') ? file_get_contents($schemaDir . '/showcase_v1beta1.yaml') : null; |
There was a problem hiding this comment.
we can assume it exists... and if we use the filesystem component, it will throw an Exception if it doesn't exist, which would be even better (since we expect it to exist)
| $serviceYaml = file_exists($schemaDir . '/showcase_v1beta1.yaml') ? file_get_contents($schemaDir . '/showcase_v1beta1.yaml') : null; | |
| $serviceYaml = $this->fs->readFile($schemaDir . '/showcase_v1beta1.yaml'); |
| $this->fs->mkdir(dirname($fullPath)); | ||
| file_put_contents($fullPath, $content); |
There was a problem hiding this comment.
Should we stick with using the filesystem component? That will make calling mkdir redundant:
| $this->fs->mkdir(dirname($fullPath)); | |
| file_put_contents($fullPath, $content); | |
| $this->fs->dumpFile($fullPath, $content); |
| -1, | ||
| false, | ||
| MigrationMode::NEW_SURFACE_ONLY | ||
| ); |
There was a problem hiding this comment.
can we get some comments or some named parameters here?
Created a script for downloading and generating the showcase client for the conformance tests. This client was generated a long time ago and we need a consistent way to generate and update the showcase client and server, specially with PQC around the corner.
Closes: #9229
Depends on: googleapis/gapic-generator-php#838