Skip to content

Commit 137a6d1

Browse files
committed
remove ha-core checkout and stuff use uv for checkout move test out of custom components
1 parent a6c4579 commit 137a6d1

File tree

15 files changed

+226
-361
lines changed

15 files changed

+226
-361
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -79,32 +79,10 @@ repos:
7979
files: ^(custom_components|tests)/.+\.py$
8080
- repo: local
8181
hooks:
82-
- id: test-core-prep
83-
# yamllint disable-line rule:line-length
84-
name: "Home Assistant Core Testing - Cloning/updating HA core#dev - patience!"
85-
# yamllint disable-line rule:line-length
86-
entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" scripts/core-testing.sh core_prep'
87-
language: script
88-
pass_filenames: false
89-
- id: test-pip-prep
90-
# yamllint disable-line rule:line-length
91-
name: "Home Assistant Core Testing - Installing dependencies - patience!"
92-
# yamllint disable-line rule:line-length
93-
entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" scripts/core-testing.sh pip_prep'
94-
language: script
95-
pass_filenames: false
9682
- id: testing
83+
name: "Local Testing - Performing Tests"
9784
# yamllint disable-line rule:line-length
98-
name: "Home Assistant Core Testing - Performing Tests"
99-
# yamllint disable-line rule:line-length
100-
entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" scripts/core-testing.sh testing'
101-
language: script
102-
pass_filenames: false
103-
- id: quality
104-
# yamllint disable-line rule:line-length
105-
name: "Home Assistant Core Testing - Quality checks - might need patience"
106-
# yamllint disable-line rule:line-length
107-
entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" scripts/core-testing.sh quality'
85+
entry: /usr/bin/env bash -c 'exec env GITHUB_ACTIONS="1" scripts/tests_and_coverage.sh test_and_coverage'
10886
language: script
10987
pass_filenames: false
11088
- repo: https://github.com/igorshubovych/markdownlint-cli

pyproject.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,14 @@ combine-as-imports = true
214214
[tool.ruff.lint.mccabe]
215215
max-complexity = 25
216216

217+
[tool.pytest]
218+
addopts = [
219+
"--auto",
220+
"--cov=custom_components"
221+
]
222+
223+
[tool.pytest.ini_options]
224+
testpaths = "tests"
225+
norecursedirs = ".git"
226+
asyncio_mode = "auto"
227+
log_cli = true

requirements_commit.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
-r requirements_test.txt
12
pre-commit
3+
ruff

requirements_test.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pytest
2+
pytest-cov
3+
pytest-asyncio
4+
pytest-homeassistant-custom-component
5+
# From our manifest.json for our custom component
6+
plugwise_usb @ https://test-files.pythonhosted.org/packages/90/5f/9cdaa7c322da4987c3820b54eacebad2911b6e7a06550c56b7921944ee90/plugwise_usb-0.40.0a21.tar.gz#plugwise-usb==0.40.0a21

scripts/core-testing.sh

Lines changed: 0 additions & 269 deletions
This file was deleted.

scripts/python-venv.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@ set -eu
33

44
pyversions=(3.12)
55
my_path=$(git rev-parse --show-toplevel)
6-
my_venv=${my_path}/venv
6+
my_venv=${my_path}/.venv
77

88
# Ensures a python virtualenv is available at the highest available python3 version
99
for pv in "${pyversions[@]}"; do
1010
if [ "$(which "python$pv")" ]; then
1111
# If not (yet) available instantiate python virtualenv
1212
if [ ! -d "${my_venv}" ]; then
1313
"python${pv}" -m pip install pip uv || pip install uv
14-
uv venv -p "${pv}" "${my_venv}"
14+
uv venv -p "${pv}" --seed
15+
uv pip install uv
1516
# shellcheck disable=SC1091
1617
. "${my_venv}/bin/activate"
17-
# Ensure wheel is installed (preventing local issues)
18-
uv pip install wheel
1918
break
2019
fi
2120
fi

scripts/setup.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ if [ -f "${my_venv}/bin/activate" ]; then
1111
# shellcheck disable=SC1091
1212
. "${my_venv}/bin/activate"
1313
# Install commit requirements
14-
python3 -m ensurepip --upgrade
15-
pip install uv
16-
uv pip install wheel
1714
uv pip install --upgrade -r requirements_commit.txt
1815
# Install pre-commit hook
1916
"${my_venv}/bin/pre-commit" install

scripts/setup_test.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
my_path=$(git rev-parse --show-toplevel)
5+
6+
# shellcheck disable=SC1091
7+
. "${my_path}/scripts/python-venv.sh"
8+
9+
# shellcheck disable=SC2154
10+
if [ -f "${my_venv}/bin/activate" ]; then
11+
# shellcheck disable=SC1091
12+
. "${my_venv}/bin/activate"
13+
# Install test requirements
14+
pip install uv
15+
uv pip install --upgrade -e . -r requirements_test.txt
16+
# Install pre-commit hook
17+
"${my_venv}/bin/pre-commit" install
18+
else
19+
echo "Virtualenv available, bailing out"
20+
exit 2
21+
fi

0 commit comments

Comments
 (0)