Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tests): organize workflows, add system tests #7695

Merged
merged 14 commits into from
Sep 27, 2024
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: Backwards Compatibility Check
name: Backwards Compatibility
on:
pull_request:
types: [opened, synchronize, reopened, edited]
branches: ['main']
jobs:
# More info at https://github.com/Roave/BackwardCompatibilityCheck.
backwards-compatibility-check:
name: Breaking Change Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -46,10 +47,45 @@ jobs:
--from=${{ steps.latest-release.outputs.release }} \
--to=origin/main --format=github-actions

# Ensure that PRs labeled "feat" actually contain a new feature, PRs labeled
# "bug" or "chore" do not.
conventional-commit-check:
name: Conventional Commit Check
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'gcf-owl-bot[bot]'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Install PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
- name: "Install dependencies"
run: composer global require "roave/backward-compatibility-check:^8.2"
- name: "Check for an incorrect feat label in the PR"
id: compatibility-checker
continue-on-error: true
# OwlBot PRs which are not labelled feat should not add new files or methods
run: |
~/.composer/vendor/bin/roave-backward-compatibility-check --to=origin/main --format=github-actions
- name: "Print the action item"
run: |
if [[ "${{ steps.compatibility-checker.outcome }}" == 'failure' ]]; then
if [[ "${{ startsWith(github.event.pull_request.title, 'feat') }}" == "true" ]]; then
echo "Action item: Change the conventional commit to use 'feat'"
exit 1
fi
elif [[ "${{ startsWith(github.event.pull_request.title, 'feat') }}" == "false" ]]; then
echo "Action item: No features found, do not use 'feat' for the conventional commit"
exit 1
fi

# Ensure the release PR does not contain an unexpected (e.g. 2.0.0) major version release
# Add "MAJOR_VERSION_ALLOWED=component1,component2" to the PR description to allow major version
# releases for those components
unexpected-major-version-check:
name: Unexpected Major Version Check
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'release-please[bot]'
steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on:
- main
paths:
- 'Storage/**'
- '.github/workflows/storage-emulator-retry-conformance-tests.yaml'
- '.github/workflows/emulator-conformance-tests-storage.yaml'
pull_request:
paths:
- 'Storage/**'
- '.github/workflows/storage-emulator-retry-conformance-tests.yaml'
- '.github/workflows/emulator-conformance-tests-storage.yaml'
name: Run Storage Retry Conformance Tests With Emulator
jobs:
test:
Expand Down
34 changes: 0 additions & 34 deletions .github/workflows/incorrect-conventional-commit-check.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ on:
- main
paths:
- 'Bigtable/**'
- '.github/workflows/bigtable-emulator-system-tests.yaml'
- '.github/workflows/system-tests-bigtable-emulator.yaml'
- '.github/emulator/**'
pull_request:
paths:
- 'Bigtable/**'
- '.github/workflows/bigtable-emulator-system-tests.yaml'
- '.github/workflows/system-tests-bigtable-emulator.yaml'
- '.github/emulator/**'
name: Run Bigtable System Tests With Emulator
permissions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ on:
- main
paths:
- 'Datastore/**'
- '.github/workflows/datastore-emulator-system-tests.yaml'
- '.github/workflows/system-tests-datastore-emulator.yaml'
- '.github/emulator/**'
pull_request:
paths:
- 'Datastore/**'
- '.github/workflows/datastore-emulator-system-tests.yaml'
- '.github/workflows/system-tests-datastore-emulator.yaml'
- '.github/emulator/**'
permissions:
contents: read
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ on:
- main
paths:
- 'Firestore/**'
- '.github/workflows/firestore-emulator-system-tests.yaml'
- '.github/workflows/system-tests-firestore-emulator.yaml'
- '.github/emulator/**'
pull_request:
paths:
- 'Firestore/**'
- '.github/workflows/firestore-emulator-system-tests.yaml'
- '.github/workflows/system-tests-firestore-emulator.yaml'
- '.github/emulator/**'
name: Run Firestore System Tests With Emulator
permissions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ on:
- main
paths:
- 'PubSub/**'
- '.github/workflows/pubsub-emulator-system-tests.yaml'
- '.github/workflows/system-tests-pubsub-emulator.yaml'
- '.github/emulator/**'
pull_request:
paths:
- 'PubSub/**'
- '.github/workflows/pubsub-emulator-system-tests.yaml'
- '.github/workflows/system-tests-pubsub-emulator.yaml'
- '.github/emulator/**'
name: Run PubSub System Tests With Emulator
permissions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on:
- main
paths:
- 'Spanner/**'
- '.github/workflows/spanner-emulator-system-tests.yaml'
- '.github/workflows/system-tests-spanner-emulator.yaml'
pull_request:
paths:
- 'Spanner/**'
- '.github/workflows/spanner-emulator-system-tests.yaml'
- '.github/workflows/system-tests-spanner-emulator.yaml'
name: Run Spanner System Tests With Emulator
permissions:
contents: read
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/system-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: System Tests
on:
pull_request:
workflow_dispatch:
jobs:
# Run system tests on the release PR
system-tests:
name: Run System Test Suite
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'release-please[bot]' || github.event_name == 'workflow_dispatch'
env:
ASSET_TEST_BUCKET: cloud-php-testdata
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@verbose
with:
php-version: "8.1"
extensions: grpc
ini-values: grpc.grpc_verbosity=error
- name: Save secrets to file
run: |
echo "${{ secrets.GOOGLE_CLOUD_PHP_TESTS_KEY }}" | base64 -d > ${{ runner.temp }}/service-account.json
- name: Install dependencies
run: composer --no-interaction --no-ansi --no-progress update
- name: Run System Tests
run: vendor/bin/phpunit -c phpunit-system.xml.dist --colors=always --exclude-group=flakey
env:
GOOGLE_CLOUD_PHP_TESTS_KEY_PATH: ${{ runner.temp }}/service-account.json
File renamed without changes.
59 changes: 0 additions & 59 deletions .kokoro/continuous/php81.cfg

This file was deleted.

50 changes: 0 additions & 50 deletions .kokoro/continuous/run-tests.sh

This file was deleted.

21 changes: 5 additions & 16 deletions Asset/tests/System/V1/AssetServiceSmokeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
*/
namespace Google\Cloud\Asset\Tests\System\V1;

use Google\Cloud\Asset\V1\AssetServiceClient;
use Google\Cloud\Asset\V1\GcsDestination;
use Google\Cloud\Asset\V1\OutputConfig;
use Google\Cloud\Asset\V1\Asset;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\ListAssetsRequest;
use Google\Cloud\Core\Testing\System\SystemTestCase;

/**
Expand All @@ -36,20 +36,9 @@ public function smokeTest()
if ($projectId === false) {
$this->fail('Environment variable PROJECT_ID must be set for smoke test');
}
$bucket = getenv('ASSET_TEST_BUCKET');
if ($bucket === false) {
$this->fail('Environment variable ASSET_TEST_BUCKET must be set for smoke test');
}
$client = new AssetServiceClient();
$objectPath = "gs://$bucket/cai-system-test";
$gcsDestination = new GcsDestination(['uri' => $objectPath]);
$outputConfig = new OutputConfig([
'gcs_destination' => $gcsDestination
]);

$resp = $client->exportAssets("projects/$projectId", $outputConfig);
$resp->pollUntilComplete();

$this->assertTrue($resp->operationSucceeded());
$response = $client->listAssets(ListAssetsRequest::build('projects/' . $projectId));
$this->assertInstanceOf(Asset::class, $response->getIterator()->current());
}
}
7 changes: 5 additions & 2 deletions BigQuery/tests/System/BigQueryTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use Google\Cloud\Storage\StorageClient;
use Google\Cloud\Core\Testing\System\SystemTestCase;

class BigQueryTestCase extends SystemTestCase
abstract class BigQueryTestCase extends SystemTestCase
{
const TESTING_PREFIX = 'gcloud_testing_';
const ENCRYPTION_SERVICE_ACCOUNT_EMAIL_TEMPLATE = 'bq-%[email protected]';
Expand All @@ -35,7 +35,10 @@ class BigQueryTestCase extends SystemTestCase
protected static $table;
private static $hasSetUp = false;

public static function setUpBeforeClass(): void
/**
* @beforeClass
*/
public static function setUpTestFixtures(): void
{
if (self::$hasSetUp) {
return;
Expand Down
7 changes: 5 additions & 2 deletions BigQuery/tests/System/ManageModelsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ class ManageModelsTest extends BigQueryTestCase
private static $keyName1;
private static $keyName2;

public static function setUpBeforeClass(): void
/**
* @beforeClass
*/
public static function setUpTestFixtures(): void
{
parent::setUpBeforeClass();
parent::setUpTestFixtures();

self::$modelId = uniqid(self::TESTING_PREFIX);

Expand Down
Loading
Loading