-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
init
script to initialize a working devenv with a specifi…
…c Home Assistant version (#125)
- Loading branch information
Showing
13 changed files
with
93 additions
and
3,686 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
# | ||
# This script downloads a specified version of Home Assistant, | ||
# extracts its test suite, processes the files, and moves them into a | ||
# local 'tests/hass' directory for further use. | ||
# | ||
# Usage: ./scripts/download_fixtures.sh <Home Assistant Version> | ||
# Example: ./scripts/download_fixtures.sh 2021.3.4 | ||
set -e | ||
|
||
# Parameters | ||
VERSION=$1 | ||
|
||
# Abort if no version is specified | ||
if [ -z "$VERSION" ]; then | ||
echo "Usage: ./scripts/download_fixtures.sh <Home Assistant Version>" | ||
exit 1 | ||
fi | ||
|
||
# Variables | ||
DOWNLOAD_FOLDER=$(mktemp -d) | ||
HASS_TESTS_FOLDER=$DOWNLOAD_FOLDER/core-$VERSION/tests/ | ||
|
||
# Remove previous folder if exists | ||
if [ -d "tests/hass" ]; then | ||
echo "Removing previous tests/hass/ folder" | ||
rm -rf tests/hass | ||
fi | ||
|
||
# Download HASS version | ||
echo "Downloading Home Assistant $VERSION in $DOWNLOAD_FOLDER" | ||
curl -L https://github.com/home-assistant/core/archive/refs/tags/$VERSION.tar.gz -o $DOWNLOAD_FOLDER/$VERSION.tar.gz | ||
|
||
# Extract HASS fixtures and tests helpers, excluding all components and actual tests | ||
echo "Extracting tests/ folder from $VERSION.tar.gz" | ||
tar -C $DOWNLOAD_FOLDER --exclude='*/components/*' --exclude='*/pylint/*' -xf $DOWNLOAD_FOLDER/$VERSION.tar.gz core-$VERSION/tests | ||
find $HASS_TESTS_FOLDER -type f -name "test_*.py" -delete | ||
|
||
# Recursively find and update imports | ||
find $HASS_TESTS_FOLDER -type f -exec sed -i 's/from tests\./from tests.hass./g' {} + | ||
mv $HASS_TESTS_FOLDER/conftest.py $HASS_TESTS_FOLDER/fixtures.py | ||
|
||
# Copy Home Assistant fixtures | ||
mv $HASS_TESTS_FOLDER ./tests/hass | ||
echo "Home Assistant $VERSION tests are now in tests/hass/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Parameters | ||
VERSION=$1 | ||
|
||
# Abort if no version is specified | ||
if [ -z "$VERSION" ]; then | ||
echo "Usage: ./scripts/init.sh <Home Assistant Version>" | ||
exit 1 | ||
fi | ||
|
||
# Abort if `venv` folder already exists | ||
if [ -d "venv" ]; then | ||
echo "venv/ folder already exists. Deactivate your venv and remove venv/ folder." | ||
exit 1 | ||
fi | ||
|
||
# Create and activate a new virtual environment | ||
python3 -m venv venv | ||
source venv/bin/activate | ||
|
||
# Upgrade pip and install all projects and their dependencies | ||
pip install --upgrade pip | ||
pip install -e '.[all]' | ||
|
||
# Override Home Assistant version | ||
pip install homeassistant==$VERSION | ||
./scripts/download_fixtures.sh $VERSION |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.