diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..10bd741d --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,52 @@ +name: CI +on: + - push +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + check-latest: true + cache: 'pip' + - run: make deps + - run: make lint + + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: + - '3.8' + - '3.9' + - '3.10' + - '3.11' + - '3.12' + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + check-latest: true + cache: 'pip' + - run: make deps + - run: make dev + - run: make test + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + check-latest: true + cache: 'pip' + - run: make deps + - run: make build diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml new file mode 100644 index 00000000..9f931f09 --- /dev/null +++ b/.github/workflows/coverage.yaml @@ -0,0 +1,25 @@ +name: Coverage +on: + - pull_request +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + cov: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + check-latest: true + cache: 'pip' + - run: make deps + - run: make dev + - run: make test + - run: make cov-xml + - uses: orgoro/coverage@v3.1 + with: + coverageFile: coverage.xml + thresholdAll: 0.8 + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml deleted file mode 100644 index ac2ab80a..00000000 --- a/.github/workflows/main.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: Main -on: - push: - branches: - - main - pull_request: - paths: - - '.github/workflows/main.yaml' -jobs: - default: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: - - '3.8' - - '3.9' - - '3.10' - - '3.11' - - '3.12' - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - run: make diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml deleted file mode 100644 index 61c1986b..00000000 --- a/.github/workflows/pull-request.yaml +++ /dev/null @@ -1,42 +0,0 @@ -name: Pull Request -on: - pull_request: -concurrency: - group: ${{ github.head_ref }} - cancel-in-progress: true -jobs: - test: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: - - '3.8' - - '3.9' - - '3.10' - - '3.11' - - '3.12' - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - run: make deps - - run: make dev - - run: make test - # Run coverage on one of the builds, doesn't matter which - - if: ${{ matrix.python-version == '3.12' }} - run: make cov-xml - - if: ${{ matrix.python-version == '3.12' }} - uses: orgoro/coverage@v3.1 - with: - coverageFile: coverage.xml - thresholdAll: 0.8 - token: ${{ secrets.GITHUB_TOKEN }} - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - - run: make deps - - run: make lint diff --git a/Makefile b/Makefile index 926c6a34..aa398c4b 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,15 @@ NAME := posit-sdk # Command aliases -PIP := pip3 PYTHON := python3 +# Check if 'uv' is available +ifneq ($(shell command -v uv 2>/dev/null),) +PIP := uv pip +else +PIP := pip3 +endif + .PHONY: build clean @@ -52,7 +58,7 @@ cov-xml: # Target for installing project dependencies deps: - $(PIP) install -r requirements.txt -r requirements-dev.txt + $(PIP) install --upgrade pip setuptools wheel -r requirements.txt -r requirements-dev.txt # Target for installing the project in editable mode dev: diff --git a/src/posit/connect/hooks.py b/src/posit/connect/hooks.py index 69cb87cd..c1876a3d 100644 --- a/src/posit/connect/hooks.py +++ b/src/posit/connect/hooks.py @@ -14,14 +14,18 @@ def handle_errors(response: Response, *args, **kwargs) -> Response: message = data["error"] http_status = response.status_code http_status_message = responses[http_status] - raise ClientError(error_code, message, http_status, http_status_message) + raise ClientError( + error_code, message, http_status, http_status_message + ) except JSONDecodeError: # No JSON error message from Connect, so just raise response.raise_for_status() return response -def check_for_deprecation_header(response: Response, *args, **kwargs) -> Response: +def check_for_deprecation_header( + response: Response, *args, **kwargs +) -> Response: """ Check for deprecation warnings from the server. diff --git a/src/posit/connect/users.py b/src/posit/connect/users.py index fae00ffe..58b2254d 100644 --- a/src/posit/connect/users.py +++ b/src/posit/connect/users.py @@ -163,12 +163,10 @@ def find( prefix: str = ..., user_role: str = ..., account_status: str = ..., - ) -> List[User]: - ... + ) -> List[User]: ... @overload - def find(self, *args, **kwargs) -> List[User]: - ... + def find(self, *args, **kwargs) -> List[User]: ... def find(self, *args, **kwargs): params = dict(*args, **kwargs) @@ -189,12 +187,10 @@ def find_one( prefix: str = ..., user_role: str = ..., account_status: str = ..., - ) -> User | None: - ... + ) -> User | None: ... @overload - def find_one(self, *args, **kwargs) -> User | None: - ... + def find_one(self, *args, **kwargs) -> User | None: ... def find_one(self, *args, **kwargs) -> User | None: params = dict(*args, **kwargs) diff --git a/tests/posit/connect/test_hooks.py b/tests/posit/connect/test_hooks.py index 0ee7bf6f..00c19c54 100644 --- a/tests/posit/connect/test_hooks.py +++ b/tests/posit/connect/test_hooks.py @@ -71,7 +71,8 @@ def test_response_client_error_without_payload(): @responses.activate def test_deprecation_warning(): responses.get( - "https://connect.example/__api__/v0", headers={"X-Deprecated-Endpoint": "v1/"} + "https://connect.example/__api__/v0", + headers={"X-Deprecated-Endpoint": "v1/"}, ) c = Client("12345", "https://connect.example")