Skip to content

Commit

Permalink
Modernize GitHub Action and Python versions (#836)
Browse files Browse the repository at this point in the history
  • Loading branch information
achimnol authored May 7, 2024
1 parent f1dbdc3 commit 7fba7a8
Show file tree
Hide file tree
Showing 35 changed files with 269 additions and 377 deletions.
67 changes: 31 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,23 @@ jobs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python 3.9
uses: actions/setup-python@v2
uses: actions/checkout@v4
- name: Setup Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Cache PyPI
uses: actions/cache@v2
with:
key: pip-lint-${{ hashFiles('requirements/*.txt') }}
path: ~/.cache/pip
restore-keys: |
pip-lint-
python-version: '3.12'
cache: pip
cache-dependency-path: |
setup.py
requirements/lint.txt
- name: Install dependencies
uses: py-actions/py-dependency-install@v2
with:
path: requirements/test.txt
path: requirements/lint.txt
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit/
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Generate dists
run: |
pip install build
Expand All @@ -53,35 +54,28 @@ jobs:
needs: [lint]
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
os: [ubuntu]
registry: ['1']
pytest-arg: ['']
include:
- python-version: '3.9'
- python-version: '3.12'
os: windows
registry: '0'
pytest-arg: '-k test_integration'
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)" # - name: Cache
- name: Cache PyPI
uses: actions/cache@v2
with:
key: pip-ci-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements/*.txt') }}
path: ${{ steps.pip-cache.outputs.dir }}
restore-keys: |
pip-ci-${{ runner.os }}-${{ matrix.python-version }}-
cache: pip
cache-dependency-path: |
setup.py
requirements/test.txt
- name: Install dependencies
uses: py-actions/py-dependency-install@v2
with:
Expand Down Expand Up @@ -109,12 +103,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
- name: Upload coverage
uses: neuro-inc/[email protected]

- name: Upload code coverage report
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
deploy:
name: Deploy on PyPI
needs: [lint, test]
Expand All @@ -123,19 +118,19 @@ jobs:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python 3.9
uses: actions/setup-python@v2
uses: actions/checkout@v4
- name: Setup Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: '3.12'
- name: Install dependencies
run: |
pip install build wheel
- name: Build wheels
run: |
python -m build
- name: Release
uses: aio-libs/create-release@v1.2.3
uses: aio-libs/create-release@v1.6.5
with:
changes_file: CHANGES.rst
name: aiodocker
Expand Down
58 changes: 14 additions & 44 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
---

ci:
autoupdate_schedule: quarterly
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.0.1'
hooks:
- id: check-merge-conflict
- repo: https://github.com/asottile/yesqa
rev: v1.3.0
hooks:
- id: yesqa
- repo: https://github.com/PyCQA/isort
rev: '5.10.0'
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: '21.10b0'
hooks:
- id: black
language_version: python3 # Should be a command that runs python3.6+
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.0.1'
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: trailing-whitespace
Expand All @@ -27,35 +15,17 @@ repos:
docs/spelling_wordlist.txt|
.gitignore|
.gitattributes
- id: check-case-conflict
- id: check-json
- id: check-xml
- id: check-executables-have-shebangs
- id: check-toml
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: check-added-large-files
- id: check-symlinks
- id: debug-statements
- id: detect-aws-credentials
args: ['--allow-missing-credentials']
- id: detect-private-key
exclude: ^tests/certs/
- repo: https://github.com/asottile/pyupgrade
rev: 'v2.29.0'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.3
hooks:
- id: pyupgrade
args: ['--py36-plus']
- repo: https://github.com/PyCQA/flake8
rev: '4.0.1'
hooks:
- id: flake8
exclude: "^docs/"

- repo: git://github.com/Lucas-C/pre-commit-hooks-markup
rev: v1.0.1
- id: ruff
args: ['--fix']
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
- id: rst-linter
files: >-
^[^/]+[.]rst$
- id: mypy
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Some simple testing tasks (sorry, UNIX only).

lint: fmt
mypy aiodocker tests

fmt:
lint:
ifdef CI
pre-commit run --all-files --show-diff-on-failure
else
Expand Down
10 changes: 5 additions & 5 deletions aiodocker/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class DockerConfigs:
def __init__(self, docker):
self.docker = docker

async def list(self, *, filters: Mapping = None) -> List[Mapping]:
async def list(self, *, filters: Optional[Mapping] = None) -> List[Mapping]:
"""
Return a list of configs
Expand All @@ -34,7 +34,7 @@ async def create(
*,
b64: bool = False,
labels: Optional[Mapping[str, str]] = None,
templating: Mapping = None,
templating: Optional[Mapping] = None,
) -> Mapping[str, Any]:
"""
Create a config
Expand Down Expand Up @@ -101,11 +101,11 @@ async def update(
config_id: str,
version: str,
*,
name: str = None,
data: str = None,
name: Optional[str] = None,
data: Optional[str] = None,
b64: bool = False,
labels: Optional[Mapping[str, str]] = None,
templating: Mapping = None,
templating: Optional[Mapping] = None,
) -> bool:
"""
Update a config.
Expand Down
7 changes: 3 additions & 4 deletions aiodocker/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def __init__(
ssl_context: Optional[ssl.SSLContext] = None,
api_version: str = "auto",
) -> None:

docker_host = url # rename
if docker_host is None:
docker_host = os.environ.get("DOCKER_HOST", None)
Expand Down Expand Up @@ -198,7 +197,7 @@ def _query(
method: str = "GET",
*,
params: Optional[Mapping[str, Any]] = None,
data: Any = None,
data: Optional[Any] = None,
headers=None,
timeout=None,
chunked=None,
Expand Down Expand Up @@ -285,7 +284,7 @@ async def _query_json(
method: str = "GET",
*,
params: Optional[Mapping[str, Any]] = None,
data: Any = None,
data: Optional[Any] = None,
headers=None,
timeout=None,
read_until_eof: bool = True,
Expand Down Expand Up @@ -318,7 +317,7 @@ def _query_chunked_post(
method: str = "POST",
*,
params: Optional[Mapping[str, Any]] = None,
data: Any = None,
data: Optional[Any] = None,
headers=None,
timeout=None,
read_until_eof: bool = True,
Expand Down
6 changes: 3 additions & 3 deletions aiodocker/execs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async def resize(self, *, h: Optional[int] = None, w: Optional[int] = None) -> N
def start(
self,
*,
timeout: aiohttp.ClientTimeout = None,
timeout: Optional[aiohttp.ClientTimeout] = None,
detach: Literal[False] = False,
) -> Stream:
pass
Expand All @@ -61,7 +61,7 @@ def start(
async def start(
self,
*,
timeout: aiohttp.ClientTimeout = None,
timeout: Optional[aiohttp.ClientTimeout] = None,
detach: Literal[True],
) -> bytes:
pass
Expand Down Expand Up @@ -102,7 +102,7 @@ async def setup() -> Tuple[URL, bytes, bool]:

async def _start_detached(
self,
timeout: aiohttp.ClientTimeout = None,
timeout: Optional[aiohttp.ClientTimeout] = None,
tty: bool = False,
) -> bytes:
if self._tty is None:
Expand Down
Loading

0 comments on commit 7fba7a8

Please sign in to comment.