Skip to content

Commit 292bb7c

Browse files
committed
Parameterize check scripts over requests version
1 parent 1245696 commit 292bb7c

File tree

5 files changed

+61
-63
lines changed

5 files changed

+61
-63
lines changed

.github/workflows/python-deps.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
7373
- name: Verify packages installed
7474
run: |
75-
$GITHUB_WORKSPACE/python-setup/tests/check_requests_2_26_0.sh ${PYTHON_VERSION}
75+
$GITHUB_WORKSPACE/python-setup/tests/check_requests.sh ${PYTHON_VERSION} 2.26.0
7676
7777
# This one shouldn't fail, but also won't install packages
7878
test-setup-python-scripts-non-standard-location:
@@ -170,5 +170,5 @@ jobs:
170170
171171
- name: Verify packages installed
172172
run: |
173-
$cmd = $Env:GITHUB_WORKSPACE + "\\python-setup\\tests\\check_requests_2_26_0.ps1"
174-
powershell -File $cmd $Env:PYTHON_VERSION
173+
$cmd = $Env:GITHUB_WORKSPACE + "\\python-setup\\tests\\check_requests.ps1"
174+
powershell -File $cmd $Env:PYTHON_VERSION 2.26.0

python-setup/tests/check_requests.ps1

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#! /usr/bin/pwsh
2+
3+
$EXPECTED_PYTHON_VERSION=$args[0]
4+
$EXPECTED_REQUESTS_VERSION=$args[1]
5+
6+
$FOUND_PYTHON_VERSION="$Env:LGTM_PYTHON_SETUP_VERSION"
7+
$FOUND_PYTHONPATH="$Env:LGTM_INDEX_IMPORT_PATH"
8+
9+
write-host "FOUND_PYTHON_VERSION=$FOUND_PYTHON_VERSION FOUND_PYTHONPATH=$FOUND_PYTHONPATH "
10+
11+
if ($FOUND_PYTHON_VERSION -ne $EXPECTED_PYTHON_VERSION) {
12+
write-host "Script told us to use Python $FOUND_PYTHON_VERSION, but expected $EXPECTED_PYTHON_VERSION"
13+
exit 1
14+
} else {
15+
write-host "Script told us to use Python $FOUND_PYTHON_VERSION, which was expected"
16+
}
17+
18+
$env:PYTHONPATH=$FOUND_PYTHONPATH
19+
20+
$INSTALLED_REQUESTS_VERSION = (py -3 -c "import requests; print(requests.__version__)")
21+
22+
if ($INSTALLED_REQUESTS_VERSION -ne $EXPECTED_REQUESTS_VERSION) {
23+
write-host "Using $FOUND_PYTHONPATH as PYTHONPATH, we found version $INSTALLED_REQUESTS_VERSION of requests, but expected $EXPECTED_REQUESTS_VERSION"
24+
exit 1
25+
} else {
26+
write-host "Using $FOUND_PYTHONPATH as PYTHONPATH, we found version $INSTALLED_REQUESTS_VERSION of requests, which was expected"
27+
}

python-setup/tests/check_requests.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
6+
7+
EXPECTED_PYTHON_VERSION=$1
8+
EXPECTED_REQUESTS_VERSION=$2
9+
10+
FOUND_PYTHON_VERSION="$LGTM_PYTHON_SETUP_VERSION"
11+
FOUND_PYTHONPATH="$LGTM_INDEX_IMPORT_PATH"
12+
13+
echo "FOUND_PYTHON_VERSION=${FOUND_PYTHON_VERSION} FOUND_PYTHONPATH=${FOUND_PYTHONPATH} "
14+
15+
if [[ $FOUND_PYTHON_VERSION != $EXPECTED_PYTHON_VERSION ]]; then
16+
echo "Script told us to use Python ${FOUND_PYTHON_VERSION}, but expected ${EXPECTED_PYTHON_VERSION}"
17+
exit 1
18+
else
19+
echo "Script told us to use Python ${FOUND_PYTHON_VERSION}, which was expected"
20+
fi
21+
22+
PYTHON_EXE="python${EXPECTED_PYTHON_VERSION}"
23+
24+
INSTALLED_REQUESTS_VERSION=$(PYTHONPATH="${FOUND_PYTHONPATH}" "${PYTHON_EXE}" -c 'import requests; print(requests.__version__)')
25+
26+
if [[ "$INSTALLED_REQUESTS_VERSION" != "$EXPECTED_REQUESTS_VERSION" ]]; then
27+
echo "Using ${FOUND_PYTHONPATH} as PYTHONPATH, we found version $INSTALLED_REQUESTS_VERSION of requests, but expected $EXPECTED_REQUESTS_VERSION"
28+
exit 1
29+
else
30+
echo "Using ${FOUND_PYTHONPATH} as PYTHONPATH, we found version $INSTALLED_REQUESTS_VERSION of requests, which was expected"
31+
fi

python-setup/tests/check_requests_2_26_0.ps1

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

python-setup/tests/check_requests_2_26_0.sh

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

0 commit comments

Comments
 (0)