From 7a3e23bd46eb5ea85f3ece1b13e8ece76364da3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Rodr=C3=ADguez-Guerra?= Date: Mon, 16 Nov 2020 16:36:39 +0100 Subject: [PATCH 1/2] Try to catch EnvironmentSectionNotValid --- src/setup.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/setup.ts b/src/setup.ts index 7e1e2fc9..cc0959ee 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -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 */ @@ -93,6 +101,18 @@ async function execute(command: string): Promise { 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) { From 0b56815a1d79e26634522d22983dd7515a5ffff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Rodr=C3=ADguez-Guerra?= Date: Mon, 16 Nov 2020 20:01:13 +0100 Subject: [PATCH 2/2] add failing test --- .github/workflows/example-8.yml | 39 ++++++++++++++++++++++++++++++ etc/example-faulty-environment.yml | 4 +++ 2 files changed, 43 insertions(+) create mode 100644 .github/workflows/example-8.yml create mode 100644 etc/example-faulty-environment.yml diff --git a/.github/workflows/example-8.yml b/.github/workflows/example-8.yml new file mode 100644 index 00000000..7939c9f8 --- /dev/null +++ b/.github/workflows/example-8.yml @@ -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 diff --git a/etc/example-faulty-environment.yml b/etc/example-faulty-environment.yml new file mode 100644 index 00000000..dac7e8b5 --- /dev/null +++ b/etc/example-faulty-environment.yml @@ -0,0 +1,4 @@ +name: anaconda-client-env +requirements: + - black + - anaconda-client