Skip to content

Commit

Permalink
feat(ci): organize workflows, add system tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer committed Sep 20, 2024
1 parent 21a154b commit 22574ca
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 193 deletions.
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
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/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:
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/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
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/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:
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/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:
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/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
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
@@ -1,11 +1,12 @@
name: Backwards Compatibility Check
name:
on:
pull_request:
types: [opened, synchronize, reopened, edited]
branches: ['main']
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
Expand Down Expand Up @@ -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
80 changes: 80 additions & 0 deletions .github/workflows/release-checks.yaml
Original file line number Diff line number Diff line change
@@ -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
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.

Loading

0 comments on commit 22574ca

Please sign in to comment.