From ec408ba70d27ce043bfa8cf35602c7fae673c696 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Fri, 20 Sep 2024 15:44:25 -0700 Subject: [PATCH] a little more shuffling --- .../backwards-compatibility-checks.yaml | 44 +++++++++- .github/workflows/release-checks.yaml | 80 ------------------- .github/workflows/system-tests.yaml | 38 +++++++++ 3 files changed, 81 insertions(+), 81 deletions(-) delete mode 100644 .github/workflows/release-checks.yaml create mode 100644 .github/workflows/system-tests.yaml diff --git a/.github/workflows/backwards-compatibility-checks.yaml b/.github/workflows/backwards-compatibility-checks.yaml index c7b82f50a93c..28c1520167ac 100644 --- a/.github/workflows/backwards-compatibility-checks.yaml +++ b/.github/workflows/backwards-compatibility-checks.yaml @@ -51,6 +51,7 @@ jobs: 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: @@ -63,7 +64,6 @@ jobs: 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: | @@ -79,3 +79,45 @@ jobs: 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: + - 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 \ No newline at end of file diff --git a/.github/workflows/release-checks.yaml b/.github/workflows/release-checks.yaml deleted file mode 100644 index 989066e1ec8c..000000000000 --- a/.github/workflows/release-checks.yaml +++ /dev/null @@ -1,80 +0,0 @@ -name: Release Checks -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/.github/workflows/system-tests.yaml b/.github/workflows/system-tests.yaml new file mode 100644 index 000000000000..d2151e6f0c39 --- /dev/null +++ b/.github/workflows/system-tests.yaml @@ -0,0 +1,38 @@ +name: System Tests +on: + pull_request: +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]' + 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