Skip to content

Commit eaad472

Browse files
committed
Improve reporting and fix finding packages, not partial packages
1 parent ef308e1 commit eaad472

File tree

2 files changed

+32
-31
lines changed

2 files changed

+32
-31
lines changed

.github/workflows/verify.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ jobs:
293293
- name: Check out committed code
294294
uses: actions/checkout@v3
295295
- name: Run dependency checker
296-
run: scripts/dependencies_check.sh
296+
run: scripts/dependencies_check.sh debug
297297

298298
coverage:
299299
name: Process test coverage

scripts/dependencies_check.sh

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,59 @@ if [ ! -d ./tmp ]; then
1515
mkdir -p ./tmp/urls
1616
fi
1717

18-
# Find URLs used
18+
# Debugging
19+
DEBUG=1
20+
if [ "${1}" = "debug" ]; then DEBUG=0; fi
21+
22+
# Simple debugging trigger
23+
debug_output () {
24+
if [ ${DEBUG} -eq 0 ]; then echo "DEBUG: ${1}"; fi
25+
}
26+
27+
debug_output "Finding URLs used for setup"
1928
urls=$(grep -hEo "(http|https)://[a-zA-Z0-9./?=_%:-]*" ./scripts/setup*.sh | sort -u)
2029

21-
# Cache upstream information
30+
debug_output "Caching upstream information"
2231
i=1
2332
for url in ${urls}; do
2433
curl -s "${url}" > ./tmp/urls/${i}
2534
i=$((i+1))
2635
done
2736

28-
# Find local packages
37+
debug_output "Find local package requirements"
2938
packages=$(grep -hEv "^$|^#|^\-e" ./requirements*.txt | cut -f 1 -d '=' | sort -u)
3039

31-
# Check for local defined packages against upstream
40+
debug_output "Check local defined packages against upstream"
3241
pkglist="./tmp/pkglist"
3342
pkgredundant="./tmp/pkgredundant"
3443
true > "${pkglist}"
3544
true > "${pkgredundant}"
3645
for pkg in ${packages}; do
3746
# shellcheck disable=SC2046,SC2143
38-
if [ ! $(grep -rhE "^${pkg}" ./tmp/urls) ]; then
39-
# echo "${pkg} not in upstream requirements/constraints"
47+
if [ ! $(grep -rhE "^${pkg}$|${pkg}[=,.]" ./tmp/urls) ]; then
48+
debug_output "${pkg} not in upstream requirements/constraints"
4049
echo "${pkg}" >> "${pkglist}"
4150
else
51+
debug_output "${pkg} redundant through upstream requirements/constraints as $(grep -rhE "^${pkg}$|${pkg}[=<>]" ./tmp/urls)"
4252
echo "${pkg}" >> "${pkgredundant}"
4353
fi
4454
done
4555

46-
# Check for versioning in local packages
56+
debug_output "Check for versioning in local packages"
4757
pkgmiss="./tmp/pkglist.miss"
4858
true > "${pkgmiss}"
4959
# shellcheck disable=SC2013
5060
for pkg in $(sort -u ${pkglist}); do
5161
# shellcheck disable=SC2046,SC2143
52-
if [ ! $(grep -rhE "^${pkg}==" ./requirements*.txt) ]; then
53-
# echo "${pkg} no versioning defined"
62+
if [ ! $(grep -rhE "^${pkg}$|${pkg}[=<>]" ./requirements*.txt) ]; then
63+
debug_output "${pkg} no versioning defined"
5464
echo "${pkg}" >> "${pkgmiss}"
65+
else
66+
debug_output "${pkg} version locally defined in $(grep -rhE "^${pkg}$|${pkg}[=<>]" ./requirements*.txt)"
5567
fi
5668
done
5769

58-
# Check for versioning in setup.py
70+
debug_output "Check for versioning in setup.py"
5971
pkgpy=$(sed -n '/install_requires=\[/,/\]/p' setup.py | tr -d '\n' | sed 's/^.*\[\(.*\)\].*$/\1/g' | tr -d ',"')
6072
for pkgfull in ${pkgpy}; do
6173
# Very ugly multi-character split
@@ -64,36 +76,25 @@ for pkgfull in ${pkgpy}; do
6476
# Check for package in upstream
6577
# shellcheck disable=SC2046,SC2143
6678
if [ ! $(grep -rhE "^${pkg}$|^${pkg}[=<>]+" ./tmp/urls) ]; then
67-
# echo "DEBUG: ${pkg} from setup.py not in upstream requirements/constraints"
79+
debug_output "${pkg} from setup.py not in upstream requirements/constraints"
6880
# Check for package locally
69-
if [ ! $(grep -rhE "^${pkg}==" ./requirements*.txt) ]; then
70-
# echo "DEBUG: ${pkg} from setup.py not in local requirements"
81+
if [ ! $(grep -rhE "^${pkg}$|${pkg}[=<>]" ./requirements*.txt) ]; then
82+
debug_output "${pkg} from setup.py not in local requirements"
7183
# shellcheck disable=SC3014
7284
if [ "${pkg}" = "${pkgfull}" ]; then
7385
echo "WARNING: ${pkg} not in any requirements and no version specified in setup.py"
74-
# else
75-
# echo "DEBUG: ${pkg} version specified in setup.py"
86+
else
87+
debug_output "${pkg} version specified in setup.py as ${pkgfull}"
7688
fi
77-
# else
78-
# echo "DEBUG: ${pkg} found in local requirements"
89+
else
90+
debug_output "${pkg} found in local requirements as $(grep -rhE "^${pkg}$|${pkg}[=<>]" ./requirements*.txt)"
7991
fi
80-
# else
81-
# echo "DEBUG: ${pkg} found in upstream URLs"
92+
else
93+
debug_output "${pkg} found in upstream URLs as $(grep -rhE "^${pkg}$|^${pkg}[=<>]+" ./tmp/urls)"
8294
fi
8395
done
8496
echo ""
8597

86-
# Print redundant information (no error value)
87-
# shellcheck disable=SC2046
88-
#if [ $(wc -l "${pkgmiss}" | awk '{print $1}') -gt 0 ]; then
89-
# echo "INFO: Packages redundant with upstream:"
90-
# # shellcheck disable=SC2013
91-
# for pkg in $(sort -u ${pkgredundant}); do
92-
# echo "INFO: ${pkg} in ($(grep -hlE "^${pkg}" ./requirements*.txt)) already available via upstream"
93-
# done
94-
# echo ""
95-
#fi
96-
9798
# Print missing information and exit error out
9899
# shellcheck disable=SC2046
99100
if [ $(wc -l "${pkgmiss}" | awk '{print $1}') -gt 0 ]; then

0 commit comments

Comments
 (0)