Skip to content

Commit

Permalink
Merge pull request #94 from jaimergp/invalid-env-syntax-errors
Browse files Browse the repository at this point in the history
Try to catch EnvironmentSectionNotValid
  • Loading branch information
goanpeca authored Nov 16, 2020
2 parents 11ae174 + 0b56815 commit 3a687cc
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
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

0 comments on commit 3a687cc

Please sign in to comment.