Skip to content

Commit

Permalink
Use default name unless not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
goanpeca committed Jul 5, 2020
1 parent 03cf563 commit 6308a80
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/example-3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 11 additions & 2 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand All @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions etc/example-environment-no-name.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies:
- black
- anaconda-client
14 changes: 12 additions & 2 deletions src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"] || "",
Expand All @@ -843,21 +844,30 @@ 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 &&
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 = await condaCommand(
`env ${condaAction} -f ${environmentFile}`,
`env ${condaAction} --file ${environmentFile} --name ${activateEnvironmentToUse}`,
useBundled,
useMamba
);
Expand Down

0 comments on commit 6308a80

Please sign in to comment.