From 7d2acdfcfd92708ecba445673d6128a8ae90de15 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 5 Jul 2021 17:10:47 +0000 Subject: [PATCH] feat: build for release --- README.md | 13 +++---- build.json | 2 +- dist/index.js | 63 ++++++++++++++------------------- integrationtests/test_common.py | 9 ----- 4 files changed, 34 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index d4b2351..cff98aa 100644 --- a/README.md +++ b/README.md @@ -80,15 +80,16 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d - - - - - + + + + + +

Sebastian Weigand

💻 🤔 🚇 🚧 ⚠️ 👀

Santiago Castro

📖

Derrick

📖

Pietro Fumiani

🐛

Doug

🐛

Sebastian Weigand

💻 🤔 🚇 🚧 ⚠️ 👀

Santiago Castro

📖

Derrick

📖

Pietro Fumiani

🐛

Doug

🐛

Filipe

🐛
- + diff --git a/build.json b/build.json index 096840a..99f2faa 100644 --- a/build.json +++ b/build.json @@ -1 +1 @@ -{"owner":"s-weigand","repo":"setup-conda","sha":"33fb1dc02728148e85d1f88a2e02b6e00c521065","ref":"refs/tags/v1.0.6","tagName":"v1.0.6","branch":"release","tags":["v1.0.6","v1"],"updated_at":"2021-06-29T17:10:04.700Z"} \ No newline at end of file +{"owner":"s-weigand","repo":"setup-conda","sha":"705d889b6733b37d5eb3ea2ba8127e1356cb356a","ref":"refs/tags/v1.0.7","tagName":"v1.0.7","branch":"release","tags":["v1.0.7","v1"],"updated_at":"2021-07-05T17:10:47.305Z"} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 579a5c8..f404b35 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1948,13 +1948,34 @@ const addCondaToPath = (config) => __awaiter(void 0, void 0, void 0, function* ( core.endGroup(); }); /** - * Activates the conda base env. + * Parse `conda shell. activate `scripts outputs + * + * @param activationStr Output of the activation script + * @param envExport Prefix to which is used to export an env variable + * @param osPathSep Character to separate path in the PATH variable + * @returns condaPaths + */ +exports.parseActivationScriptOutput = (activationStr, envExport, osPathSep) => __awaiter(void 0, void 0, void 0, function* () { + let condaPaths = []; + const lines = activationStr.split(envExport); + for (const line of lines) { + if (line.startsWith('PATH')) { + const paths = line.replace(/PATH\s?=|'|"|\n|\s/g, '').split(osPathSep); + condaPaths = paths + .filter((path) => path.toLowerCase().indexOf('miniconda') !== -1) + .filter((orig, index, self) => index === self.findIndex((subSetItem) => subSetItem === orig)); + } + } + return condaPaths; +}); +/** + * Activates the conda base env by changing the path and env variables. * * @param config Configuration of the action */ const activate_conda = (config) => __awaiter(void 0, void 0, void 0, function* () { core.startGroup('Activating conda base'); - let envVarsAndCondaPaths; + let condaPaths; let activationStr = ''; const options = { listeners: {} }; options.listeners = { @@ -1965,50 +1986,18 @@ const activate_conda = (config) => __awaiter(void 0, void 0, void 0, function* ( console.log('Conda activate script:'); if (config.os === 'win32') { yield exec.exec('conda', ['shell.powershell', 'activate', 'base'], options); - envVarsAndCondaPaths = exports.parseActivationScriptOutput(activationStr, '$Env:', ';'); + condaPaths = yield exports.parseActivationScriptOutput(activationStr, '$Env:', ';'); } else { yield exec.exec('conda', ['shell.bash', 'activate', 'base'], options); - envVarsAndCondaPaths = exports.parseActivationScriptOutput(activationStr, 'export ', ':'); + condaPaths = yield exports.parseActivationScriptOutput(activationStr, 'export ', ':'); } - const { condaPaths, envVars } = yield envVarsAndCondaPaths; - console.log('\n\nData used for activation:\n', { condaPaths, envVars }); + console.log('\n\nData used for activation:\n', { condaPaths }); for (const condaPath of condaPaths) { sane_add_path(condaPath); } - for (const varName in envVars) { - core.exportVariable(varName, envVars[varName]); - } core.endGroup(); }); -/** - * Parse `conda shell. activate `scripts outputs - * - * @param activationStr Output of the activation script - * @param envExport Prefix to which is used to export an env variable - * @param osPathSep Character to separate path in the PATH variable - * @returns - */ -exports.parseActivationScriptOutput = (activationStr, envExport, osPathSep) => __awaiter(void 0, void 0, void 0, function* () { - let condaPaths = []; - const envVars = {}; - const lines = activationStr.split(envExport); - for (const line of lines) { - if (line.startsWith('PATH')) { - const paths = line.replace(/PATH\s?=|'|"|\n|\s/g, '').split(osPathSep); - condaPaths = paths - .filter((path) => path.toLowerCase().indexOf('miniconda') !== -1) - .filter((orig, index, self) => index === self.findIndex((subSetItem) => subSetItem === orig)); - } - else { - const [varName, varValue] = line.replace(/'|"|\n|\s/g, '').split('='); - if (varValue !== undefined) { - envVars[varName.trim()] = varValue.trim(); - } - } - } - return { condaPaths, envVars }; -}); const get_python_location = () => __awaiter(void 0, void 0, void 0, function* () { core.startGroup('Getting original pythonLocation'); let pythonLocation = ''; diff --git a/integrationtests/test_common.py b/integrationtests/test_common.py index f985e00..1423574 100644 --- a/integrationtests/test_common.py +++ b/integrationtests/test_common.py @@ -22,12 +22,3 @@ def test_conda_channels(): assert returncode == 0 assert channel_list == expected assert stderr == b"" - - -def test_conda_env_vars_set(): - """Conda env_vars are set""" - assert "miniconda" in os.environ["CONDA_PREFIX"].lower() - assert "miniconda" in os.environ["CONDA_EXE"].lower() - assert "miniconda" in os.environ["CONDA_PYTHON_EXE"].lower() - assert os.environ["CONDA_SHLVL"] == "1" - assert os.environ["CONDA_DEFAULT_ENV"] != ""