|
| 1 | +name: Gapic Generator Specialized Tests |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - 'packages/gapic-generator/**' |
| 7 | + - '.github/workflows/gapic-generator-tests.yml' |
| 8 | + push: |
| 9 | + branches: [main] |
| 10 | + paths: |
| 11 | + - 'packages/gapic-generator/**' |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: gapic-gen-${{ github.head_ref || github.run_id }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +env: |
| 18 | + SHOWCASE_VERSION: 0.35.0 |
| 19 | + PROTOC_VERSION: 3.20.2 |
| 20 | + LATEST_STABLE_PYTHON: 3.14 |
| 21 | + ALL_PYTHON: "['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']" |
| 22 | + |
| 23 | +jobs: |
| 24 | + check_changes: |
| 25 | + # We use a job-level 'if' with dorny/paths-filter because GitHub's top-level |
| 26 | + # 'on: pull_request: paths' can be bypassed during repository-wide migrations |
| 27 | + # or structural changes. This ensures these specialized (and heavy) matrix |
| 28 | + # jobs stay silent on PRs that do not touch the generator. |
| 29 | + runs-on: ubuntu-latest |
| 30 | + outputs: |
| 31 | + run_generator: ${{ steps.filter.outputs.generator }} |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + - uses: dorny/paths-filter@v3 |
| 35 | + id: filter |
| 36 | + with: |
| 37 | + filters: | |
| 38 | + generator: |
| 39 | + - 'packages/gapic-generator/**' |
| 40 | + - '.github/workflows/gapic-generator-tests.yml' |
| 41 | +
|
| 42 | + # Preserve the workaround for env variables in matrix |
| 43 | + python_config: |
| 44 | + needs: check_changes |
| 45 | + if: ${{ needs.check_changes.outputs.run_generator == 'true' }} |
| 46 | + runs-on: ubuntu-latest |
| 47 | + outputs: |
| 48 | + all_python: ${{ env.ALL_PYTHON }} |
| 49 | + latest_stable_python: ${{ env.LATEST_STABLE_PYTHON }} |
| 50 | + steps: |
| 51 | + - run: echo "Initializing config for gapic-generator" |
| 52 | + |
| 53 | + showcase-unit: |
| 54 | + needs: python_config |
| 55 | + strategy: |
| 56 | + fail-fast: false |
| 57 | + matrix: |
| 58 | + python: ${{ fromJSON(needs.python_config.outputs.all_python) }} |
| 59 | + variant: ['', _alternative_templates, _mixins, _alternative_templates_mixins, _w_rest_async] |
| 60 | + logging_scope: ["", "google"] |
| 61 | + runs-on: ubuntu-latest |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@v5 |
| 64 | + - name: Set up Python |
| 65 | + uses: actions/setup-python@v6 |
| 66 | + with: |
| 67 | + python-version: "${{ matrix.python }}" |
| 68 | + - name: Install System Deps & Protoc |
| 69 | + run: | |
| 70 | + sudo apt-get update && sudo apt-get install -y curl pandoc unzip |
| 71 | + sudo mkdir -p /usr/src/protoc/ && sudo chown -R ${USER} /usr/src/ |
| 72 | + curl --location https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip --output /usr/src/protoc/protoc.zip |
| 73 | + cd /usr/src/protoc/ && unzip protoc.zip |
| 74 | + sudo ln -s /usr/src/protoc/bin/protoc /usr/local/bin/protoc |
| 75 | + - name: Run Nox |
| 76 | + env: |
| 77 | + GOOGLE_SDK_PYTHON_LOGGING_SCOPE: ${{ matrix.logging_scope }} |
| 78 | + run: | |
| 79 | + pip install nox |
| 80 | + cd packages/gapic-generator |
| 81 | + nox -s showcase_unit${{ matrix.variant }}-${{ matrix.python }} |
| 82 | +
|
| 83 | + showcase-mypy: |
| 84 | + needs: python_config |
| 85 | + runs-on: ubuntu-latest |
| 86 | + steps: |
| 87 | + - uses: actions/checkout@v5 |
| 88 | + - name: Set up Python |
| 89 | + uses: actions/setup-python@v6 |
| 90 | + with: |
| 91 | + python-version: ${{ needs.python_config.outputs.latest_stable_python }} |
| 92 | + - name: Install System Deps |
| 93 | + run: sudo apt-get update && sudo apt-get install -y pandoc |
| 94 | + - name: Run Mypy |
| 95 | + run: | |
| 96 | + pip install nox |
| 97 | + cd packages/gapic-generator |
| 98 | + nox -s showcase_mypy |
| 99 | +
|
| 100 | + goldens: |
| 101 | + needs: python_config |
| 102 | + runs-on: ubuntu-latest |
| 103 | + steps: |
| 104 | + - uses: actions/checkout@v5 |
| 105 | + - name: Set up Python |
| 106 | + uses: actions/setup-python@v6 |
| 107 | + with: |
| 108 | + python-version: ${{ needs.python_config.outputs.latest_stable_python }} |
| 109 | + - name: Install System Deps |
| 110 | + run: sudo apt-get update && sudo apt-get install -y pandoc |
| 111 | + - name: Run Goldens |
| 112 | + run: | |
| 113 | + pip install nox |
| 114 | + cd packages/gapic-generator |
| 115 | + for pkg in credentials eventarc logging redis; do |
| 116 | + nox -f tests/integration/goldens/$pkg/noxfile.py -s format lint unit-${{ needs.python_config.outputs.latest_stable_python }} |
| 117 | + done |
| 118 | +
|
| 119 | + goldens-prerelease: |
| 120 | + needs: python_config |
| 121 | + runs-on: ubuntu-latest |
| 122 | + steps: |
| 123 | + - uses: actions/checkout@v5 |
| 124 | + - name: Set up Python |
| 125 | + uses: actions/setup-python@v6 |
| 126 | + with: |
| 127 | + python-version: ${{ needs.python_config.outputs.latest_stable_python }} |
| 128 | + - name: Install System Deps |
| 129 | + run: sudo apt-get update && sudo apt-get install -y pandoc |
| 130 | + - name: Run Goldens (Prerelease) |
| 131 | + run: | |
| 132 | + pip install nox |
| 133 | + cd packages/gapic-generator |
| 134 | + for pkg in credentials eventarc logging redis; do |
| 135 | + nox -f tests/integration/goldens/$pkg/noxfile.py -s core_deps_from_source prerelease_deps |
| 136 | + done |
| 137 | +
|
| 138 | + fragment-snippet: |
| 139 | + needs: python_config |
| 140 | + strategy: |
| 141 | + matrix: |
| 142 | + python: ["3.10", "3.14"] |
| 143 | + runs-on: ubuntu-latest |
| 144 | + steps: |
| 145 | + - uses: actions/checkout@v5 |
| 146 | + - name: Set up Python |
| 147 | + uses: actions/setup-python@v6 |
| 148 | + with: |
| 149 | + python-version: ${{ matrix.python }} |
| 150 | + # This fixes the Pandoc error |
| 151 | + - name: Install System Deps & Protoc |
| 152 | + run: | |
| 153 | + sudo apt-get update && sudo apt-get install -y curl pandoc unzip |
| 154 | + sudo mkdir -p /usr/src/protoc/ && sudo chown -R ${USER} /usr/src/ |
| 155 | + curl --location https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip --output /usr/src/protoc/protoc.zip |
| 156 | + cd /usr/src/protoc/ && unzip protoc.zip |
| 157 | + sudo ln -s /usr/src/protoc/bin/protoc /usr/local/bin/protoc |
| 158 | + - name: Run Tests |
| 159 | + run: | |
| 160 | + pip install nox |
| 161 | + cd packages/gapic-generator |
| 162 | + # Run fragment for current matrix python |
| 163 | + nox -s fragment-${{ matrix.python }} |
| 164 | + # Run snippetgen only on the latest stable to avoid the "Python not found" error |
| 165 | + if [ "${{ matrix.python }}" == "${{ needs.python_config.outputs.latest_stable_python }}" ]; then |
| 166 | + nox -s snippetgen |
| 167 | + fi |
0 commit comments