diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index edc10bb31..51886ba05 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -48,8 +48,11 @@ jobs: pip install virtualenv --upgrade python -m venv venv . venv/bin/activate - pip install -U pip setuptools wheel - pip install -r requirements_test.txt -r requirements_commit.txt + pip install uv + uv pip install -U pip setuptools wheel + uv pip install -r requirements_test.txt -r requirements_commit.txt + # TODO: Remove after update of aiohttp beyond 3.10.0 + uv pip show aiohttp | grep -q "Version: 3.10.0" && (grep -q "core.locations" venv/lib/python*/site-packages/aiohttp/web_urldispatcher.py && echo " *** aiohttp already patched" || ( echo "Patching aiohttp 3.10.0 for tests"; patch -tRup0 venv/lib/python*/site-packages/aiohttp/web_urldispatcher.py < patch/aiohttp310.patch && echo " *** aiohttp Patched!" || echo " *** aiohttp patch failed?")) || ( echo " ***"; echo " *** WE CAN REMOVE THE PATCH FOR aiohttp 3.10.0 from $0"; echo " ***" ) - name: Restore pre-commit environment from cache id: cache-precommit uses: actions/cache@v4 @@ -97,7 +100,7 @@ jobs: - name: Ruff (with fix) run: | . venv/bin/activate - ruff plugwise/*py tests/*py + ruff check --fix plugwise/*py tests/*py - name: If needed, commit ruff changes to the pull request if: failure() run: | @@ -194,11 +197,14 @@ jobs: run: | python -m venv venv . venv/bin/activate - pip install -U pip setuptools wheel + pip install uv + uv pip install -U pip setuptools wheel #pip install -r requirements_test.txt # 20220124 Mimic setup_test.sh - pip install --upgrade -r requirements_test.txt -c https://raw.githubusercontent.com/home-assistant/core/dev/homeassistant/package_constraints.txt -r https://raw.githubusercontent.com/home-assistant/core/dev/requirements_test.txt -r https://raw.githubusercontent.com/home-assistant/core/dev/requirements_test_pre_commit.txt - pip install --upgrade pytest-asyncio + uv pip install --upgrade -r requirements_test.txt -c https://raw.githubusercontent.com/home-assistant/core/dev/homeassistant/package_constraints.txt -r https://raw.githubusercontent.com/home-assistant/core/dev/requirements_test.txt -r https://raw.githubusercontent.com/home-assistant/core/dev/requirements_test_pre_commit.txt + uv pip install --upgrade pytest-asyncio + # TODO: Remove after update of aiohttp beyond 3.10.0 + uv pip show aiohttp | grep -q "Version: 3.10.0" && (grep -q "core.locations" venv/lib/python*/site-packages/aiohttp/web_urldispatcher.py && echo " *** aiohttp already patched" || ( echo "Patching aiohttp 3.10.0 for tests"; patch -tRup0 venv/lib/python*/site-packages/aiohttp/web_urldispatcher.py < patch/aiohttp310.patch && echo " *** aiohttp Patched!" || echo " *** aiohttp patch failed?")) || ( echo " ***"; echo " *** WE CAN REMOVE THE PATCH FOR aiohttp 3.10.0 from $0"; echo " ***" ) pytest: runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index f4fc193c5..a75e47820 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## ongoing + +- Note2self; remove aiohttp 3.10 test fixing in scripts/* and verify workflow + ## v0.38.3 - Implement fix for Core Issue [#119686](https://github.com/home-assistant/core/issues/119686) diff --git a/patch/aiohttp310.patch b/patch/aiohttp310.patch new file mode 100644 index 000000000..b67728026 --- /dev/null +++ b/patch/aiohttp310.patch @@ -0,0 +1,19 @@ +--- venv/lib/python3.12/site-packages/aiohttp/web_urldispatcher.py 2024-08-01 13:01:32 ++++ /tmp/web_urldispatcher.py 2024-08-01 22:37:19 +@@ -1132,15 +1132,7 @@ + def _get_resource_index_key(self, resource: AbstractResource) -> str: + """Return a key to index the resource in the resource index.""" + # strip at the first { to allow for variables +- #return resource.canonical.partition("{")[0].rstrip("/") or "/" +- if "{" in (index_key := resource.canonical): +- # strip at the first { to allow for variables, and than +- # rpartition at / to allow for variable parts in the path +- # For example if the canonical path is `/core/locations{tail:.*}` +- # the index key will be `/core` since index is based on the +- # url parts split by `/` +- index_key = index_key.partition("{")[0].rpartition("/")[0] +- return index_key.rstrip("/") or "/" ++ return resource.canonical.partition("{")[0].rstrip("/") or "/" + + def index_resource(self, resource: AbstractResource) -> None: + """Add a resource to the resource index.""" diff --git a/requirements_test.txt b/requirements_test.txt index 2351f0dbf..4c6ba10dc 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -6,3 +6,4 @@ radon==6.0.1 types-python-dateutil # Added for prettier nodeenv==1.9.1 +uv diff --git a/scripts/tests_and_coverage.sh b/scripts/tests_and_coverage.sh index 3b9eca688..6949bbe06 100755 --- a/scripts/tests_and_coverage.sh +++ b/scripts/tests_and_coverage.sh @@ -24,7 +24,11 @@ fi # Install/update dependencies pre-commit install pre-commit install-hooks -pip install -r requirements_test.txt -r requirements_commit.txt +pip install uv +uv pip install -r requirements_test.txt -r requirements_commit.txt +# TODO: Remove after update of aiohttp beyond 3.10.0 +# shellcheck disable=SC2015 +uv pip show aiohttp | grep -q "Version: 3.10.0" && (grep -q "core.locations" venv/lib/python*/site-packages/aiohttp/web_urldispatcher.py && echo " *** aiohttp already patched" || ( echo "Patching aiohttp 3.10.0 for tests"; patch -tRup0 venv/lib/python*/site-packages/aiohttp/web_urldispatcher.py < patch/aiohttp310.patch && echo " *** aiohttp Patched!" || echo " *** aiohttp patch failed?")) || ( echo " ***"; echo " *** WE CAN REMOVE THE PATCH FOR aiohttp 3.10.0 from $0"; echo " ***" ) set +u diff --git a/tests/INIT.md b/tests/INIT.md index a9c99b84f..089e0d8c9 100644 --- a/tests/INIT.md +++ b/tests/INIT.md @@ -27,7 +27,7 @@ Once the project is ready for upload to test (i.e. version number ending in `a0` Prepare: -- [ ] `python3 -m venv venv ; source venv/bin/activate ; pip install --upgrade pip; pip install -r requirements_test.txt ; pip install --upgrade setuptools wheel twine` +- [ ] `python3 -m venv venv ; source venv/bin/activate ; pip install --upgrade pip; pip install uv; uv pip install -r requirements_test.txt ; uv pip install --upgrade setuptools wheel twine` Package: (**ensure you are in your venv**)