File tree Expand file tree Collapse file tree 5 files changed +106
-2
lines changed
pip_root_venv_detection_2 Expand file tree Collapse file tree 5 files changed +106
-2
lines changed Original file line number Diff line number Diff line change 1+ # README
2+
3+ ## Origin
4+
5+ Origin of this test was a comment by Arne:
6+ < https://github.com/green-coding-solutions/green-metrics-tool/pull/1297#issuecomment-3302240294 >
7+
8+ This is my Dockerfile:
9+
10+ ``` dockerfile
11+ FROM greencoding/gcb_playwright:v20
12+
13+ RUN cd /root && \
14+ python3 -m virtualenv venv && \
15+ /root/venv/bin/pip install psutils
16+
17+ CMD ["tail" , "-f" , "/dev/null" ]
18+ ```
19+
20+ psutils is not found
21+
22+ ## Test
23+
24+ The test script validates that the issue was resolved.
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3- # Build Playwright container and verify psutils is detected in /root/venv/ by dependency_resolver
3+ # Build container and verify psutils is detected in /root/venv/ by dependency_resolver
44
55set -e
66
77SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
88DOCKERFILE_PATH=" $SCRIPT_DIR "
99DEPENDENCY_RESOLVER_PATH=" $SCRIPT_DIR /../../.."
10- CONTAINER_NAME=" test-playwright -$( date +%s) "
10+ CONTAINER_NAME=" test-pip-root-venv-detection -$( date +%s) "
1111
1212echo " Building Docker image from $DOCKERFILE_PATH ..."
1313docker build -t " $CONTAINER_NAME " -f " $DOCKERFILE_PATH /Dockerfile" " $DOCKERFILE_PATH "
Original file line number Diff line number Diff line change 1+ FROM greencoding/gcb_playwright:v20
2+
3+ RUN cd /root && \
4+ python3 -m virtualenv venv && \
5+ /root/venv/bin/pip install psutils
6+
7+ RUN rm /usr/bin/apt
8+ RUN rm /usr/bin/dpkg
9+ RUN rm /usr/bin/dpkg-query
10+ RUN rm /usr/bin/python3
11+
12+ CMD ["tail" , "-f" , "/dev/null" ]
Original file line number Diff line number Diff line change 1+ # README
2+
3+ ## Origin
4+
5+ Origin of this test was a comment by Arne:
6+ < https://github.com/green-coding-solutions/green-metrics-tool/pull/1297#issuecomment-3302325317 >
7+
8+ My Dockerfile:
9+
10+ ``` dockerfile
11+ FROM greencoding/gcb_playwright:v20
12+
13+ RUN cd /root && \
14+ python3 -m virtualenv venv && \
15+ /root/venv/bin/pip install psutils
16+
17+ RUN rm /usr/bin/apt
18+ RUN rm /usr/bin/dpkg
19+ RUN rm /usr/bin/dpkg-query
20+ RUN rm /usr/bin/python3
21+
22+ CMD ["tail" , "-f" , "/dev/null" ]
23+ ```
24+
25+ Our tool finds nothing.
26+
27+ ## Test
28+
29+ The test fails. The dependency resolver can't resolve the dependencies, because pip can't be executed:
30+
31+ ``` sh
32+ /usr/local/bin/pip: cannot execute: required file not found
33+ ```
34+
35+ pip is missing python3.
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Build container and verify psutils is detected in /root/venv/ by dependency_resolver
4+
5+ set -e
6+
7+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
8+ DOCKERFILE_PATH=" $SCRIPT_DIR "
9+ DEPENDENCY_RESOLVER_PATH=" $SCRIPT_DIR /../../.."
10+ CONTAINER_NAME=" test-pip-root-venv-detection-2-$( date +%s) "
11+
12+ echo " Building Docker image from $DOCKERFILE_PATH ..."
13+ docker build -t " $CONTAINER_NAME " -f " $DOCKERFILE_PATH /Dockerfile" " $DOCKERFILE_PATH "
14+
15+ echo " Starting container..."
16+ docker run --rm -d --name " $CONTAINER_NAME " " $CONTAINER_NAME "
17+
18+ echo " Running dependency_resolver on container $CONTAINER_NAME ..."
19+ cd " $DEPENDENCY_RESOLVER_PATH "
20+ source venv/bin/activate
21+
22+ echo " Checking for psutils in output..."
23+ if python3 -m dependency_resolver docker " $CONTAINER_NAME " | grep -q " psutils" ; then
24+ echo " ✓ psutils found in dependency output"
25+ else
26+ echo " ✗ psutils NOT found in dependency output"
27+ fi
28+
29+ echo " Cleaning up..."
30+ docker stop " $CONTAINER_NAME "
31+ docker rmi " $CONTAINER_NAME "
32+
33+ echo " Test complete!"
You can’t perform that action at this time.
0 commit comments