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

Try to catch EnvironmentSectionNotValid #94

Merged
merged 2 commits into from
Nov 16, 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
39 changes: 39 additions & 0 deletions .github/workflows/example-8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "Example 8: this should fail"

on:
pull_request:
branches:
- "*"
push:
branches:
- "master"

jobs:
example-1:
name: Ex1 (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.7", "2.7"]
steps:
- uses: actions/checkout@v2
- uses: ./
id: setup-miniconda
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
environment-file: etc/example-faulty-environment.yml
- name: Check previous step failed
shell: bash
run: ${{ steps.setup-miniconda.conclusion == "failure" }}
- name: Conda info
shell: bash -l {0}
run: conda info
- name: Conda list
shell: pwsh
run: conda list
- name: Environment
shell: bash -l {0}
run: printenv | sort
4 changes: 4 additions & 0 deletions etc/example-faulty-environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: anaconda-client-env
requirements:
- black
- anaconda-client
20 changes: 20 additions & 0 deletions src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ const IGNORED_WARNINGS = [
`Key 'use_only_tar_bz2' is not a known primitive parameter.`,
];

/**
* warnings that should be errors
*/
const FORCED_ERRORS = [
// conda env create will ignore invalid sections and move on
`EnvironmentSectionNotValid`,
];

/**
* avoid spurious conda warnings before we have a chance to update them
*/
Expand All @@ -93,6 +101,18 @@ async function execute(command: string): Promise<Result> {
let options: exec.ExecOptions = {
errStream: new stream.Writable(),
listeners: {
stdout: (data: Buffer) => {
const stringData = data.toString();
for (const forced_error of FORCED_ERRORS) {
if (stringData.includes(forced_error)) {
return {
ok: false,
error: new Error(`"${command}" failed with "${forced_error}"`),
};
}
}
return data;
},
stderr: (data: Buffer) => {
const stringData = data.toString();
for (const ignore of IGNORED_WARNINGS) {
Expand Down