diff --git a/.github/workflows/spanner.yaml b/.github/workflows/spanner.yaml new file mode 100644 index 000000000000..ed356ea4e094 --- /dev/null +++ b/.github/workflows/spanner.yaml @@ -0,0 +1,36 @@ +# Copyright 2022 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 +# +# http://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. +# Github action job to test core java library features on +# downstream client libraries before they are released. +on: + push: + branches: + - main + pull_request: +name: spanner +jobs: + units: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + java: [21] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: ${{matrix.java}} + - run: java -version + - run: tests/spanner/test-spanner.sh \ No newline at end of file diff --git a/tests/spanner/test-spanner.sh b/tests/spanner/test-spanner.sh new file mode 100755 index 000000000000..5c8ec79b0ee2 --- /dev/null +++ b/tests/spanner/test-spanner.sh @@ -0,0 +1,38 @@ +#!/bin/bash +set -e + +SPANNER_VERSION=$(awk '/google-cloud-spanner-bom<\/artifactId>/{f=1;next} //{if(f){print;exit}}' google-cloud-bom/pom.xml | sed -n 's/.*\(.*\)<\/version>.*/\1/p') +FIRST_PARTY_DEPENDENCIES_VERSION=$(awk '/first-party-dependencies<\/artifactId>/{f=1;next} //{if(f){print;exit}}' libraries-bom/pom.xml | sed -n 's/.*\(.*\)<\/version>.*/\1/p') + +echo "google-cloud-spanner-bom version: $SPANNER_VERSION" +echo "first-party-dependencies version: $FIRST_PARTY_DEPENDENCIES_VERSION" + +# Download spanner source code +rm -rf java-spanner +git clone --depth 1 --branch v${SPANNER_VERSION} -c advice.detachedHead=false https://github.com/googleapis/java-spanner.git + +# Update the version of sdk-platform-java-config in all pom.xml files +for pom_file in $(find java-spanner -name "pom.xml"); do + if grep -q "sdk-platform-java-config" "$pom_file"; then + awk -v version="${FIRST_PARTY_DEPENDENCIES_VERSION}" ' + /sdk-platform-java-config<\/artifactId>/ { + print + getline # Read the next line (which should be the version) + print " " version "" + next + } + { print } + ' "$pom_file" > "$pom_file.tmp" && mv "$pom_file.tmp" "$pom_file" + echo "Updated: $pom_file" + fi +done + +# Show the diffs +echo "Changes after version updates:" +(cd java-spanner && git add .) +(cd java-spanner && git --no-pager diff --staged) + +# Clean up backup files +find java-spanner -name "pom.xml.bak" -delete + +(cd java-spanner && JOB_TYPE=test .kokoro/build.sh) \ No newline at end of file