Skip to content

Commit 8d21185

Browse files
committed
Further checking and warnings
1 parent 4665a6b commit 8d21185

File tree

3 files changed

+54
-7
lines changed

3 files changed

+54
-7
lines changed

requirements_commit.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# Minimal requirements for committing
44
# Versioning omitted (leave this up to HA-core)
55
coverage
6-
flake8-black
6+
flake8-black==0.3.6
77
mypy
88
pre-commit
99
pylint
10-
pylint_strict_informational
10+
pylint_strict_informational==0.1

requirements_test.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Import from setup.py
22
-e .
33
# Versioning omitted (leave this up to HA-core)
4-
pytest-asyncio==0.20.2
4+
pytest-asyncio
55
radon==5.1.0
6-
types-python-dateutil==2.8.19.5
6+
types-python-dateutil

scripts/dependencies_check.sh

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# - For everything *not* in use by HA-core we still would want dependabot to kick in appropriately
88
# - This script will exit with error if it finds 'unversioned' dependencies (as such should be part of our CI)
99

10+
# Default to non-error
11+
exitcode=0
12+
1013
# Use local tmp
1114
if [ ! -d ./tmp ]; then
1215
mkdir -p ./tmp/urls
@@ -27,12 +30,16 @@ packages=$(grep -hEv "^$|^#|^\-e" ./requirements*.txt | cut -f 1 -d '=' | sort -
2730

2831
# Check for local defined packages against upstream
2932
pkglist="./tmp/pkglist"
33+
pkgredundant="./tmp/pkgredundant"
3034
true > "${pkglist}"
35+
true > "${pkgredundant}"
3136
for pkg in ${packages}; do
3237
# shellcheck disable=SC2046,SC2143
3338
if [ ! $(grep -rhE "^${pkg}" ./tmp/urls) ]; then
3439
# echo "${pkg} not in upstream requirements/constraints"
3540
echo "${pkg}" >> "${pkglist}"
41+
else
42+
echo "${pkg}" >> "${pkgredundant}"
3643
fi
3744
done
3845

@@ -48,13 +55,53 @@ for pkg in $(sort -u ${pkglist}); do
4855
fi
4956
done
5057

58+
# Check for versioning in setup.py
59+
pkgpy=$(sed -n '/install_requires=\[/,/\]/p' setup.py | tr -d '\n' | sed 's/^.*\[\(.*\)\].*$/\1/g' | tr -d ',"')
60+
for pkgfull in ${pkgpy}; do
61+
# Very ugly multi-character split
62+
# shellcheck disable=SC3011
63+
pkg=$(cut -d '=' -f 1 <<< "${pkgfull}" | cut -d '<' -f 1 | cut -d '>' -f 1)
64+
# shellcheck disable=SC2046,SC2143
65+
if [ ! $(grep -qrhE "^${pkg}" ./tmp/urls) ]; then
66+
# echo "DEBUG: ${pkg} from setup.py not in upstream requirements/constraints"
67+
if [ ! $(grep -rhE "^${pkg}==" ./requirements*.txt) ]; then
68+
# echo "DEBUG: ${pkg} from setup.py not in local requirements"
69+
# shellcheck disable=SC3014
70+
if [ "${pkg}" == "${pkgfull}" ]; then
71+
echo "WARNING: ${pkg} not in any requirements and no version specified in setup.py"
72+
# else
73+
# echo "DEBUG: ${pkg} version specified in setup.py"
74+
fi
75+
# else
76+
# echo "DEBUG: ${pkg} found in local requirements"
77+
fi
78+
# else
79+
# echo "DEBUG: ${pkg} found in upstream URLs"
80+
fi
81+
done
82+
echo ""
83+
84+
# Print redundant information (no error value)
85+
# shellcheck disable=SC2046
86+
#if [ $(wc -l "${pkgmiss}" | awk '{print $1}') -gt 0 ]; then
87+
echo "INFO: Packages redundant with upstream:"
88+
# shellcheck disable=SC2013
89+
for pkg in $(sort -u ${pkgredundant}); do
90+
echo "INFO: ${pkg} in ($(grep -hlE "^${pkg}" ./requirements*.txt)) already avavilable via $(grep -rhlE "^${pkg}" ./tmp/urls/)"
91+
done
92+
echo ""
93+
#fi
94+
5195
# Print missing information and exit error out
5296
# shellcheck disable=SC2046
5397
if [ $(wc -l "${pkgmiss}" | awk '{print $1}') -gt 0 ]; then
54-
echo "Packages missing from local requirements_*.txt files:"
98+
echo "ERROR: Packages missing from local requirements_*.txt files:"
5599
# shellcheck disable=SC2013
56100
for pkg in $(sort -u ${pkgmiss}); do
57-
echo " ${pkg} in $(grep -hlE "^${pkg}" ./requirements*.txt) missing version information"
101+
echo "INFO: ${pkg} in $(grep -hlE "^${pkg}" ./requirements*.txt) missing version information"
58102
done
59-
exit 1
103+
echo ""
104+
exitcode=1
60105
fi
106+
107+
exit ${exitcode}

0 commit comments

Comments
 (0)