Skip to content

Commit

Permalink
chore: add and refactor dev commands (#5861)
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer authored Mar 28, 2023
1 parent cea265c commit 343d5ac
Show file tree
Hide file tree
Showing 268 changed files with 2,888 additions and 13,151 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: DoxFX Test Suite
on:
push:
branches: [ main ]
pull_request:
workflow_dispatch:

jobs:
docfx:
name: "Run DocFX tests"
runs-on: ubuntu-latest
env:
PHPDOC_ENV: prod
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- run: pip install --require-hashes -r .kokoro/docs/docker/requirements.txt
- name: Setup PHP
uses: shivammathur/setup-php@verbose
with:
php-version: "8.0"
- name: Extract phpDocumentor
id: extract
uses: shrink/actions-docker-extract@v2
with:
image: "phpdoc/phpdoc:202301112131087e6028"
path: "/opt/phpdoc/."
- name: Symlink phpDocumentor
run: ln -s $(pwd)/${{ steps.extract.outputs.destination }}/bin/phpdoc /usr/local/bin/phpdoc
- name: Install Dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
command: composer --no-interaction --no-ansi --no-progress update -d dev
- name: Run DocFX Unit Test Suite
run: dev/vendor/bin/phpunit -c dev/phpunit-docfx.xml.dist
- name: Run Docs Generator (Dry Run)
run: .kokoro/docs/publish.sh
21 changes: 21 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CS Test Suite
on:
push:
branches: [ main ]
pull_request:
workflow_dispatch:

jobs:
style:
runs-on: ubuntu-latest
name: PHP Style Check
steps:
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
- name: "Install dependencies"
run: composer global require "squizlabs/php_codesniffer:3.*"
- name: Run PHPCS Code Style Checker
run: ~/.composer/vendor/bin/phpcs --standard=phpcs-ruleset.xml -p
51 changes: 6 additions & 45 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,55 +66,16 @@ jobs:
- name: Run Package Test Suites
run: bash .github/run-package-tests.sh

style:
test_dev_commands:
name: Dev Commands Unit Tests
runs-on: ubuntu-latest
name: PHP Style Check
steps:
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
- name: Install Dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
command: composer --no-interaction --no-ansi --no-progress update
- name: Run PHPCS Code Style Checker
run: dev/sh/style

docfx:
name: "Run DocFX tests"
runs-on: ubuntu-latest
env:
PHPDOC_ENV: prod
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- run: pip install --require-hashes -r .kokoro/docs/docker/requirements.txt
- name: Setup PHP
uses: shivammathur/setup-php@verbose
with:
php-version: "8.0"
- name: Extract phpDocumentor
id: extract
uses: shrink/actions-docker-extract@v2
with:
image: "phpdoc/phpdoc:202301112131087e6028"
path: "/opt/phpdoc/."
- name: Symlink phpDocumentor
run: ln -s $(pwd)/${{ steps.extract.outputs.destination }}/bin/phpdoc /usr/local/bin/phpdoc
- name: Install Dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
command: composer --no-interaction --no-ansi --no-progress update
- name: Run DocFX Unit Test Suite
run: vendor/bin/phpunit -c dev/phpunit-docfx.xml.dist
- name: Run Docs Generator (Dry Run)
run: .kokoro/docs/publish.sh
- name: "Install dependencies"
run: composer --no-interaction --no-ansi --no-progress update -d dev
- name: Run Dev Unit Test Suite
run: dev/vendor/bin/phpunit -c dev/phpunit.xml.dist
7 changes: 0 additions & 7 deletions .kokoro/continuous/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ fi
# non-secret env vars
export ASSET_TEST_BUCKET="php_asset_test_bucket"

echo "Running PHPCS Code Style Checker"
dev/sh/style

PHP_VERSION=$(php -r 'echo PHP_MAJOR_VERSION;')
if [ "5" == $PHP_VERSION ]; then
# Exclude compute if the PHP version is below 7.0
Expand All @@ -50,8 +47,4 @@ echo "Running System Test Suite"
vendor/bin/phpunit -d memory_limit=512M -c phpunit${PHPUNIT_SUFFIX}-system.xml.dist \
--verbose --log-junit ${SYSTEM_LOG_FILENAME}

echo "Running package integration Test"

dev/google-cloud integration -u

popd
6 changes: 3 additions & 3 deletions .kokoro/docs/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
PROJECT_DIR=$(dirname $(dirname $SCRIPT_DIR))

# Run "composer install" if it hasn't been run yet
if [ ! -d 'vendor/' ]; then
composer install -d $PROJECT_DIR
if [ ! -d 'dev/vendor/' ]; then
composer install -d $PROJECT_DIR/dev
fi

if [ "$STAGING_BUCKET" != "" ]; then
echo "Using staging bucket ${STAGING_BUCKET}..."
fi

find $PROJECT_DIR/* -mindepth 1 -maxdepth 1 -name 'composer.json' -not -path '*vendor/*' -exec dirname {} \; | while read DIR
find $PROJECT_DIR/* -mindepth 1 -maxdepth 1 -name 'composer.json' -not -path '*vendor/*' -regex '[A-Z].*' -exec dirname {} \; | while read DIR
do
COMPONENT=$(basename $DIR)
VERSION=$(cat $DIR/VERSION)
Expand Down
2 changes: 1 addition & 1 deletion AdvisoryNotifications/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"component": {
"id": "cloud-advisorynotifications",
"path": "AdvisoryNotifications",
"target": "https://github.com/googleapis/google-cloud-php-advisorynotifications"
"target": "googleapis/google-cloud-php-advisorynotifications"
}
},
"require": {
Expand Down
68 changes: 0 additions & 68 deletions CommonProtos/dev/regenerate.sh

This file was deleted.

14 changes: 1 addition & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,12 @@
"phpunit/phpunit": "^4.8|^5.0|^8.0",
"yoast/phpunit-polyfills": "^1.0",
"phpspec/prophecy": "^1.10.3",
"squizlabs/php_codesniffer": "3.*",
"phpdocumentor/reflection": "^3.0||^4.0||^5.0",
"symfony/console": "^3.0",
"erusev/parsedown": "^1.6",
"vierbergenlars/php-semver": "^3.0",
"phpseclib/phpseclib": "^2.0||^3.0",
"google/cloud-tools": "^0.13.0",
"opis/closure": "^3.0",
"swaggest/json-schema": "^0.12.0",
"rg/avro-php": "^1.8.0||^2.0.1||^3.0.0",
"symfony/yaml": "^3.3||^6.0"
"rg/avro-php": "^1.8.0||^2.0.1||^3.0.0"
},
"conflict": {
"psr/log": ">=3"
Expand Down Expand Up @@ -568,7 +563,6 @@
"Google\\Cloud\\DataCatalog\\Lineage\\Tests\\": "DataCatalogLineage/tests",
"Google\\Cloud\\Datastore\\Tests\\": "Datastore/tests",
"Google\\Cloud\\Debugger\\Tests\\": "Debugger/tests",
"Google\\Cloud\\Dev\\": "dev/src",
"Google\\Cloud\\ErrorReporting\\Tests\\": "ErrorReporting/tests",
"Google\\Cloud\\Firestore\\Tests\\": "Firestore/tests",
"Google\\Cloud\\Language\\Tests\\": "Language/tests",
Expand Down Expand Up @@ -596,12 +590,6 @@
"PubSub/tests/System/testdata/generated/StateProto.php"
]
},
"scripts": {
"google-cloud": "dev/google-cloud",
"style": "dev/sh/style",
"style-fix": "dev/sh/style-fix",
"tests": "dev/sh/tests"
},
"bin": [
"Core/bin/google-cloud-batch",
"Debugger/bin/google-cloud-debugger"
Expand Down
35 changes: 35 additions & 0 deletions dev/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"type": "library",
"description": "Development commands for the google/cloud library",
"require": {
"vierbergenlars/php-semver": "^3.0",
"symfony/console": " ^3.0",
"symfony/yaml": " ^3.3||^6.0",
"symfony/process": "^6.0",
"google/cloud": "dev-parent",
"symfony/filesystem": "^6.0",
"twig/twig": "^3.5"
},
"autoload": {
"psr-4": {
"Google\\Cloud\\Dev\\": "src"
}
},
"require-dev": {
"phpspec/prophecy": "^1.17",
"phpunit/phpunit": "4.8|^5.0|^8.0",
"swaggest/json-schema": "^0.12.0",
"yoast/phpunit-polyfills": "^1.0"
},
"repositories": {
"google-cloud": {
"type": "path",
"url": "../",
"options": {
"versions": {
"google/cloud": "dev-parent"
}
}
}
}
}
29 changes: 11 additions & 18 deletions dev/google-cloud
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@
* limitations under the License.
*/

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

use Google\Cloud\Dev\AddComponent\Command\AddComponent;
use Google\Cloud\Dev\ComponentIntegration\Command\ComponentIntegration;
use Google\Cloud\Dev\ComponentManager;
use Google\Cloud\Dev\Credentials\Command as Credentials;
use Google\Cloud\Dev\DocFx\Command\DocFx;
use Google\Cloud\Dev\Release\Release;
use Google\Cloud\Dev\ReleaseBuilder\ReleaseBuilder;
use Google\Cloud\Dev\Split\Command as Split;
use Google\Cloud\Dev\Command\AddComponentCommand;
use Google\Cloud\Dev\Command\DocFxCommand;
use Google\Cloud\Dev\Command\ComponentInfoCommand;
use Google\Cloud\Dev\Command\ReleaseCommand;
use Google\Cloud\Dev\Command\SplitCommand;
use Symfony\Component\Console\Application;

if (!class_exists(Application::class)) {
Expand All @@ -38,14 +35,10 @@ if (!class_exists(Application::class)) {

$rootDirectory = realpath(__DIR__ . '/../') . '/';

$componentManager = new ComponentManager($rootDirectory);

$app = new Application;
$app->add(new AddComponent($rootDirectory));
$app->add(new ComponentIntegration($rootDirectory));
$app->add(new Credentials($rootDirectory));
$app->add(new DocFX($rootDirectory));
$app->add(new Release($rootDirectory));
$app->add(new ReleaseBuilder($rootDirectory));
$app->add(new Split($rootDirectory, $componentManager));
$app->add(new AddComponentCommand($rootDirectory));
$app->add(new DocFxCommand());
$app->add(new ComponentInfoCommand());
$app->add(new ReleaseCommand($rootDirectory));
$app->add(new SplitCommand($rootDirectory));
$app->run();
2 changes: 2 additions & 0 deletions dev/phpunit-docfx.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<testsuites>
<testsuite name="DocFX Test Suite">
<directory>./tests/Unit/DocFx</directory>
<directory>./tests/Unit/Command/DocFxCommandTest.php</directory>
</testsuite>
</testsuites>
</phpunit>

18 changes: 18 additions & 0 deletions dev/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true">
<testsuites>
<testsuite name="Dev Unit Test Suite">
<directory>tests/Unit</directory>
<exclude>tests/Unit/DocFx/</exclude>
<exclude>tests/Unit/Command/DocFxCommandTest.php</exclude>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src</directory>
<exclude>
<directory suffix=".php">src/V[!a-zA-Z]*</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
5 changes: 0 additions & 5 deletions dev/sh/style

This file was deleted.

Loading

0 comments on commit 343d5ac

Please sign in to comment.