Skip to content

Commit

Permalink
Migrate from CircleCI to GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
phyrwork committed Sep 3, 2024
1 parent 50e7360 commit 2d3fcba
Show file tree
Hide file tree
Showing 8 changed files with 270 additions and 147 deletions.
134 changes: 0 additions & 134 deletions .circleci/config.yml

This file was deleted.

53 changes: 53 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
test:
strategy:
fail-fast: false
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12" ]
uv-version: [ "0.4.0" ]
os: [ ubuntu-22.04 ]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Set up uv ${{ matrix.uv-version }}
uses: yezz123/setup-uv@v4
with:
uv-version: ${{ matrix.uv-version }}

- name: Set up cache
uses: actions/cache@v3
with:
path: ./.venv
key: venv-${{ hashFiles('uv.lock') }}

- name: Install dependencies
run: uv sync

- name: Lint and check code format
run: uv run ruff check

- name: Check types
run: uv run mypy .

- name: Run unit tests
run: uv run pytest --cov=asyncio_multilock
37 changes: 37 additions & 0 deletions .github/workflows/publish-pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:
runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/project/asyncio-multilock

permissions:
id-token: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build

- name: Publish package
uses: pypa/gh-action-pypi-publish@v1.9.0
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
50 changes: 50 additions & 0 deletions .github/workflows/test-publish-pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Test publish

on: push

permissions:
contents: read

jobs:
deploy:
runs-on: ubuntu-latest

environment:
name: test-pypi
url: https://test.pypi.org/project/asyncio-multilock

permissions:
id-token: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies
run: |
python -m pip install --upgrade pip toml
pip install build
- name: Add build number to package version
shell: python
run: |
import toml
with open("pyproject.toml", "r") as f:
data = toml.load(f)
data["project"]["version"] = f'{data["project"]["version"]}.dev${{ github.run_id }}'
with open("pyproject.toml", "w") as f:
toml.dump(data, f)
- name: Build package
run: python -m build

- name: Publish package
uses: pypa/gh-action-pypi-publish@v1.9.0
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
repository-url: https://test.pypi.org/legacy/
skip-existing: true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# asyncio-multilock

[![asyncio-multilock](https://circleci.com/gh/phyrwork/asyncio-multilock/tree/main.svg?style=svg)](https://app.circleci.com/pipelines/github/phyrwork/asyncio-multilock?branch=main)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/phyrwork/asyncio-multilock/ci.yaml)

`asyncio_multilock` provides `MultiLock`, an `asyncio` based lock with built-in
shared/exclusive mode semantics.
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = [
{name = "Connor Newton", email = "connor@ifthenelse.io"}
]
readme = "README.md"
requires-python = ">=3.11,<4.0"
requires-python = ">=3.9,<4.0"
dependencies = []

[build-system]
Expand All @@ -21,6 +21,7 @@ dev-dependencies = [
"pytest-runner>=6.0.1",
"pytest-asyncio>=0.24.0",
"pytest-timeout>=2.3.1",
"pytest-cov>=5.0.0",
]

[tool.pytest.ini_options]
Expand Down
16 changes: 6 additions & 10 deletions src/asyncio_multilock/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from __future__ import annotations

from asyncio import CancelledError, Event, create_task
from contextlib import ExitStack, asynccontextmanager, contextmanager, suppress
from asyncio import Event
from contextlib import asynccontextmanager, contextmanager
from enum import IntEnum
from functools import reduce
from typing import (
AsyncIterator,
Dict,
FrozenSet,
Hashable,
Iterator,
Optional,
Expand All @@ -16,16 +15,13 @@
__sentinel__ = object()


class LockError(Exception):
...
class LockError(Exception): ...


class EventUsedError(LockError):
...
class EventUsedError(LockError): ...


class HandleUsedError(LockError):
...
class HandleUsedError(LockError): ...


class MultiLockType(IntEnum):
Expand Down Expand Up @@ -239,7 +235,7 @@ async def context(
#
# async def acquire(
# self,
# type: MultiLockType,
# \type: MultiLockType,
# handle: Optional[Hashable] = None,
# event: Optional[Event] = None,
# ) -> Hashable:
Expand Down
Loading

0 comments on commit 2d3fcba

Please sign in to comment.