|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +# Cancel in-progress runs for the same branch when a new push arrives. |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + |
| 17 | +jobs: |
| 18 | + test: |
| 19 | + name: pytest (Python ${{ matrix.python-version }}) |
| 20 | + runs-on: ubuntu-latest |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Install uv |
| 29 | + uses: astral-sh/setup-uv@v6 |
| 30 | + with: |
| 31 | + enable-cache: true |
| 32 | + |
| 33 | + - name: Install Python ${{ matrix.python-version }} |
| 34 | + run: uv python install ${{ matrix.python-version }} |
| 35 | + |
| 36 | + - name: Sync dependencies |
| 37 | + run: uv sync --python ${{ matrix.python-version }} |
| 38 | + |
| 39 | + - name: Run unit tests |
| 40 | + run: uv run --python ${{ matrix.python-version }} pytest |
| 41 | + |
| 42 | + lint: |
| 43 | + name: ruff + mypy |
| 44 | + runs-on: ubuntu-latest |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + |
| 48 | + - name: Install uv |
| 49 | + uses: astral-sh/setup-uv@v6 |
| 50 | + with: |
| 51 | + enable-cache: true |
| 52 | + |
| 53 | + - name: Sync dependencies |
| 54 | + run: uv sync |
| 55 | + |
| 56 | + - name: Ruff |
| 57 | + run: uv run ruff check src/ tests/ examples/ |
| 58 | + |
| 59 | + - name: Mypy |
| 60 | + run: uv run mypy src/ |
| 61 | + |
| 62 | + integration: |
| 63 | + # Only run live API tests on the canonical repository, on push to main. |
| 64 | + # Forks won't have the secret and would fail otherwise. |
| 65 | + name: live API tests |
| 66 | + runs-on: ubuntu-latest |
| 67 | + needs: [test, lint] |
| 68 | + if: github.repository == 'bytesview/python-client' && github.event_name == 'push' |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v4 |
| 71 | + |
| 72 | + - name: Install uv |
| 73 | + uses: astral-sh/setup-uv@v6 |
| 74 | + |
| 75 | + - name: Sync dependencies |
| 76 | + run: uv sync |
| 77 | + |
| 78 | + - name: Run integration tests |
| 79 | + env: |
| 80 | + PYTEST_TOKEN: ${{ secrets.PYTEST_NEWSDATA_API }} |
| 81 | + run: | |
| 82 | + if [ -z "${PYTEST_TOKEN}" ]; then |
| 83 | + echo "PYTEST_NEWSDATA_API secret not set; skipping integration tests." |
| 84 | + exit 0 |
| 85 | + fi |
| 86 | + uv run pytest -m integration |
0 commit comments