Skip to content

Commit

Permalink
fix github actions ci
Browse files Browse the repository at this point in the history
  • Loading branch information
igorcoding committed Oct 11, 2024
1 parent 4777ea9 commit 273356e
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 69 deletions.
72 changes: 8 additions & 64 deletions .github/workflows/actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
test:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: ['3.10', '3.11', '3.12']

runs-on: ${{ matrix.os }}
Expand All @@ -28,63 +28,25 @@ jobs:
run: uv sync --all-extras --dev

- name: Run style check
run: uv run ruff format --check --diff $(package)
run: uv run ruff format --check --diff extapi tests

- name: Run ruff
run: uv run ruff check $(package)
run: uv run ruff check extapi tests

- name: Run mypy
run: uv run mypy --enable-error-code ignore-without-code $(package)
run: uv run mypy --enable-error-code ignore-without-code extapi tests

- name: Run deptry
run: uv run deptry . -e 'env|\.env|venv|\.venv|\..+'

- name: Run tests
run: uv run pytest .

build-wheels:
name: Build wheels on ${{ matrix.os }}
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
needs:
- test

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install uv
uses: astral-sh/setup-uv@v3

- uses: actions/setup-python@v5

- name: Install the project
run: uv sync --all-extras --dev
env:
UV_SYSTEM_PYTHON: 1

- name: Install cibuildwheel
run: pip install --upgrade cibuildwheel

- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "cp310-* cp311-* cp312-*"

- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl

publish:
name: Publish wheels
name: Publish to PyPI
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
needs:
- build-wheels
- test
runs-on: ubuntu-latest
steps:
- name: Get tag
Expand All @@ -106,26 +68,11 @@ jobs:
run: |
python -m pip install --upgrade pip setuptools wheel twine build
- uses: actions/download-artifact@v4
with:
name: wheels-ubuntu-latest
path: wheels-ubuntu

- uses: actions/download-artifact@v4
with:
name: wheels-macos-latest
path: wheels-macos

- uses: actions/download-artifact@v4
with:
name: wheels-windows-latest
path: wheels-windows

- name: Publish dist
run: |
python -m build . -s
tree dist wheels-ubuntu wheels-macos wheels-windows
twine upload dist/* wheels-ubuntu/*.whl wheels-macos/*.whl wheels-windows/*.whl
tree dist
twine upload dist/*
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
Expand All @@ -136,7 +83,4 @@ jobs:
prerelease: false
title: ${{ steps.get_tag.outputs.TAG }}
files: |
wheels-ubuntu/*.whl
wheels-macos/*.whl
wheels-windows/*.whl
dist/*
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 0.1.6
* moved to github

# 0.1.5
* removed unnecessary `asyncio.sleep` after the last retry in `RetryableExecutor.execute`

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# extapi

[![Build](https://github.com/ktsstudio/extapi/actions/workflows/actions.yaml/badge.svg?branch=main)](https://github.com/ktsstudio/extapi/actions)
[![PyPI](https://img.shields.io/pypi/v/extapi.svg)](https://pypi.python.org/pypi/extapi)

Library for performing HTTP calls to external systems. Made to be modular, extensible and easy to use.

## Installation
Expand Down
2 changes: 2 additions & 0 deletions extapi/_meta.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import importlib.util
import sys

PY311 = sys.version_info >= (3, 11)
has_open_telemetry = importlib.util.find_spec("opentelemetry") is not None
has_prometheus = importlib.util.find_spec("prometheus_client") is not None
9 changes: 8 additions & 1 deletion extapi/http/abc.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import abc
from collections.abc import Mapping
from typing import Any, Generic, Protocol, Self, TypeVar, runtime_checkable
from typing import Any, Generic, Protocol, TypeVar, runtime_checkable

from multidict import CIMultiDict
from yarl import URL

from extapi._meta import PY311

from .types import RequestData, Response, StrOrURL

if PY311:
from typing import Self # type: ignore[attr-defined]
else:
from typing_extensions import Self

T_co = TypeVar("T_co", covariant=True)
T_contr = TypeVar("T_contr", contravariant=True)
T = TypeVar("T")
Expand Down
8 changes: 7 additions & 1 deletion extapi/http/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@
Generic,
Literal,
Protocol,
Self,
TypeVar,
runtime_checkable,
)

from multidict import CIMultiDict
from yarl import URL

from extapi._meta import PY311

if PY311:
from typing import Self # type: ignore[attr-defined]
else:
from typing_extensions import Self

HttpMethod = Literal["GET", "POST", "PUT", "PATCH", "DELETE"] | str
StrOrURL = str | URL

Expand Down
9 changes: 8 additions & 1 deletion extapi/limiters/concurrency/abc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import abc
from typing import Protocol, Self
from typing import Protocol

from extapi._meta import PY311

if PY311:
from typing import Self # type: ignore[attr-defined]
else:
from typing_extensions import Self


class AbstractSemaphore(metaclass=abc.ABCMeta):
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "extapi"
version = "0.1.5"
version = "0.1.6b1"
description = "External API library"
authors = [
{ name = "KTS", email = "[email protected]" }
Expand All @@ -25,6 +25,7 @@ readme = "README.md"
dependencies = [
"multidict",
"yarl",
"typing-extensions; python_version < '3.11'",
]

[project.optional-dependencies]
Expand Down
8 changes: 7 additions & 1 deletion tests/exthttp/test_abstract.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
from typing import Any, assert_type
from typing import Any

import pytest
from multidict import CIMultiDict

from extapi._meta import PY311
from extapi.http.abc import AbstractExecutor, Addon
from extapi.http.types import RequestData, Response

if PY311:
from typing import assert_type # type: ignore[attr-defined]
else:
from typing_extensions import assert_type


class TestAbstractExecutor:
@pytest.mark.parametrize("method", ["get", "post", "put", "patch", "delete"])
Expand Down

0 comments on commit 273356e

Please sign in to comment.