Skip to content

Commit bd1f875

Browse files
authored
Set output venv when activate-environment is used (#627)
Closes: #622
1 parent 1a91c38 commit bd1f875

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

.github/workflows/test.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ jobs:
334334
with:
335335
persist-credentials: false
336336
- name: Install latest version
337+
id: setup-uv
337338
uses: ./
338339
with:
339340
python-version: 3.13.1t
@@ -348,6 +349,19 @@ jobs:
348349
exit 1
349350
fi
350351
shell: bash
352+
- name: Verify output venv is set
353+
run: |
354+
if [ -z "$UV_VENV" ]; then
355+
echo "output venv is not set"
356+
exit 1
357+
fi
358+
if [ ! -d "$UV_VENV" ]; then
359+
echo "output venv not point to a directory: $UV_VENV"
360+
exit 1
361+
fi
362+
shell: bash
363+
env:
364+
UV_VENV: ${{ steps.setup-uv.outputs.venv }}
351365

352366
test-musl:
353367
runs-on: ubuntu-latest

action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ outputs:
8686
description: "The path to the installed uvx binary."
8787
cache-hit:
8888
description: "A boolean value to indicate a cache entry was found"
89+
venv:
90+
description: "Path to the activated venv if activate-environment is true"
8991
runs:
9092
using: "node24"
9193
main: "dist/setup/index.js"

dist/setup/index.js

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/setup-uv.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,14 @@ async function activateEnvironment(): Promise<void> {
213213
core.info("Activating python venv...");
214214
await exec.exec("uv", execArgs);
215215

216-
let venvBinPath = `${workingDirectory}${path.sep}.venv${path.sep}bin`;
216+
const venvPath = path.resolve(`${workingDirectory}${path.sep}.venv`);
217+
let venvBinPath = `${venvPath}${path.sep}bin`;
217218
if (process.platform === "win32") {
218-
venvBinPath = `${workingDirectory}${path.sep}.venv${path.sep}Scripts`;
219+
venvBinPath = `${venvPath}${path.sep}Scripts`;
219220
}
220221
core.addPath(path.resolve(venvBinPath));
221-
core.exportVariable(
222-
"VIRTUAL_ENV",
223-
path.resolve(`${workingDirectory}${path.sep}.venv`),
224-
);
222+
core.exportVariable("VIRTUAL_ENV", venvPath);
223+
core.setOutput("venv", venvPath);
225224
}
226225
}
227226

0 commit comments

Comments
 (0)