Skip to content

Commit

Permalink
Add Dev Container Configuration (#162)
Browse files Browse the repository at this point in the history
* Add dev container and development documentation

* Remove note on venv

* Bump artifacts action
  • Loading branch information
kingsleyadam authored Feb 14, 2025
1 parent 9fdc8b1 commit 93a8698
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 27 deletions.
49 changes: 49 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
}
49 changes: 24 additions & 25 deletions .github/workflows/publish-testpypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -58,4 +58,3 @@ jobs:
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion src/abbfreeathome/dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
aiohttp!=3.11.0
aioresponses
backoff
build
packaging
pre-commit
pytest
pytest-asyncio
pytest-cov
pytest-env
ruff
ruff

0 comments on commit 93a8698

Please sign in to comment.