diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..8119c74 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,49 @@ +{ + "name": "abbfreeathome-dev", + "image": "mcr.microsoft.com/devcontainers/python:1-3.12-bookworm", + "features": { + "ghcr.io/va-h/devcontainers-features/uv:latest": { + "shellautocompletion": true + }, + "ghcr.io/devcontainers-extra/features/pre-commit:2": {} + }, + "containerEnv": { + "UV_LINK_MODE": "copy" + }, + "customizations": { + "vscode": { + "extensions": [ + "charliermarsh.ruff", + "ms-python.pylint", + "ms-python.vscode-pylance", + "visualstudioexptteam.vscodeintellicode", + "ms-python.debugpy", + "esbenp.prettier-vscode", + "GitHub.vscode-pull-request-github", + "GitHub.copilot", + "waderyan.gitblame" + ], + "settings": { + "editor.formatOnSave": true, + "editor.tabSize": 2, + "editor.insertSpaces": true, + "editor.detectIndentation": false, + "files.insertFinalNewline": true, + "files.trimTrailingWhitespace": true, + "python.defaultInterpreterPath": "/workspaces/local-abbfreeathome/.venv/bin/python", + "python.terminal.activateEnvInCurrentTerminal": true, + "python.testing.pytestArgs": [ + "." + ], + "[python]": { + "editor.defaultFormatter": "charliermarsh.ruff" + }, + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true, + "gitblame.statusBarMessageFormat": "Modified By ${author.name} (${time.ago})", + "gitblame.inlineMessageFormat": "Modified By ${author.name} (${time.ago})", + } + } + }, + "postCreateCommand": "uv venv && uv pip install -r src/abbfreeathome/dev-requirements.txt && pre-commit install" +} diff --git a/.github/workflows/publish-testpypi.yaml b/.github/workflows/publish-testpypi.yaml index 4f7bc4a..3eae4b1 100644 --- a/.github/workflows/publish-testpypi.yaml +++ b/.github/workflows/publish-testpypi.yaml @@ -8,29 +8,29 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout Repo - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - - 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: Store the distribution packages - uses: actions/upload-artifact@v3 - with: - name: python-package-distributions - path: dist/ + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - 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: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ publish-to-testpypi: name: Publish Python distribution to TestPyPI @@ -45,7 +45,7 @@ jobs: url: https://test.pypi.org/p/local-abbfreeathome permissions: - id-token: write # IMPORTANT: mandatory for trusted publishing + id-token: write # IMPORTANT: mandatory for trusted publishing steps: - name: Download all the dists @@ -58,4 +58,3 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: repository-url: https://test.pypi.org/legacy/ - \ No newline at end of file diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index e91530b..33331c7 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -27,7 +27,7 @@ jobs: run: python3 -m build - name: Store the distribution packages - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: python-package-distributions path: dist/ diff --git a/README.md b/README.md index f135e0f..f52b360 100644 --- a/README.md +++ b/README.md @@ -162,6 +162,30 @@ Replace `python3.12` with your Python bash alias, double check which directory y Create any number of python files using the examples below (or your own code) to interact with the api. +## Development + +The easiest way to develop is in Visual Studio and the use of DevContainers. It'll also ensure you're following the same code formatting and linting standards as everyone else. It'll also get your local environment setup with all the tools required in minutes. + +### Prerequisites + +- [Docker](https://docs.docker.com/get-docker/) +- [Visual Studio Code](https://code.visualstudio.com/) +- [Git](https://git-scm.com/) + +### Getting Started + +1. If you don't have access to this repository, start by forking the repo into your own account. +2. Open up Visual Studio Code, navigate to the [Command Palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) and search for `Dev Containers: Clone Repository in Container Volume`. +3. You'll be prompted to enter the GitHub Repository URL. This will your forked repo url (unless you have access to this repo). +4. The dev container image will be built, once this is complete you'll be ready to develop! + +### Tests + +You can run a few tests to ensure everything is working as it should. + +1. In Visual Studio Code, Navigate to the `Testing` tab on the left and click `Run Tests` (Double Play Icon). This should run all Python Unit Tests. You can also run `Run Tests With Coverage` to get the code coverage results. +2. In a new terminal window you can run `python3 -m build` to build and package up the python code. + ## Examples Below are a number of examples on how to use the library. These examples use the above directory and virtual environment. diff --git a/src/abbfreeathome/dev-requirements.txt b/src/abbfreeathome/dev-requirements.txt index a97fdcf..bf680a0 100644 --- a/src/abbfreeathome/dev-requirements.txt +++ b/src/abbfreeathome/dev-requirements.txt @@ -1,10 +1,11 @@ aiohttp!=3.11.0 aioresponses backoff +build packaging pre-commit pytest pytest-asyncio pytest-cov pytest-env -ruff \ No newline at end of file +ruff