1name: "Unit tests" 2 3on: 4 pull_request: 5 branches: 6 - main 7 8jobs: 9 run-unittests: 10 name: unit${{ matrix.option }}-${{ matrix.python }} 11 # TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed. 12 # Use ubuntu-22.04 until Python 3.7 is removed from the test matrix 13 # https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories 14 runs-on: ubuntu-22.04 15 strategy: 16 matrix: 17 option: ["", "_grpc_gcp", "_wo_grpc", "_w_prerelease_deps", "_w_async_rest_extra"] 18 python: 19 - "3.7" 20 - "3.8" 21 - "3.9" 22 - "3.10" 23 - "3.11" 24 - "3.12" 25 - "3.13" 26 exclude: 27 - option: "_wo_grpc" 28 python: 3.7 29 - option: "_wo_grpc" 30 python: 3.8 31 - option: "_wo_grpc" 32 python: 3.9 33 steps: 34 - name: Checkout 35 uses: actions/checkout@v4 36 - name: Setup Python 37 uses: actions/setup-python@v5 38 with: 39 python-version: ${{ matrix.python }} 40 - name: Install nox 41 run: | 42 python -m pip install --upgrade setuptools pip wheel 43 python -m pip install nox 44 - name: Run unit tests 45 env: 46 COVERAGE_FILE: .coverage${{ matrix.option }}-${{matrix.python }} 47 run: | 48 nox -s unit${{ matrix.option }}-${{ matrix.python }} 49 - name: Upload coverage results 50 uses: actions/upload-artifact@v4 51 with: 52 name: coverage-artifact-${{ matrix.option }}-${{ matrix.python }} 53 path: .coverage${{ matrix.option }}-${{ matrix.python }} 54 include-hidden-files: true 55 56 report-coverage: 57 name: cover 58 runs-on: ubuntu-latest 59 needs: 60 - run-unittests 61 steps: 62 - name: Checkout 63 uses: actions/checkout@v4 64 - name: Setup Python 65 uses: actions/setup-python@v5 66 with: 67 python-version: "3.10" 68 - name: Install coverage 69 run: | 70 python -m pip install --upgrade setuptools pip wheel 71 python -m pip install coverage 72 - name: Download coverage results 73 uses: actions/download-artifact@v4 74 with: 75 path: .coverage-results/ 76 - name: Report coverage results 77 run: | 78 find .coverage-results -type f -name '*.zip' -exec unzip {} \; 79 coverage combine .coverage-results/**/.coverage* 80 coverage report --show-missing --fail-under=100 81