From 22574cadd1eaffa62c8c72940016192d8b5b097d Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Fri, 20 Sep 2024 15:30:00 -0700 Subject: [PATCH] feat(ci): organize workflows, add system tests --- ...> emulator-conformance-tests-storage.yaml} | 4 +- ...ml => emulator-system-tests-bigtable.yaml} | 4 +- ...l => emulator-system-tests-datastore.yaml} | 4 +- ...l => emulator-system-tests-firestore.yaml} | 4 +- ...yaml => emulator-system-tests-pubsub.yaml} | 4 +- ...aml => emulator-system-tests-spanner.yaml} | 4 +- .../incorrect-conventional-commit-check.yaml | 34 -------- ...ibility-check.yaml => owl-bot-checks.yaml} | 55 ++++++------- .github/workflows/release-checks.yaml | 80 +++++++++++++++++++ .kokoro/continuous/php81.cfg | 59 -------------- .kokoro/continuous/run-tests.sh | 50 ------------ phpunit-system.xml.dist | 7 -- 12 files changed, 116 insertions(+), 193 deletions(-) rename .github/workflows/{storage-emulator-retry-conformance-tests.yaml => emulator-conformance-tests-storage.yaml} (85%) rename .github/workflows/{bigtable-emulator-system-tests.yaml => emulator-system-tests-bigtable.yaml} (90%) rename .github/workflows/{datastore-emulator-system-tests.yaml => emulator-system-tests-datastore.yaml} (90%) rename .github/workflows/{firestore-emulator-system-tests.yaml => emulator-system-tests-firestore.yaml} (90%) rename .github/workflows/{pubsub-emulator-system-tests.yaml => emulator-system-tests-pubsub.yaml} (90%) rename .github/workflows/{spanner-emulator-system-tests.yaml => emulator-system-tests-spanner.yaml} (93%) delete mode 100644 .github/workflows/incorrect-conventional-commit-check.yaml rename .github/workflows/{backwards-compatibility-check.yaml => owl-bot-checks.yaml} (58%) create mode 100644 .github/workflows/release-checks.yaml delete mode 100644 .kokoro/continuous/php81.cfg delete mode 100755 .kokoro/continuous/run-tests.sh diff --git a/.github/workflows/storage-emulator-retry-conformance-tests.yaml b/.github/workflows/emulator-conformance-tests-storage.yaml similarity index 85% rename from .github/workflows/storage-emulator-retry-conformance-tests.yaml rename to .github/workflows/emulator-conformance-tests-storage.yaml index 9385fd7ca7a1..fe5d0d6fb59f 100644 --- a/.github/workflows/storage-emulator-retry-conformance-tests.yaml +++ b/.github/workflows/emulator-conformance-tests-storage.yaml @@ -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: diff --git a/.github/workflows/bigtable-emulator-system-tests.yaml b/.github/workflows/emulator-system-tests-bigtable.yaml similarity index 90% rename from .github/workflows/bigtable-emulator-system-tests.yaml rename to .github/workflows/emulator-system-tests-bigtable.yaml index b06fc5c52ce7..ed0e1d3ec85a 100644 --- a/.github/workflows/bigtable-emulator-system-tests.yaml +++ b/.github/workflows/emulator-system-tests-bigtable.yaml @@ -4,12 +4,12 @@ on: - main paths: - 'Bigtable/**' - - '.github/workflows/bigtable-emulator-system-tests.yaml' + - '.github/workflows/emulator-system-tests-bigtable.yaml' - '.github/emulator/**' pull_request: paths: - 'Bigtable/**' - - '.github/workflows/bigtable-emulator-system-tests.yaml' + - '.github/workflows/emulator-system-tests-bigtable.yaml' - '.github/emulator/**' name: Run Bigtable System Tests With Emulator permissions: diff --git a/.github/workflows/datastore-emulator-system-tests.yaml b/.github/workflows/emulator-system-tests-datastore.yaml similarity index 90% rename from .github/workflows/datastore-emulator-system-tests.yaml rename to .github/workflows/emulator-system-tests-datastore.yaml index 583c22aa68d3..4fc1c6f23a48 100644 --- a/.github/workflows/datastore-emulator-system-tests.yaml +++ b/.github/workflows/emulator-system-tests-datastore.yaml @@ -5,12 +5,12 @@ on: - main paths: - 'Datastore/**' - - '.github/workflows/datastore-emulator-system-tests.yaml' + - '.github/workflows/emulator-system-tests-datastore.yaml' - '.github/emulator/**' pull_request: paths: - 'Datastore/**' - - '.github/workflows/datastore-emulator-system-tests.yaml' + - '.github/workflows/emulator-system-tests-datastore.yaml' - '.github/emulator/**' permissions: contents: read diff --git a/.github/workflows/firestore-emulator-system-tests.yaml b/.github/workflows/emulator-system-tests-firestore.yaml similarity index 90% rename from .github/workflows/firestore-emulator-system-tests.yaml rename to .github/workflows/emulator-system-tests-firestore.yaml index a68a42f87423..95305a657682 100644 --- a/.github/workflows/firestore-emulator-system-tests.yaml +++ b/.github/workflows/emulator-system-tests-firestore.yaml @@ -4,12 +4,12 @@ on: - main paths: - 'Firestore/**' - - '.github/workflows/firestore-emulator-system-tests.yaml' + - '.github/workflows/emulator-system-tests-firestore.yaml' - '.github/emulator/**' pull_request: paths: - 'Firestore/**' - - '.github/workflows/firestore-emulator-system-tests.yaml' + - '.github/workflows/emulator-system-tests-firestore.yaml' - '.github/emulator/**' name: Run Firestore System Tests With Emulator permissions: diff --git a/.github/workflows/pubsub-emulator-system-tests.yaml b/.github/workflows/emulator-system-tests-pubsub.yaml similarity index 90% rename from .github/workflows/pubsub-emulator-system-tests.yaml rename to .github/workflows/emulator-system-tests-pubsub.yaml index 76b2837b950f..4485f267c6dc 100644 --- a/.github/workflows/pubsub-emulator-system-tests.yaml +++ b/.github/workflows/emulator-system-tests-pubsub.yaml @@ -4,12 +4,12 @@ on: - main paths: - 'PubSub/**' - - '.github/workflows/pubsub-emulator-system-tests.yaml' + - '.github/workflows/emulator-system-tests-pubsub.yaml' - '.github/emulator/**' pull_request: paths: - 'PubSub/**' - - '.github/workflows/pubsub-emulator-system-tests.yaml' + - '.github/workflows/emulator-system-tests-pubsub.yaml' - '.github/emulator/**' name: Run PubSub System Tests With Emulator permissions: diff --git a/.github/workflows/spanner-emulator-system-tests.yaml b/.github/workflows/emulator-system-tests-spanner.yaml similarity index 93% rename from .github/workflows/spanner-emulator-system-tests.yaml rename to .github/workflows/emulator-system-tests-spanner.yaml index 224d8919fefc..d233c97dff66 100644 --- a/.github/workflows/spanner-emulator-system-tests.yaml +++ b/.github/workflows/emulator-system-tests-spanner.yaml @@ -4,11 +4,11 @@ on: - main paths: - 'Spanner/**' - - '.github/workflows/spanner-emulator-system-tests.yaml' + - '.github/workflows/emulator-system-tests-spanner.yaml' pull_request: paths: - 'Spanner/**' - - '.github/workflows/spanner-emulator-system-tests.yaml' + - '.github/workflows/emulator-system-tests-spanner.yaml' name: Run Spanner System Tests With Emulator permissions: contents: read diff --git a/.github/workflows/incorrect-conventional-commit-check.yaml b/.github/workflows/incorrect-conventional-commit-check.yaml deleted file mode 100644 index 6071e5453719..000000000000 --- a/.github/workflows/incorrect-conventional-commit-check.yaml +++ /dev/null @@ -1,34 +0,0 @@ -name: Conventional Commit Check -on: - pull_request: - types: [opened, synchronize, reopened, edited] - branches: ['main'] -jobs: - # More info at https://github.com/Roave/BackwardCompatibilityCheck. - incorrect-conventional-commit-check: - runs-on: ubuntu-latest - 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 - if: ${{ github.event.pull_request.user.login == 'gcf-owl-bot' && !startsWith(github.event.pull_request.title, 'feat')}} - 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 \ - --from=${{ github.event.pull_request.head.sha }} \ - --to=${{ github.event.pull_request.base.sha }} - - name: "Print the action item" - run: | - if [[ "${{ steps.compatibility-checker.outcome }}" == 'failure' ]]; then - echo "Action item: Change the PR label to feat" - exit 1 - fi diff --git a/.github/workflows/backwards-compatibility-check.yaml b/.github/workflows/owl-bot-checks.yaml similarity index 58% rename from .github/workflows/backwards-compatibility-check.yaml rename to .github/workflows/owl-bot-checks.yaml index 33efeab1682d..6db78e683461 100644 --- a/.github/workflows/backwards-compatibility-check.yaml +++ b/.github/workflows/owl-bot-checks.yaml @@ -1,4 +1,4 @@ -name: Backwards Compatibility Check +name: on: pull_request: types: [opened, synchronize, reopened, edited] @@ -6,6 +6,7 @@ on: jobs: # More info at https://github.com/Roave/BackwardCompatibilityCheck. backwards-compatibility-check: + name: Backwards Compatibility Check runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -46,43 +47,35 @@ jobs: --from=${{ steps.latest-release.outputs.release }} \ --to=origin/main --format=github-actions - # 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: + # Ensure that PRs labeled "feat" actually contain a new feature + conventional-commit-check: + name: Conventional Commit Check runs-on: ubuntu-latest - if: github.event.pull_request.user.login == 'release-please[bot]' steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Parse allowed major versions - uses: actions-ecosystem/action-regex-match@v2 - id: allowed-major-versions + - name: "Install PHP" + uses: shivammathur/setup-php@v2 with: - text: ${{ github.event.pull_request.body }} - regex: '^MAJOR_VERSION_ALLOWED=(.*)$' - flags: gm - - name: "Check for unexpected major version" + 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 + if: ${{ github.event.pull_request.user.login == 'gcf-owl-bot[bot]' }} + 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: | - # parse allowed major versions into an array - IFS=', ' read -r -a ALLOWED_MAJOR_VERSIONS <<< "${{ steps.allowed-major-versions.outputs.group1 }}" - # get all changed components - COMPONENTS=$(git diff origin/main --name-only | grep VERSION | xargs dirname) - FAIL="" - for COMPONENT in ${COMPONENTS}; do { - if [[ "$(cat $COMPONENT/VERSION)" == [123456789].0.0 ]]; then - # A new version is being released - make sure it's allowed - if [[ ${ALLOWED_MAJOR_VERSIONS[@]} =~ $COMPONENT ]]; then - echo "Major version release allowed: $COMPONENT" - else - echo "Unexpected major version release found: $COMPONENT" - FAIL="true" - fi + if [[ "${{ steps.compatibility-checker.outcome }}" == 'failure' ]]; then + if [[ "${{ !startsWith(github.event.pull_request.title, 'feat') }}" ]]; then + echo "Action item: Change the conventional commit to use 'feat'" + exit 1 fi - }; done - if [[ "$FAIL" == "true" ]]; then - echo "Add \"MAJOR_VERSION_ALLOWED=component1,component2\" to the PR description to allow " - echo "major version releases for those components" + elif [[ "${{ !startsWith(github.event.pull_request.title, 'feat') }}" ]]; then + echo "Action item: No features found, do not use 'feat' for the conventional commit" exit 1 fi diff --git a/.github/workflows/release-checks.yaml b/.github/workflows/release-checks.yaml new file mode 100644 index 000000000000..dc8978912949 --- /dev/null +++ b/.github/workflows/release-checks.yaml @@ -0,0 +1,80 @@ +name: +on: + pull_request: + types: [opened, synchronize, reopened, edited] + branches: ['main'] +jobs: + # Run system tests on the release PR + system-tests: + runs-on: ubuntu-latest + if: github.event_name == 'push' + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup PHP + uses: shivammathur/setup-php@verbose + with: + php-version: "8.1" + - name: Install dependencies and define env vars + run: composer --no-interaction --no-ansi --no-progress update + env: + GOOGLE_CLOUD_PHP_TESTS_KEY_PATH: "${{ runner.temp }}/service-account.json" + GOOGLE_CLOUD_PHP_WHITELIST_TESTS_KEY_PATH: "${{ runner.temp }}/service-account.whitelist.json" + GOOGLE_CLOUD_PHP_FIRESTORE_TESTS_KEY_PATH: "${{ runner.temp }}/service-account.firestore.json" + ASSET_TEST_BUCKET: php_asset_test_bucket + - uses: mobiledevops/secret-to-file-action@v1 + with: + base64-encoded-secret: ${{ secrets.GOOGLE_CLOUD_PHP_TESTS_KEY }} + filename: ${{ env.GOOGLE_CLOUD_PHP_TESTS_KEY_PATH }} + - uses: mobiledevops/secret-to-file-action@v1 + with: + base64-encoded-secret: ${{ secrets.GOOGLE_CLOUD_PHP_WHITELIST_TESTS_KEY }} + filename: ${{ env.GOOGLE_CLOUD_PHP_WHITELIST_TESTS_KEY_PATH }} + - uses: mobiledevops/secret-to-file-action@v1 + with: + base64-encoded-secret: ${{ secrets.GOOGLE_CLOUD_PHP_FIRESTORE_TESTS_KEY }} + filename: ${{ env.GOOGLE_CLOUD_PHP_FIRESTORE_TESTS_KEY_PATH }} + - name: Run System Tests + run: vendor/bin/phpunit -d memory_limit=512M -c phpunit-system.xml.dist --verbose + + # 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: + runs-on: ubuntu-latest + if: github.event.pull_request.user.login == 'release-please[bot]' + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Parse allowed major versions + uses: actions-ecosystem/action-regex-match@v2 + id: allowed-major-versions + with: + text: ${{ github.event.pull_request.body }} + regex: '^MAJOR_VERSION_ALLOWED=(.*)$' + flags: gm + - name: "Check for unexpected major version" + run: | + # parse allowed major versions into an array + IFS=', ' read -r -a ALLOWED_MAJOR_VERSIONS <<< "${{ steps.allowed-major-versions.outputs.group1 }}" + # get all changed components + COMPONENTS=$(git diff origin/main --name-only | grep VERSION | xargs dirname) + FAIL="" + for COMPONENT in ${COMPONENTS}; do { + if [[ "$(cat $COMPONENT/VERSION)" == [123456789].0.0 ]]; then + # A new version is being released - make sure it's allowed + if [[ ${ALLOWED_MAJOR_VERSIONS[@]} =~ $COMPONENT ]]; then + echo "Major version release allowed: $COMPONENT" + else + echo "Unexpected major version release found: $COMPONENT" + FAIL="true" + fi + fi + }; done + if [[ "$FAIL" == "true" ]]; then + echo "Add \"MAJOR_VERSION_ALLOWED=component1,component2\" to the PR description to allow " + echo "major version releases for those components" + exit 1 + fi diff --git a/.kokoro/continuous/php81.cfg b/.kokoro/continuous/php81.cfg deleted file mode 100644 index e1e6f7e4f098..000000000000 --- a/.kokoro/continuous/php81.cfg +++ /dev/null @@ -1,59 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Download trampoline resources. These will be in ${KOKORO_GFILE_DIR} -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# All builds use the trampoline script to run in docker. -build_file: "google-cloud-php/.kokoro/trampoline.sh" - -# Configure the build command -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/google-cloud-php/.kokoro/continuous/run-tests.sh" -} - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/php81" -} - -# key files from keystore -env_vars: { - key: "GOOGLE_CLOUD_PHP_TESTS_KEY_PATH" - value: "71386_google-cloud-php-system-test-service-account" -} - -env_vars: { - key: "GOOGLE_CLOUD_PHP_FIRESTORE_TESTS_KEY_PATH" - value: "71386_google-cloud-php-system-test-firestore-service-account" -} - -env_vars: { - key: "GOOGLE_CLOUD_PHP_WHITELIST_TESTS_KEY_PATH" - value: "71386_google-cloud-php-system-test-whitelist-service-account" -} - -action { - define_artifacts { - regex: "**/*sponge_log.xml" - } -} - -# Fetch keystore keys -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 71386 - keyname: "google-cloud-php-system-test-service-account" - } - keystore_resource { - keystore_config_id: 71386 - keyname: "google-cloud-php-system-test-whitelist-service-account" - } - keystore_resource { - keystore_config_id: 71386 - keyname: "google-cloud-php-system-test-firestore-service-account" - } - } -} diff --git a/.kokoro/continuous/run-tests.sh b/.kokoro/continuous/run-tests.sh deleted file mode 100755 index 354254ce987e..000000000000 --- a/.kokoro/continuous/run-tests.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -set -ex - -pushd github/google-cloud-php -composer --no-interaction --no-ansi --no-progress update - -SHORT_JOB_NAME=${KOKORO_JOB_NAME##*/} - -mkdir -p ${SHORT_JOB_NAME}/unit -mkdir -p ${SHORT_JOB_NAME}/snippets -mkdir -p ${SHORT_JOB_NAME}/system - -UNIT_LOG_FILENAME=${SHORT_JOB_NAME}/unit/sponge_log.xml -SNIPPETS_LOG_FILENAME=${SHORT_JOB_NAME}/snippets/sponge_log.xml -SYSTEM_LOG_FILENAME=${SHORT_JOB_NAME}/system/sponge_log.xml - -if [ ! -z "${GOOGLE_CLOUD_PHP_TESTS_KEY_PATH}" ]; then - export GOOGLE_CLOUD_PHP_TESTS_KEY_PATH="${KOKORO_KEYSTORE_DIR}/${GOOGLE_CLOUD_PHP_TESTS_KEY_PATH}" -fi - -if [ ! -z "${GOOGLE_CLOUD_PHP_WHITELIST_TESTS_KEY_PATH}" ]; then - export GOOGLE_CLOUD_PHP_WHITELIST_TESTS_KEY_PATH="${KOKORO_KEYSTORE_DIR}/${GOOGLE_CLOUD_PHP_WHITELIST_TESTS_KEY_PATH}" -fi - -if [ ! -z "${GOOGLE_CLOUD_PHP_FIRESTORE_TESTS_KEY_PATH}" ]; then - export GOOGLE_CLOUD_PHP_FIRESTORE_TESTS_KEY_PATH="${KOKORO_KEYSTORE_DIR}/${GOOGLE_CLOUD_PHP_FIRESTORE_TESTS_KEY_PATH}" -fi - -# non-secret env vars -export ASSET_TEST_BUCKET="php_asset_test_bucket" - -PHP_VERSION=$(php -r 'echo PHP_MAJOR_VERSION;') -if [ "5" == $PHP_VERSION ]; then - # Exclude compute if the PHP version is below 7.0 - PHPUNIT_SUFFIX="-php5" -fi - -echo "Running Unit Test Suite" -vendor/bin/phpunit -c phpunit${PHPUNIT_SUFFIX}.xml.dist --log-junit ${UNIT_LOG_FILENAME} - -echo "Running Snippet Test Suite" -vendor/bin/phpunit -c phpunit-snippets.xml.dist --verbose --log-junit \ - ${SNIPPETS_LOG_FILENAME} - -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} - -popd diff --git a/phpunit-system.xml.dist b/phpunit-system.xml.dist index 2297e85ede70..1ddb3fca1446 100644 --- a/phpunit-system.xml.dist +++ b/phpunit-system.xml.dist @@ -5,13 +5,6 @@ */src src - - */src/V[!a-zA-Z]* - */src/*/V[!a-zA-Z]* - */src/*/*/V[!a-zA-Z]* - Core/src/Testing - dev -