diff --git a/.github/workflows/example-3.yml b/.github/workflows/example-3.yml index cbdecc6b..bf93bd87 100644 --- a/.github/workflows/example-3.yml +++ b/.github/workflows/example-3.yml @@ -27,3 +27,23 @@ jobs: conda info conda list printenv | sort + + + example-3-no-name: + name: Ex3-no-name Linux + runs-on: 'ubuntu-latest' + steps: + - uses: actions/checkout@v2 + - uses: ./ + with: + activate-environment: anaconda-client-env + environment-file: etc/example-environment-no-name.yml + python-version: 3.8 + condarc-file: etc/example-condarc.yml + auto-activate-base: false + auto-update-conda: true + - shell: bash -l {0} + run: | + conda info + conda list + printenv | sort diff --git a/dist/setup/index.js b/dist/setup/index.js index 342e4672..f0637086 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -21947,6 +21947,7 @@ function setupMiniconda(installerUrl, minicondaVersion, architecture, condaVersi if (environmentFile) { let environmentYaml; let condaAction; + let activateEnvironmentToUse; try { const sourceEnvironmentPath = path.join(process.env["GITHUB_WORKSPACE"] || "", environmentFile); environmentYaml = yield yaml.safeLoad(fs.readFileSync(sourceEnvironmentPath, "utf8")); @@ -21958,18 +21959,26 @@ function setupMiniconda(installerUrl, minicondaVersion, architecture, condaVersi environmentYaml["name"] !== undefined && environmentYaml["name"] !== activateEnvironment) { condaAction = "create"; + activateEnvironmentToUse = environmentYaml["name"]; utils.consoleLog(`Creating conda environment from yaml file...`); - core.warning('The environment name on "environment-file" is not the same as "enviroment-activate"!'); + core.warning('The environment name on "environment-file" is not the same as "enviroment-activate", using "environment-file"!'); } else if (activateEnvironment && activateEnvironment === environmentYaml["name"]) { utils.consoleLog(`Updating conda environment from yaml file...`); condaAction = "update"; + activateEnvironmentToUse = activateEnvironment; + } + else if (activateEnvironment && environmentYaml["name"] === undefined) { + core.warning('The environment name on "environment-file" is not defined, using "enviroment-activate"!'); + condaAction = "update"; + activateEnvironmentToUse = activateEnvironment; } else { + activateEnvironmentToUse = activateEnvironment; condaAction = "create"; } - result = yield condaCommand(`env ${condaAction} -f ${environmentFile}`, useBundled, useMamba); + result = yield condaCommand(`env ${condaAction} --file ${environmentFile} --name ${activateEnvironmentToUse}`, useBundled, useMamba); if (!result.ok) return result; } diff --git a/etc/example-environment-no-name.yml b/etc/example-environment-no-name.yml new file mode 100644 index 00000000..227056d9 --- /dev/null +++ b/etc/example-environment-no-name.yml @@ -0,0 +1,3 @@ +dependencies: + - black + - anaconda-client diff --git a/src/setup.ts b/src/setup.ts index bdbb8b3a..a3eebcfb 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -826,6 +826,7 @@ async function setupMiniconda( if (environmentFile) { let environmentYaml: TEnvironment; let condaAction: string; + let activateEnvironmentToUse: string; try { const sourceEnvironmentPath: string = path.join( process.env["GITHUB_WORKSPACE"] || "", @@ -843,9 +844,10 @@ async function setupMiniconda( environmentYaml["name"] !== activateEnvironment ) { condaAction = "create"; + activateEnvironmentToUse = environmentYaml["name"]; utils.consoleLog(`Creating conda environment from yaml file...`); core.warning( - 'The environment name on "environment-file" is not the same as "enviroment-activate"!' + 'The environment name on "environment-file" is not the same as "enviroment-activate", using "environment-file"!' ); } else if ( activateEnvironment && @@ -853,11 +855,19 @@ async function setupMiniconda( ) { utils.consoleLog(`Updating conda environment from yaml file...`); condaAction = "update"; + activateEnvironmentToUse = activateEnvironment; + } else if (activateEnvironment && environmentYaml["name"] === undefined) { + core.warning( + 'The environment name on "environment-file" is not defined, using "enviroment-activate"!' + ); + condaAction = "update"; + activateEnvironmentToUse = activateEnvironment; } else { + activateEnvironmentToUse = activateEnvironment; condaAction = "create"; } result = await condaCommand( - `env ${condaAction} -f ${environmentFile}`, + `env ${condaAction} --file ${environmentFile} --name ${activateEnvironmentToUse}`, useBundled, useMamba );