|
| 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 | +# https://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 | + |
| 15 | +on: |
| 16 | + pull_request: |
| 17 | + branches: |
| 18 | + - main |
| 19 | + |
| 20 | +permissions: |
| 21 | + contents: read |
| 22 | + |
| 23 | +name: unittest |
| 24 | +jobs: |
| 25 | + unit: |
| 26 | + runs-on: ubuntu-22.04 |
| 27 | + strategy: |
| 28 | + matrix: |
| 29 | + python: ['3.8'] |
| 30 | + steps: |
| 31 | + - name: Checkout |
| 32 | + uses: actions/checkout@v4 |
| 33 | + - name: Setup Python |
| 34 | + uses: actions/setup-python@v5 |
| 35 | + with: |
| 36 | + python-version: ${{ matrix.python }} |
| 37 | + - name: Install nox |
| 38 | + run: | |
| 39 | + python -m pip install --upgrade setuptools pip wheel |
| 40 | + python -m pip install nox |
| 41 | + - name: Run unit tests |
| 42 | + env: |
| 43 | + COVERAGE_FILE: .coverage-${{ matrix.python }} |
| 44 | + run: | |
| 45 | + nox -s unit-${{ matrix.python }} |
| 46 | + - name: Upload coverage results |
| 47 | + uses: actions/upload-artifact@v4 |
| 48 | + with: |
| 49 | + name: coverage-artifact-${{ matrix.python }} |
| 50 | + path: .coverage-${{ matrix.python }} |
| 51 | + include-hidden-files: true |
| 52 | + |
| 53 | + cover: |
| 54 | + runs-on: ubuntu-latest |
| 55 | + needs: |
| 56 | + - unit |
| 57 | + steps: |
| 58 | + - name: Checkout |
| 59 | + uses: actions/checkout@v4 |
| 60 | + - name: Setup Python |
| 61 | + uses: actions/setup-python@v5 |
| 62 | + with: |
| 63 | + python-version: "3.13" |
| 64 | + - name: Install coverage |
| 65 | + run: | |
| 66 | + python -m pip install --upgrade setuptools pip wheel |
| 67 | + python -m pip install coverage |
| 68 | + - name: Download coverage results |
| 69 | + uses: actions/download-artifact@v4 |
| 70 | + with: |
| 71 | + path: .coverage-results/ |
| 72 | + - name: Report coverage results |
| 73 | + run: | |
| 74 | + find .coverage-results -type f -name '*.zip' -exec unzip {} \; |
| 75 | + coverage combine .coverage-results/**/.coverage* |
| 76 | + coverage report --show-missing --fail-under=99 |
0 commit comments