Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions .github/workflows/test-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
tests:
name: Tests (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
environment: ci-live
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -91,6 +92,7 @@ jobs:
examples:
name: Examples (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
environment: ci-live
strategy:
fail-fast: false
matrix:
Expand All @@ -116,26 +118,22 @@ jobs:
PDFREST_API_KEY: ${{ secrets.PDFREST_API_KEY }}

publish:
name: Publish to CodeArtifact
name: Publish to PyPI
needs:
- docs-check
- tests
- examples
if: github.event_name == 'release'
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
environment: production
permissions:
id-token: write
contents: read
packages: write
env:
UV_PROJECT_ENVIRONMENT: .venv-release
UV_TRUSTED_PUBLISHING: always
steps:
- uses: actions/checkout@v4
- name: Assume AWS role for repository CI
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::304774597385:role/cit-oidc-role-${{ github.event.repository.name }}-ci
aws-region: us-east-2
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
Expand All @@ -149,11 +147,9 @@ jobs:
path: |
${{ env.UV_PROJECT_ENVIRONMENT }}
key: ${{ runner.os }}-uv-release-${{ hashFiles('pyproject.toml') }}
- name: Install keyring
run: uv tool install keyring --with keyrings.codeartifact
- name: Synchronize project dependencies
run: uv sync --group dev
- name: Build distribution artifacts
run: uv build --python 3.11
- name: Publish package to CodeArtifact
run: uv publish --publish-url=https://datalogics-304774597385.d.codeartifact.us-east-2.amazonaws.com/pypi/cit-pypi/ --username __token__
- name: Publish package to PyPI (Trusted Publishing)
run: uv publish
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pdfrest"
version = "0.1.0"
version = "1.0.0"
description = "Python client library for interacting with the PDFRest API"
readme = "README.md"
authors = [
Expand Down
58 changes: 58 additions & 0 deletions tests/live/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from __future__ import annotations

import os
from typing import Any

import pytest

from pdfrest import AsyncPdfRestClient, PdfRestClient

DEFAULT_LIVE_WSN = "dl-internal-python-ci"


def _with_live_wsn_header(kwargs: dict[str, Any], wsn: str) -> dict[str, Any]:
new_kwargs = dict(kwargs)
headers = dict(new_kwargs.get("headers") or {})
headers["wsn"] = wsn
new_kwargs["headers"] = headers
return new_kwargs


@pytest.fixture(scope="session")
def pdfrest_live_wsn() -> str:
return os.getenv("PDFREST_LIVE_WSN", DEFAULT_LIVE_WSN)


@pytest.fixture(autouse=True)
def inject_live_test_wsn_header(
monkeypatch: pytest.MonkeyPatch,
pdfrest_live_wsn: str,
) -> None:
original_sync_init = PdfRestClient.__init__
original_async_init = AsyncPdfRestClient.__init__

def sync_init_with_live_header(
self: PdfRestClient,
*args: Any,
**kwargs: Any,
) -> None:
original_sync_init(
self,
*args,
**_with_live_wsn_header(kwargs, pdfrest_live_wsn),
)

def async_init_with_live_header(
self: AsyncPdfRestClient,
*args: Any,
**kwargs: Any,
) -> None:
original_async_init(
self,
*args,
**_with_live_wsn_header(kwargs, pdfrest_live_wsn),
)

monkeypatch.setattr(PdfRestClient, "__init__", sync_init_with_live_header)
monkeypatch.setattr(AsyncPdfRestClient, "__init__", async_init_with_live_header)
return
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.