Skip to content

Commit b7fd193

Browse files
committed
add installed env paths to virtual environment
1 parent ad24770 commit b7fd193

2 files changed

Lines changed: 29 additions & 24 deletions

File tree

.github/workflows/test-python-setup-uv.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ jobs:
4141
python --version
4242
uv --version
4343
uv pip list
44-
# Activate venv (cross-platform)
45-
if [ -f .venv/bin/activate ]; then
46-
source .venv/bin/activate
47-
else
48-
source .venv/Scripts/activate
49-
fi
5044
# Verify core dependency is installed
5145
python -c "import requests; print('[OK] Core dependency installed')"
5246
# Verify dev group is NOT installed (default is now empty)
@@ -91,12 +85,6 @@ jobs:
9185
shell: bash
9286
run: |
9387
uv pip list
94-
# Activate venv (cross-platform)
95-
if [ -f .venv/bin/activate ]; then
96-
source .venv/bin/activate
97-
else
98-
source .venv/Scripts/activate
99-
fi
10088
# Verify test and docs groups are installed
10189
python -c "import pytest_cov; import pytest_mock; print('[OK] Test dependencies installed')"
10290
python -c "import mkdocs; print('[OK] Docs dependencies installed')"
@@ -140,12 +128,6 @@ jobs:
140128
shell: bash
141129
run: |
142130
uv pip list
143-
# Activate venv (cross-platform)
144-
if [ -f .venv/bin/activate ]; then
145-
source .venv/bin/activate
146-
else
147-
source .venv/Scripts/activate
148-
fi
149131
# Verify core dependency is installed
150132
python -c "import requests; print('[OK] Core dependency installed')"
151133
# Verify dev group is NOT installed
@@ -219,8 +201,6 @@ jobs:
219201
shell: bash
220202
run: |
221203
uv pip list
222-
# Activate venv (cross-platform)
223-
if [ -f .venv/bin/activate ]; then source .venv/bin/activate; else source .venv/Scripts/activate; fi
224204
python -c "import requests; print('[OK] Dependencies installed without lock verification')"
225205
226206
test-uv-lock-verification-fail:

actions/python-setup/uv/action.yml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,32 @@ runs:
7272
uv sync "${args[@]}"
7373
echo "::endgroup::"
7474
75+
- name: Activate virtual environment
76+
shell: bash
77+
run: |
78+
echo "::group::Activating virtual environment"
79+
# Determine the correct bin/Scripts directory
80+
if [ -f .venv/bin/python ]; then
81+
VENV_BIN="$(pwd)/.venv/bin"
82+
echo "Adding to PATH: $VENV_BIN"
83+
echo "$VENV_BIN" >> $GITHUB_PATH
84+
echo "VIRTUAL_ENV=$(pwd)/.venv" >> $GITHUB_ENV
85+
elif [ -f .venv/Scripts/python.exe ]; then
86+
VENV_SCRIPTS="$(pwd)/.venv/Scripts"
87+
echo "Adding to PATH: $VENV_SCRIPTS"
88+
echo "$VENV_SCRIPTS" >> $GITHUB_PATH
89+
echo "VIRTUAL_ENV=$(pwd)/.venv" >> $GITHUB_ENV
90+
else
91+
echo "::warning::No virtual environment found at .venv"
92+
fi
93+
echo "::endgroup::"
94+
7595
- name: Show environment information
7696
shell: bash
7797
run: |
7898
echo "::group::Environment information"
99+
echo "Virtual environment: ACTIVATED"
100+
echo ""
79101
echo "Virtual environment location:"
80102
if [ -d .venv ]; then
81103
echo " $(pwd)/.venv"
@@ -87,16 +109,19 @@ runs:
87109
echo " $(pwd)/.venv/Scripts/python.exe"
88110
fi
89111
echo ""
90-
echo "Activation command (Linux/macOS):"
91-
echo " source .venv/bin/activate"
112+
echo "The virtual environment has been automatically activated."
113+
echo "You can now use 'python' and installed CLI tools directly in subsequent steps."
92114
echo ""
93-
echo "Activation command (Windows):"
94-
echo " source .venv/Scripts/activate"
115+
echo "Example usage:"
116+
echo " - run: python --version"
117+
echo " - run: pytest"
118+
echo " - run: black ."
95119
else
96120
echo " No .venv directory found"
97121
fi
98122
echo "::endgroup::"
99123
100124
echo "::group::Installed packages summary"
125+
python --version
101126
uv pip list
102127
echo "::endgroup::"

0 commit comments

Comments
 (0)