Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Use default name unless not provided #53

Merged
merged 1 commit into from
Jul 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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