|
| 1 | +# Copyright 2026 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +name: Librarian generate diff check on pull requests |
| 15 | +on: |
| 16 | + pull_request: |
| 17 | + |
| 18 | +jobs: |
| 19 | + library_generation: |
| 20 | + runs-on: ubuntu-24.04 |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + fetch-depth: 0 |
| 25 | + - uses: actions/setup-go@v5 |
| 26 | + with: |
| 27 | + go-version: 'stable' |
| 28 | + - name: Install Librarian |
| 29 | + run: | |
| 30 | + V=$(go run github.com/googleapis/librarian/cmd/librarian@latest config get version) |
| 31 | + echo "Installing librarian version $V" |
| 32 | + go install github.com/googleapis/librarian/cmd/librarian@$V |
| 33 | + - name: Install protoc |
| 34 | + run: | |
| 35 | + set -e |
| 36 | + VERSION="33.2" |
| 37 | + curl -fsSL --retry 5 --retry-delay 15 -o /tmp/protoc.zip "https://github.com/protocolbuffers/protobuf/releases/download/v$VERSION/protoc-$VERSION-linux-x86_64.zip" |
| 38 | + cd /usr/local |
| 39 | + sudo unzip -o /tmp/protoc.zip |
| 40 | + protoc --version |
| 41 | + - uses: actions/setup-java@v4 |
| 42 | + with: |
| 43 | + java-version: "17" |
| 44 | + distribution: "temurin" |
| 45 | + cache: "maven" |
| 46 | + - name: Verify Java and Maven installation |
| 47 | + run: | |
| 48 | + java -version |
| 49 | + if ! command -v mvn &> /dev/null; then |
| 50 | + sudo apt-get update && sudo apt-get install -y maven |
| 51 | + fi |
| 52 | + mvn -version |
| 53 | + - uses: actions/setup-python@v5 |
| 54 | + with: |
| 55 | + python-version: "3.12" |
| 56 | + cache: 'pip' |
| 57 | + - name: Run librarian install |
| 58 | + run: | |
| 59 | + librarian install |
| 60 | + echo "$HOME/java_tools/bin" >> $GITHUB_PATH |
| 61 | + - name: Run librarian generate |
| 62 | + env: |
| 63 | + PYTHONPATH: ${{ github.workspace }}/sdk-platform-java/hermetic_build/library_generation/owlbot |
| 64 | + run: | |
| 65 | + librarian generate --all |
| 66 | + - name: Check for generated code changes |
| 67 | + run: | |
| 68 | + git diff --exit-code |
0 commit comments