|
55 | 55 | # GitHub tells you which host‑port was assigned via the `job.services` context |
56 | 56 | POSTGRES_URI: postgres://postgres:postgres@localhost:${{ job.services.postgres.ports['5432'] }}/testdb |
57 | 57 | run: | |
58 | | - uv run nox -s pytest |
| 58 | + uv run nox -s pytest -- --coverage |
| 59 | +
|
| 60 | + - name: Upload coverage |
| 61 | + uses: actions/upload-artifact@v4 |
| 62 | + with: |
| 63 | + name: .coverage.${{ matrix.python-version }} |
| 64 | + path: .coverage |
| 65 | + retention-days: 1 |
| 66 | + if-no-files-found: error |
| 67 | + include-hidden-files: true |
| 68 | + |
| 69 | + # upload-coverage taken from: https://github.com/hikari-py/hikari/blob/master/.github/workflows/ci.yml#L66 |
| 70 | + # |
| 71 | + # Copyright (c) 2020 Nekokatt |
| 72 | + # Copyright (c) 2021-present davfsa |
| 73 | + # |
| 74 | + # Permission is hereby granted, free of charge, to any person obtaining a copy |
| 75 | + # of this software and associated documentation files (the "Software"), to deal |
| 76 | + # in the Software without restriction, including without limitation the rights |
| 77 | + # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 78 | + # copies of the Software, and to permit persons to whom the Software is |
| 79 | + # furnished to do so, subject to the following conditions: |
| 80 | + # |
| 81 | + # The above copyright notice and this permission notice shall be included in all |
| 82 | + # copies or substantial portions of the Software. |
| 83 | + upload-coverage: |
| 84 | + needs: [ test ] |
| 85 | + runs-on: ubuntu-latest |
| 86 | + |
| 87 | + steps: |
| 88 | + - uses: actions/checkout@v4 |
| 89 | + - name: Install uv |
| 90 | + uses: astral-sh/setup-uv@v6 |
| 91 | + with: |
| 92 | + version: "0.6.9" |
| 93 | + python-version: "3.13" |
| 94 | + activate-environment: true |
| 95 | + |
| 96 | + - name: Download coverage |
| 97 | + uses: actions/download-artifact@v4 |
| 98 | + with: |
| 99 | + path: coverages/ |
| 100 | + |
| 101 | + - name: Extract individual coverage files |
| 102 | + run: | |
| 103 | + cd coverages |
| 104 | + |
| 105 | + for coverage_dir in ./.coverage.*; do |
| 106 | + mv "$coverage_dir/.coverage" "../$coverage_dir" |
| 107 | + rmdir "$coverage_dir" |
| 108 | + done |
| 109 | + |
| 110 | + cd .. |
| 111 | +
|
| 112 | + - name: Combine coverage |
| 113 | + run: | |
| 114 | + uv sync --frozen --only-group coverage |
| 115 | + |
| 116 | + coverage combine |
| 117 | + coverage xml |
| 118 | + coverage report |
| 119 | +
|
| 120 | + - name: Upload coverage to codecov |
| 121 | + uses: codecov/codecov-action@v5 |
| 122 | + with: |
| 123 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | + |
59 | 128 |
|
60 | 129 | ruff: |
61 | 130 | runs-on: ubuntu-latest |
@@ -105,7 +174,7 @@ jobs: |
105 | 174 | uv run nox -s asyncpg_check |
106 | 175 |
|
107 | 176 | ci-done: |
108 | | - needs: [ test, asyncpg, pyright, ruff ] |
| 177 | + needs: [ test,upload-coverage, asyncpg, pyright, ruff ] |
109 | 178 | if: always() && !cancelled() |
110 | 179 |
|
111 | 180 | runs-on: ubuntu-latest |
|
0 commit comments