Skip to content

Commit

Permalink
ci: consolidate workflows (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdstein authored May 30, 2024
1 parent b52e424 commit 4d3b4d8
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 81 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
coverageFile: coverage.xml
thresholdAll: 0.8
token: ${{ secrets.GITHUB_TOKEN }}
26 changes: 0 additions & 26 deletions .github/workflows/main.yaml

This file was deleted.

42 changes: 0 additions & 42 deletions .github/workflows/pull-request.yaml

This file was deleted.

10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 6 additions & 2 deletions src/posit/connect/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 4 additions & 8 deletions src/posit/connect/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion tests/posit/connect/test_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 4d3b4d8

Please sign in to comment.