Skip to content

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

feat(tests): organize workflows, add system tests

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

Workflow file for this run

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