Skip to content

Commit

Permalink
chore: remove poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
elsbrock committed Feb 6, 2025
1 parent 1e0c45e commit 83d6fdf
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 98 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ jobs:
- name: "Checkout the repository"
uses: "actions/[email protected]"

- name: "Set up Python"
uses: actions/[email protected]
with:
python-version: "3.11"
cache: "pip"
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main

- name: "Install requirements"
run: python3 -m pip install poetry && poetry install --no-root
- name: Setup Nix cache
uses: DeterminateSystems/magic-nix-cache-action@main

Check warning on line 23 in .github/workflows/lint.yml

View workflow job for this annotation

GitHub Actions / Ruff

Magic Nix Cache is deprecated

Magic Nix Cache has been deprecated due to a change in the underlying GitHub APIs and will stop working on 1 February 2025. To continue caching Nix builds in GitHub Actions, use FlakeHub Cache instead. Replace... uses: DeterminateSystems/magic-nix-cache-action@main ...with... uses: DeterminateSystems/flakehub-cache-action@main For more details: https://dtr.mn/magic-nix-cache-eol

Check warning on line 23 in .github/workflows/lint.yml

View workflow job for this annotation

GitHub Actions / test

Magic Nix Cache is deprecated

Magic Nix Cache has been deprecated due to a change in the underlying GitHub APIs and will stop working on 1 February 2025. To continue caching Nix builds in GitHub Actions, use FlakeHub Cache instead. Replace... uses: DeterminateSystems/magic-nix-cache-action@main ...with... uses: DeterminateSystems/flakehub-cache-action@main For more details: https://dtr.mn/magic-nix-cache-eol

- name: Ruff
run: poetry run ruff check .
- name: Run Ruff
run: |
nix develop --command bash -c "pip install -r requirements.txt && ruff check ."
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:

- name: Run tests
run: |
nix develop --command pytest tests/ -v --cov=custom_components.cowboy
nix develop --command bash -c "pip install -r requirements.txt && pytest tests/ -v --cov=custom_components.cowboy"
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,43 @@ The account password is stored by the integration in order to be able to renew t
> [!NOTE]
> The integration polls the Cowboy bike for data updates every minute and checks for software release availability every hour.
## Development

This project uses [Nix](https://nixos.org/) to manage development environments. This ensures consistent development environments across different machines.

### Prerequisites

1. Install Nix following the [official instructions](https://nixos.org/download.html)
2. Enable [Flakes](https://nixos.wiki/wiki/Flakes#Enable_flakes) if you haven't already

### Setting Up Development Environment

1. Clone the repository:
```bash
git clone https://github.com/elsbrock/cowboy-ha.git
cd cowboy-ha
```

2. Enter the development environment:
```bash
nix develop
```

This will:
- Create a Python virtual environment
- Install all development dependencies
- Set up a basic Home Assistant configuration

3. Start a development instance of Home Assistant:
```bash
hass -c config
```
Then visit http://localhost:8123 in your browser.

### Running Tests

The test suite can be run using pytest: `pytest tests/ -v`

## Disclaimer

This integration is an independent project and not officially affiliated with Cowboy. "Cowboy" is a trademark and belongs to its respective owners. This project does not claim any official endorsement by Cowboy. Use at your own risk.
Expand Down
39 changes: 2 additions & 37 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,13 @@
pythonEnv = pkgs.python311.withPackages (ps: with ps; [
pip
virtualenv
pytest
pytest-cov
pytest-asyncio
black
pylint
hatchling
colorlog
]);
in
{
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
pythonEnv

# Tools used in CI/development
yq-go # For JSON/YAML processing
zip # For packaging releases
git # For version control

# Development tools
git
pre-commit
];

Expand All @@ -51,41 +38,19 @@
if [ ! -f .venv/.installed ]; then
echo "Installing dependencies..."
pip install --upgrade pip
pip install home-assistant
pip install pytest-homeassistant-custom-component || exit 1
pip install -e ".[dev]" || exit 1
pip install -r requirements.txt
touch .venv/.installed
fi
# Add .venv/bin to PATH
export PATH="$PWD/.venv/bin:$PATH"
# Create config directory if it doesn't exist
if [ ! -d config ]; then
mkdir -p config
fi
# Create basic configuration.yaml if it doesn't exist
if [ ! -f config/configuration.yaml ]; then
echo "default_config:" > config/configuration.yaml
echo "# Uncomment below to enable debug logging for your component" >> config/configuration.yaml
echo "# logger:" >> config/configuration.yaml
echo "# default: info" >> config/configuration.yaml
echo "# logs:" >> config/configuration.yaml
echo "# custom_components.cowboy: debug" >> config/configuration.yaml
fi
echo "Development environment ready!"
echo ""
echo "Quick start:"
echo "1. Run 'hass -c config' to start Home Assistant"
echo "2. Visit http://localhost:8123 in your browser"
echo "3. Run 'pytest tests/' to run tests"
echo ""
echo "Development tips:"
echo "- Edit config/configuration.yaml to configure the integration"
echo "- Home Assistant will automatically reload when you make changes"
echo "- Use 'hass --debug -c config' for debug output"
'';
};
}
Expand Down
51 changes: 0 additions & 51 deletions pyproject.toml

This file was deleted.

10 changes: 10 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
homeassistant>=2023.12.3
pytest>=7.0
pytest-cov
pytest-homeassistant-custom-component>=0.13.91
pytest-asyncio>=0.21.0
black
pylint
pre-commit
ruff>=0.9.4
colorlog>=6.9.0

0 comments on commit 83d6fdf

Please sign in to comment.