From d7fe281f1b506e69671b5c729a948956ba1c0561 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sun, 13 Jul 2025 12:06:06 +0200 Subject: [PATCH 01/10] Actions and pypi --- .github/workflows/merge.yml | 43 ++++++++++++++++++++++++++++ .github/workflows/verify.yml | 55 ++++++++++++++++++++++++++++++++++++ .gitignore | 3 +- LICENSE | 21 ++++++++++++++ README.md | 1 + pyproject.toml | 2 +- 6 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/merge.yml create mode 100644 .github/workflows/verify.yml create mode 100644 LICENSE create mode 100644 README.md diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml new file mode 100644 index 0000000..1a75acd --- /dev/null +++ b/.github/workflows/merge.yml @@ -0,0 +1,43 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Latest release + +env: + CACHE_VERSION: 1 + DEFAULT_PYTHON: "3.13" + +# Only run on merges +on: + pull_request: + types: closed + branches: + - main + +jobs: + publishing: + name: Build and publish Python 🐍 distributions 📦 to PyPI + runs-on: ubuntu-latest + # Only trigger on merges, not just closes + if: github.event.pull_request.merged == true + steps: + - name: Check out committed code + uses: actions/checkout@v4 + - name: Set up Python ${{ env.DEFAULT_PYTHON }} + id: python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.DEFAULT_PYTHON }} + - name: Install pypa/build + run: >- + python3 -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: python3 -m build + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.pypi_token }} + skip-existing: true diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 0000000..5ad33c9 --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,55 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Latest commit + +env: + CACHE_VERSION: 1 + DEFAULT_PYTHON: "3.13" + PRE_COMMIT_HOME: ~/.cache/pre-commit + VENV: venv + +on: + schedule: + - cron: "2 4 * * 0" # weekly + workflow_dispatch: + push: +# pull_request: + +jobs: + # Check shellscripts + shellcheck: + name: Shellcheck + runs-on: ubuntu-latest + steps: + - name: Check out committed code + uses: actions/checkout@v4 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + + test-publishing: + name: Build and publish Python 🐍 distributions 📦 to TestPyPI + runs-on: ubuntu-latest + needs: + - cache + - prepare + - coverage + - mypy + steps: + - name: Check out committed code + uses: actions/checkout@v4 + - name: Install pypa/build + run: | + . venv/bin/activate + uv pip install build + - name: Build a binary wheel and a source tarball + run: | + . venv/bin/activate + python3 -m build + - name: Publish distribution 📦 to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + continue-on-error: true + with: + password: ${{ secrets.testpypi_token }} + repository-url: https://test.pypi.org/legacy/ + skip-existing: true diff --git a/.gitignore b/.gitignore index eba1a63..94f98cd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,9 @@ venv __pycache__ *.pyc .*.swp -/*.egg_info +/*.egg-info /build/ +dist tests/__pycache__ .mypy_cache .vscode diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d44874a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 by @CoMPaTech + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..43cf59e --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Ubiquity airOS Module diff --git a/pyproject.toml b/pyproject.toml index 3136b76..dde1d81 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "airos" -version = "0.0.1" +version = "0.0.2" license = "MIT" description = "Ubiquity airOS module(s) for Python 3." readme = "README.md" From 35bf8221bb92439682fcc39adf2fbac7bff209e2 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sun, 13 Jul 2025 12:07:32 +0200 Subject: [PATCH 02/10] Pre-commit --- .markdownlint.yaml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .markdownlint.yaml diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..320406d --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,2 @@ +default: true +MD013: false From c9d6db3bb686e8c6857f323831d4ae5a00d3957b Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sun, 13 Jul 2025 12:09:47 +0200 Subject: [PATCH 03/10] Remove for now --- .github/workflows/verify.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 5ad33c9..68b138b 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -1,6 +1,3 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - name: Latest commit env: @@ -11,7 +8,7 @@ env: on: schedule: - - cron: "2 4 * * 0" # weekly + - cron: "2 4 * * 0" # weekly workflow_dispatch: push: # pull_request: @@ -30,11 +27,6 @@ jobs: test-publishing: name: Build and publish Python 🐍 distributions 📦 to TestPyPI runs-on: ubuntu-latest - needs: - - cache - - prepare - - coverage - - mypy steps: - name: Check out committed code uses: actions/checkout@v4 From a27118a9fd2e473da6453b0a77958506c848cec2 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sun, 13 Jul 2025 12:11:49 +0200 Subject: [PATCH 04/10] Prep uv --- .github/workflows/verify.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 68b138b..97625c4 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -30,12 +30,17 @@ jobs: steps: - name: Check out committed code uses: actions/checkout@v4 + - name: Prepare uv + run: | + pip install uv + uv venv --system --seed venv - name: Install pypa/build run: | . venv/bin/activate uv pip install build - name: Build a binary wheel and a source tarball run: | + . venv/bin/activate . venv/bin/activate python3 -m build - name: Publish distribution 📦 to Test PyPI From 09013b0c119df94f8d905f1fc90b6393c04f659d Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sun, 13 Jul 2025 12:22:37 +0200 Subject: [PATCH 05/10] Switch to TP --- .github/workflows/merge.yml | 23 +++++++++++------------ .github/workflows/verify.yml | 13 +++++-------- .pre-commit-config.yaml | 20 ++++++++++---------- airos/__init__.py | 2 -- 4 files changed, 26 insertions(+), 32 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 1a75acd..3d281c4 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -1,6 +1,3 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - name: Latest release env: @@ -28,16 +25,18 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ env.DEFAULT_PYTHON }} - - name: Install pypa/build - run: >- - python3 -m - pip install - build - --user - - name: Build a binary wheel and a source tarball - run: python3 -m build + - name: Prepare poetry + run: | + pip install uv + uv venv --system --seed venv + . venv/bin/activate + uv pip install poetry + - name: Dependencies and build + run: | + . venv/bin/activate + poetry install --no-root + poetry build - name: Publish distribution 📦 to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - password: ${{ secrets.pypi_token }} skip-existing: true diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 97625c4..0d0abd2 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -30,23 +30,20 @@ jobs: steps: - name: Check out committed code uses: actions/checkout@v4 - - name: Prepare uv + - name: Prepare poetry run: | pip install uv uv venv --system --seed venv - - name: Install pypa/build - run: | . venv/bin/activate - uv pip install build - - name: Build a binary wheel and a source tarball + uv pip install poetry + - name: Dependencies and build run: | . venv/bin/activate - . venv/bin/activate - python3 -m build + poetry install --no-root + poetry build - name: Publish distribution 📦 to Test PyPI uses: pypa/gh-action-pypi-publish@release/v1 continue-on-error: true with: - password: ${{ secrets.testpypi_token }} repository-url: https://test.pypi.org/legacy/ skip-existing: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 95187d4..da4b4d0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,16 +40,16 @@ repos: - --quiet-level=2 exclude_types: [csv, json] exclude: ^userdata/|^fixtures/ - - repo: https://github.com/PyCQA/bandit - rev: 1.8.5 - hooks: - - id: bandit - name: "Bandit checking" - args: - - --quiet - - --format=custom - - --configfile=tests/bandit.yaml - files: ^(airos|tests)/.+\.py$ +# - repo: https://github.com/PyCQA/bandit +# rev: 1.8.5 +# hooks: +# - id: bandit +# name: "Bandit checking" +# args: +# - --quiet +# - --format=custom +# - --configfile=tests/bandit.yaml +# files: ^(airos|tests)/.+\.py$ - repo: https://github.com/adrienverge/yamllint.git rev: v1.37.1 hooks: diff --git a/airos/__init__.py b/airos/__init__.py index ccfa2f7..516ca7a 100644 --- a/airos/__init__.py +++ b/airos/__init__.py @@ -1,3 +1 @@ """Ubiquity AirOS python module.""" - - From 5ef985dcc3e5dd571f03a21de711ee1d01988185 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sun, 13 Jul 2025 12:27:16 +0200 Subject: [PATCH 06/10] Correctly use environment and set up permissions --- .github/workflows/merge.yml | 4 +++ .github/workflows/verify.yml | 4 +++ .yamllint | 61 ++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 .yamllint diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 3d281c4..146b8d8 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -15,6 +15,10 @@ jobs: publishing: name: Build and publish Python 🐍 distributions 📦 to PyPI runs-on: ubuntu-latest + environment: + name: pypi + permissions: + id-token: write # Only trigger on merges, not just closes if: github.event.pull_request.merged == true steps: diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 0d0abd2..30dfb95 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -27,6 +27,10 @@ jobs: test-publishing: name: Build and publish Python 🐍 distributions 📦 to TestPyPI runs-on: ubuntu-latest + environment: + name: testpypi + permissions: + id-token: write steps: - name: Check out committed code uses: actions/checkout@v4 diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..51e2cea --- /dev/null +++ b/.yamllint @@ -0,0 +1,61 @@ +ignore: | + .github* +rules: + braces: + level: error + min-spaces-inside: 0 + max-spaces-inside: 1 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + brackets: + level: error + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + colons: + level: error + max-spaces-before: 0 + max-spaces-after: 1 + commas: + level: error + max-spaces-before: 0 + min-spaces-after: 1 + max-spaces-after: 1 + comments: + level: error + require-starting-space: true + min-spaces-from-content: 2 + comments-indentation: + level: error + document-end: + level: error + present: false + document-start: + level: error + present: false + empty-lines: + level: error + max: 1 + max-start: 0 + max-end: 1 + hyphens: + level: error + max-spaces-after: 1 + indentation: + level: error + spaces: 2 + indent-sequences: true + check-multi-line-strings: false + key-duplicates: + level: error + line-length: disable + new-line-at-end-of-file: + level: error + new-lines: + level: error + type: unix + trailing-spaces: + level: error + truthy: + level: error From 388bc2e78d208d7a5d2d99a932aeece8ef3e92ad Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sun, 13 Jul 2025 12:34:34 +0200 Subject: [PATCH 07/10] Tinker env --- .github/workflows/merge.yml | 5 ++--- .github/workflows/verify.yml | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 146b8d8..a065039 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -15,8 +15,7 @@ jobs: publishing: name: Build and publish Python 🐍 distributions 📦 to PyPI runs-on: ubuntu-latest - environment: - name: pypi + environment: pypi permissions: id-token: write # Only trigger on merges, not just closes @@ -32,7 +31,7 @@ jobs: - name: Prepare poetry run: | pip install uv - uv venv --system --seed venv + uv venv --seed venv . venv/bin/activate uv pip install poetry - name: Dependencies and build diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 30dfb95..27f303d 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -27,8 +27,7 @@ jobs: test-publishing: name: Build and publish Python 🐍 distributions 📦 to TestPyPI runs-on: ubuntu-latest - environment: - name: testpypi + environment: testpypi permissions: id-token: write steps: @@ -37,7 +36,7 @@ jobs: - name: Prepare poetry run: | pip install uv - uv venv --system --seed venv + uv venv --seed venv . venv/bin/activate uv pip install poetry - name: Dependencies and build From 7d89ac9c4b3dc567db644078d7b22aa5d62012d0 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sun, 13 Jul 2025 12:57:13 +0200 Subject: [PATCH 08/10] Back to token-based --- .github/workflows/merge.yml | 1 + .github/workflows/verify.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index a065039..a164fdd 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -43,3 +43,4 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: skip-existing: true + password: ${{ secrets.pypi_token }} diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 27f303d..5f85e75 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -50,3 +50,4 @@ jobs: with: repository-url: https://test.pypi.org/legacy/ skip-existing: true + password: ${{ secrets.testpypi_token }} From c2c8ed8709dbca027777f239b546b6ed0b423c7e Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sun, 13 Jul 2025 12:58:49 +0200 Subject: [PATCH 09/10] Back to TP --- .github/workflows/merge.yml | 1 - .github/workflows/verify.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index a164fdd..a065039 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -43,4 +43,3 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: skip-existing: true - password: ${{ secrets.pypi_token }} diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 5f85e75..27f303d 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -50,4 +50,3 @@ jobs: with: repository-url: https://test.pypi.org/legacy/ skip-existing: true - password: ${{ secrets.testpypi_token }} From 8632c0440c1218e9006f445ec2d06c3490dc61b0 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sun, 13 Jul 2025 13:01:59 +0200 Subject: [PATCH 10/10] Back to TP with env --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index dde1d81..703aaa0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "airos" -version = "0.0.2" +version = "0.0.3a0" license = "MIT" description = "Ubiquity airOS module(s) for Python 3." readme = "README.md"