Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/docker-existing-dockerfile
{
"name": "Existing Dockerfile",
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerFile": "../Dockerfile.dev",
"build": {
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "../Dockerfile.dev"
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Install package in "dev mode" to expose CLI
"postCreateCommand": "pip3 install -e .",
"postCreateCommand": "uv sync --dev --frozen",
"postStartCommand": "uv sync --dev --frozen",
"postAttachCommand": "uv sync --dev --frozen",
// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
// "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
Expand All @@ -19,26 +23,22 @@
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"charliermarsh.ruff",
"ms-python.pylint"
]
},
"settings": {
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true,
"terminal.integrated.defaultProfile.linux": "zsh",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff"
},
"ruff.format.args": [
"--config",
"line-length=127"
],
"pylint.args": [
"--max-line-length=127"
]
"settings": {
"python.defaultInterpreterPath": ".venv/bin/python",
"python.terminal.activateEnvInCurrentTerminal": true,
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true,
"terminal.integrated.defaultProfile.linux": "zsh",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff"
}
}
}
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uv.lock linguist-generated
70 changes: 52 additions & 18 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,71 @@ on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.13"]

steps:
- uses: actions/checkout@v3

- name: Install uv and set the Python version
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}

- name: Build package
run: uv build

test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.13.x"]
python-version: ["3.13"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3

- name: Install uv and set the Python version
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install build
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
run: uv sync --locked --all-extras --dev

- name: Lint with ruff
# stop the build if there are Python syntax errors or undefined names
run: uv run ruff check --select=E9,F63,F7,F82 --output-format=github

- name: Test with pytest
run: |
pytest
- name: Build package
run: python -m build
uv run pytest

lint:
continue-on-error: true

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.13"]

steps:
- uses: actions/checkout@v3

- name: Install uv and set the Python version
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --locked --all-extras --dev

- name: Lint with ruff
run: uv run ruff check --output-format=github
19 changes: 12 additions & 7 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,24 @@ jobs:
deploy:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.13"]

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3

- name: Install uv and set the Python version
uses: astral-sh/setup-uv@v7
with:
python-version: '3.13.x'
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
run: uv sync --locked --all-extras --dev

- name: Build package
run: python -m build
run: uv build

- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
Expand Down
6 changes: 1 addition & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@
"terminal.integrated.defaultProfile.linux": "zsh",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff"
},
"ruff.lineLength": 127,
"pylint.args": [
"--max-line-length=127"
]
}
}
19 changes: 5 additions & 14 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM mcr.microsoft.com/devcontainers/python:1-3.13
FROM ghcr.io/astral-sh/uv:0.9.30 AS uv

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
FROM mcr.microsoft.com/devcontainers/python:3-3.13

COPY --from=uv --chown=vscode: /uv /uvx /bin/

RUN \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& apt-get update \
apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
# Additional library needed by some tests and accordingly by VScode Tests Discovery
git \
Expand All @@ -13,13 +14,3 @@ RUN \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /workspaces

# Install Python dependencies from requirements
COPY requirements.txt ./
COPY requirements_test.txt ./
RUN pip3 install -r requirements.txt
RUN pip3 install -r requirements_test.txt
RUN rm -f requirements.txt requirements_test.txt

# Set the default shell to bash instead of sh
ENV SHELL /bin/bash
34 changes: 34 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,37 @@ omada = "tplink_omada_client.cli:main"
[project.urls]
"Homepage" = "https://github.com/MarkGodwin/tplink-omada-api"
"Bug Tracker" = "https://github.com/MarkGodwin/tplink-omada-api/issues"

[dependency-groups]
dev = [
{include-group = "lint"},
{include-group = "test"},
"uv>=0.9.30",
]
lint = [
"pylint>=4.0.4",
"ruff>=0.15.0",
]
test = [
"coverage>=7.4.4",
"pytest>=9.0.0",
"pytest-aiohttp>=1.0.5",
]

[tool.ruff]
line-length = 127
preview = true

[tool.ruff.lint]
extend-select = [
"C90", # mccabe
"E", # pycodestyle
"W", # pycodestyle
"F", # pyflakes
]

[tool.ruff.lint.mccabe]
max-complexity = 10

[tool.pylint.main]
max-line-length = 127
15 changes: 0 additions & 15 deletions requirements.txt

This file was deleted.

9 changes: 0 additions & 9 deletions requirements_test.txt

This file was deleted.

Loading
Loading