From bd1f875aba1ebb6d38211b773b094ad1dcca58df Mon Sep 17 00:00:00 2001 From: Kevin Stillhammer Date: Sat, 11 Oct 2025 15:17:25 +0200 Subject: [PATCH] Set output venv when activate-environment is used (#627) Closes: #622 --- .github/workflows/test.yml | 14 ++++++++++++++ action.yml | 2 ++ dist/setup/index.js | 8 +++++--- src/setup-uv.ts | 11 +++++------ 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3264ed7..f91bf92 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -334,6 +334,7 @@ jobs: with: persist-credentials: false - name: Install latest version + id: setup-uv uses: ./ with: python-version: 3.13.1t @@ -348,6 +349,19 @@ jobs: exit 1 fi shell: bash + - name: Verify output venv is set + run: | + if [ -z "$UV_VENV" ]; then + echo "output venv is not set" + exit 1 + fi + if [ ! -d "$UV_VENV" ]; then + echo "output venv not point to a directory: $UV_VENV" + exit 1 + fi + shell: bash + env: + UV_VENV: ${{ steps.setup-uv.outputs.venv }} test-musl: runs-on: ubuntu-latest diff --git a/action.yml b/action.yml index 997ecb5..c29a89d 100644 --- a/action.yml +++ b/action.yml @@ -86,6 +86,8 @@ outputs: description: "The path to the installed uvx binary." cache-hit: description: "A boolean value to indicate a cache entry was found" + venv: + description: "Path to the activated venv if activate-environment is true" runs: using: "node24" main: "dist/setup/index.js" diff --git a/dist/setup/index.js b/dist/setup/index.js index f811ffb..11bf112 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -129661,12 +129661,14 @@ async function activateEnvironment() { const execArgs = ["venv", ".venv", "--directory", inputs_1.workingDirectory]; core.info("Activating python venv..."); await exec.exec("uv", execArgs); - let venvBinPath = `${inputs_1.workingDirectory}${path.sep}.venv${path.sep}bin`; + const venvPath = path.resolve(`${inputs_1.workingDirectory}${path.sep}.venv`); + let venvBinPath = `${venvPath}${path.sep}bin`; if (process.platform === "win32") { - venvBinPath = `${inputs_1.workingDirectory}${path.sep}.venv${path.sep}Scripts`; + venvBinPath = `${venvPath}${path.sep}Scripts`; } core.addPath(path.resolve(venvBinPath)); - core.exportVariable("VIRTUAL_ENV", path.resolve(`${inputs_1.workingDirectory}${path.sep}.venv`)); + core.exportVariable("VIRTUAL_ENV", venvPath); + core.setOutput("venv", venvPath); } } function setCacheDir() { diff --git a/src/setup-uv.ts b/src/setup-uv.ts index b47ae19..091da59 100644 --- a/src/setup-uv.ts +++ b/src/setup-uv.ts @@ -213,15 +213,14 @@ async function activateEnvironment(): Promise { core.info("Activating python venv..."); await exec.exec("uv", execArgs); - let venvBinPath = `${workingDirectory}${path.sep}.venv${path.sep}bin`; + const venvPath = path.resolve(`${workingDirectory}${path.sep}.venv`); + let venvBinPath = `${venvPath}${path.sep}bin`; if (process.platform === "win32") { - venvBinPath = `${workingDirectory}${path.sep}.venv${path.sep}Scripts`; + venvBinPath = `${venvPath}${path.sep}Scripts`; } core.addPath(path.resolve(venvBinPath)); - core.exportVariable( - "VIRTUAL_ENV", - path.resolve(`${workingDirectory}${path.sep}.venv`), - ); + core.exportVariable("VIRTUAL_ENV", venvPath); + core.setOutput("venv", venvPath); } }