Skip to content
Open
186 changes: 186 additions & 0 deletions .github/workflows/spanner-targeted-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Spanner Targeted Release

on:
push:
branches:
- targeted-release
workflow_dispatch:
inputs:
projectId:
description: 'Target GCP Project ID'
type: string
required: true
default: 'span-cloud-migrations-staging'
bucketName:
description: 'Target GCS Bucket Name'
type: string
required: true
default: 'spanner-migrations-staging'
stagePrefix:
description: 'Prefix for staging the template (e.g., templates-2025-10-31). If blank, defaults to templates-YYYY-MM-DD using current date.'
type: string
required: false
default: ''
templateName:
description: 'Template Name to build and stage'
type: string
required: true
default: 'Spanner_to_SourceDb'
modulePath:
description: 'Maven module directory of the template to build'
type: string
required: true
default: 'v2/spanner-to-sourcedb'
runnerLabels:
description: 'Runner labels formatted as a JSON array'
type: string
required: true
default: '["self-hosted", "spanner-release"]'
runIntegrationTests:
description: 'Run Spanner integration tests before staging templates'
type: boolean
required: true
default: true
specific_test:
description: 'Specific Integration Test (passed to -Dtest=)'
type: string
required: false
default: ''

env:
MAVEN_OPTS: >-
-Dorg.slf4j.simpleLogger.log.org.apache.maven.plugins.shade=error
--add-opens java.base/java.nio=ALL-UNNAMED
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED

permissions:
contents: read

jobs:
targeted_release:
name: Targeted Template Release
runs-on: ${{ fromJSON(github.event.inputs.runnerLabels || '["self-hosted", "spanner-release"]') }}
steps:
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Setup Environment
id: setup-env
uses: ./.github/actions/setup-env

- name: Resolve Variables
id: resolve-vars
run: |
PROJECT_ID="${{ github.event.inputs.projectId }}"
PROJECT_ID="${PROJECT_ID:-span-cloud-migrations-staging}"

BUCKET_NAME="${{ github.event.inputs.bucketName }}"
BUCKET_NAME="${BUCKET_NAME:-spanner-migrations-staging}"

TEMPLATE_NAME="${{ github.event.inputs.templateName }}"
TEMPLATE_NAME="${TEMPLATE_NAME:-Spanner_to_SourceDb}"

MODULE_PATH="${{ github.event.inputs.modulePath }}"
MODULE_PATH="${MODULE_PATH:-v2/spanner-to-sourcedb}"

STAGE_PREFIX="${{ github.event.inputs.stagePrefix }}"
if [ -z "$STAGE_PREFIX" ]; then
STAGE_PREFIX="templates-$(date +'%Y-%m-%d')"
fi

RUN_INTEGRATION_TESTS="${{ github.event.inputs.runIntegrationTests }}"
RUN_INTEGRATION_TESTS="${RUN_INTEGRATION_TESTS:-true}"

SPECIFIC_TEST="${{ github.event.inputs.specific_test }}"
SPECIFIC_TEST="${SPECIFIC_TEST:-}"

echo "Resolved Variables:"
echo "-------------------"
echo "Project ID: $PROJECT_ID"
echo "Bucket Name: $BUCKET_NAME"
echo "Template Name: $TEMPLATE_NAME"
echo "Module Path: $MODULE_PATH"
echo "Stage Prefix: $STAGE_PREFIX"
echo "Run IT Tests: $RUN_INTEGRATION_TESTS"
echo "Specific Test: $SPECIFIC_TEST"
echo "-------------------"

echo "projectId=$PROJECT_ID" >> $GITHUB_OUTPUT
echo "bucketName=$BUCKET_NAME" >> $GITHUB_OUTPUT
echo "templateName=$TEMPLATE_NAME" >> $GITHUB_OUTPUT
echo "modulePath=$MODULE_PATH" >> $GITHUB_OUTPUT
echo "stagePrefix=$STAGE_PREFIX" >> $GITHUB_OUTPUT
echo "runIntegrationTests=$RUN_INTEGRATION_TESTS" >> $GITHUB_OUTPUT
echo "specificTest=$SPECIFIC_TEST" >> $GITHUB_OUTPUT
shell: bash

- name: Run Integration Tests
if: ${{ steps.resolve-vars.outputs.runIntegrationTests == 'true' }}
run: |
echo "Starting Spanner Integration Tests..."
./cicd/run-it-tests \
--modules-to-build="SPANNER" \
--it-region="us-central1" \
--it-project="span-cloud-teleport-testing" \
--it-artifact-bucket="span-cloud-teleport-testing-it-gitactions" \
--it-private-connectivity="datastream-connect-2" \
--it-cloud-proxy-host="10.128.0.16" \
--test="${{ steps.resolve-vars.outputs.specificTest }}"

- name: Upload Integration Tests Report
if: always() && (steps.resolve-vars.outputs.runIntegrationTests == 'true')
uses: actions/upload-artifact@v7
with:
name: surefire-integration-test-results
path: |
**/surefire-reports/TEST-*.xml
**/surefire-reports/*.html
**/surefire-reports/html/**
retention-days: 10

- name: Integration Test report on GitHub
if: always() && (steps.resolve-vars.outputs.runIntegrationTests == 'true')
uses: dorny/test-reporter@v3
with:
name: Integration Test report on GitHub
path: '**/surefire-reports/TEST-*.xml'
reporter: java-junit
only-summary: 'true'
token: ${{ secrets.GITHUB_TOKEN }}
fail-on-error: 'false'
list-suites: 'failed'
list-tests: 'failed'

- name: Build & Stage Template
run: |
Comment thread
sm745052 marked this conversation as resolved.
echo "Starting Spanner Targeted Release staging..."

mvn clean package -PtemplatesStage \
-DprojectId="${{ steps.resolve-vars.outputs.projectId }}" \
-DbucketName="${{ steps.resolve-vars.outputs.bucketName }}" \
-DstagePrefix="${{ steps.resolve-vars.outputs.stagePrefix }}" \
-DtemplateName="${{ steps.resolve-vars.outputs.templateName }}" \
-Dmaven.test.skip \
-DskipIntegrationTests \
-pl ${{ steps.resolve-vars.outputs.modulePath }} -am
shell: bash

- name: Cleanup Java Environment
uses: ./.github/actions/cleanup-java-env
if: always()
Loading