From 12cadb7bc5d94669cafd162e1a0edb6bc9de3c9b Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Mon, 23 Nov 2020 13:36:32 -0700 Subject: [PATCH 1/8] Set artifcats availability status --- .github/workflows/upstream-dev-ci.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/upstream-dev-ci.yaml b/.github/workflows/upstream-dev-ci.yaml index f14e896fd6d..4ce0a5e6f7c 100644 --- a/.github/workflows/upstream-dev-ci.yaml +++ b/.github/workflows/upstream-dev-ci.yaml @@ -21,6 +21,8 @@ jobs: fail-fast: false matrix: python-version: ["3.8"] + outputs: + artifacts_availability: ${{ steps.status.outputs.ARTIFACTS_AVAILABLE }} steps: - name: Cancel previous runs uses: styfle/cancel-workflow-action@0.6.0 @@ -43,6 +45,11 @@ jobs: run: | set -o pipefail python -m pytest -rf | tee output-${{ matrix.python-version }}-log + - name: Set availability status of logs + if: failure() + run: | + echo '::set-output name=ARTIFACTS_AVAILABLE::true' + exit 1 - name: Upload artifacts if: "failure()&&(github.event_name == 'schedule')&&(github.repository == 'pydata/xarray')" # Check the exit code of previous step @@ -55,7 +62,7 @@ jobs: report: name: report needs: upstream-dev - if: "always()&&(github.event_name == 'schedule')&&(github.repository == 'pydata/xarray')" + if: "always()&&(github.event_name == 'schedule')&&(github.repository == 'pydata/xarray')&&(needs.upstream-dev.outputs.artifacts_availability =='true')" runs-on: ubuntu-latest defaults: run: From bbbc63f923206d115d3a54887e349d1999cd0b43 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Mon, 23 Nov 2020 13:47:00 -0700 Subject: [PATCH 2/8] Fix bug during issue creation/update --- .github/workflows/upstream-dev-ci.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/upstream-dev-ci.yaml b/.github/workflows/upstream-dev-ci.yaml index 4ce0a5e6f7c..b87de6f60c5 100644 --- a/.github/workflows/upstream-dev-ci.yaml +++ b/.github/workflows/upstream-dev-ci.yaml @@ -115,11 +115,10 @@ jobs: creator: "github-actions[bot]" } const result = await github.graphql(query, variables) - const issue_info = result.repository.issues.edges[0].node - // If no issue is open, create a new issue, else update the - // body of the existing issue. - if (typeof issue_info.number === 'undefined') { + // If no issue is open, create a new issue, + // else update the body of the existing issue. + if (result.repository.issues.edges.length === 0) { github.issues.create({ owner: variables.owner, repo: variables.name, @@ -131,7 +130,7 @@ jobs: github.issues.update({ owner: variables.owner, repo: variables.name, - issue_number: issue_info.number, + issue_number: result.repository.issues.edges[0].node.number, body: issue_body }) } From c4c762da3bb5c30a134d5bda49044ca6ef7a9540 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Mon, 23 Nov 2020 15:18:24 -0700 Subject: [PATCH 3/8] write if condition on multiple lines --- .github/workflows/upstream-dev-ci.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/upstream-dev-ci.yaml b/.github/workflows/upstream-dev-ci.yaml index b87de6f60c5..7613d6807a3 100644 --- a/.github/workflows/upstream-dev-ci.yaml +++ b/.github/workflows/upstream-dev-ci.yaml @@ -62,7 +62,11 @@ jobs: report: name: report needs: upstream-dev - if: "always()&&(github.event_name == 'schedule')&&(github.repository == 'pydata/xarray')&&(needs.upstream-dev.outputs.artifacts_availability =='true')" + if: | + always() && + github.event_name == 'schedule' && + github.repository == 'pydata/xarray' && + needs.upstream-dev.outputs.artifacts_availability =='true' runs-on: ubuntu-latest defaults: run: From 7fd0b52e37f45a6d960dd83052d432d0e9c9ed83 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Wed, 2 Dec 2020 13:10:00 -0700 Subject: [PATCH 4/8] Enforce channel priority. Thank you, @mathause --- .github/workflows/upstream-dev-ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upstream-dev-ci.yaml b/.github/workflows/upstream-dev-ci.yaml index efe047e1ae5..6197b26fe47 100644 --- a/.github/workflows/upstream-dev-ci.yaml +++ b/.github/workflows/upstream-dev-ci.yaml @@ -38,7 +38,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Set up conda environment run: | - mamba env update -f ci/requirements/py38.yml + mamba env update --override-channels -c conda-forge -f ci/requirements/py38.yml bash ci/install-upstream-wheels.sh conda list - name: Run Tests From df9ea23051d36b4469be402d60b93a134a112e08 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Wed, 2 Dec 2020 13:16:10 -0700 Subject: [PATCH 5/8] Set channel priority to `strict` --- .github/workflows/upstream-dev-ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/upstream-dev-ci.yaml b/.github/workflows/upstream-dev-ci.yaml index 6197b26fe47..a2b65634812 100644 --- a/.github/workflows/upstream-dev-ci.yaml +++ b/.github/workflows/upstream-dev-ci.yaml @@ -32,13 +32,14 @@ jobs: - uses: conda-incubator/setup-miniconda@v2 with: channels: conda-forge + channel-priority: strict mamba-version: "*" activate-environment: xarray-tests auto-update-conda: false python-version: ${{ matrix.python-version }} - name: Set up conda environment run: | - mamba env update --override-channels -c conda-forge -f ci/requirements/py38.yml + mamba env update -f ci/requirements/py38.yml bash ci/install-upstream-wheels.sh conda list - name: Run Tests From 2aa0f8895c6ed014e82298986836d2c9e4d6d870 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Wed, 2 Dec 2020 14:15:52 -0700 Subject: [PATCH 6/8] multi-line conditional expressions --- .github/workflows/upstream-dev-ci.yaml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/upstream-dev-ci.yaml b/.github/workflows/upstream-dev-ci.yaml index a2b65634812..52a00cd57c5 100644 --- a/.github/workflows/upstream-dev-ci.yaml +++ b/.github/workflows/upstream-dev-ci.yaml @@ -53,7 +53,10 @@ jobs: exit 1 - name: Upload artifacts - if: "failure()&&(github.event_name == 'schedule')&&(github.repository == 'pydata/xarray')" # Check the exit code of previous step + if: | + failure() + && github.event_name == 'schedule' + && github.repository == 'pydata/xarray' uses: actions/upload-artifact@v2 with: name: output-${{ matrix.python-version }}-log @@ -64,10 +67,10 @@ jobs: name: report needs: upstream-dev if: | - always() && - github.event_name == 'schedule' && - github.repository == 'pydata/xarray' && - needs.upstream-dev.outputs.artifacts_availability =='true' + always() + && github.event_name == 'schedule' + && github.repository == 'pydata/xarray' + && needs.upstream-dev.outputs.artifacts_availability =='true' runs-on: ubuntu-latest defaults: run: @@ -98,7 +101,7 @@ jobs: const title = "⚠️ Nightly upstream-dev CI failed ⚠️" const workflow_url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}` const issue_body = `[Workflow Run URL](${workflow_url})\n${pytest_logs}` - + // Run GraphQL query against GitHub API to find the most recent open issue used for reporting failures const query = `query($owner:String!, $name:String!, $creator:String!, $label:String!){ repository(owner: $owner, name: $name) { From 624685ca17deb8a422a6e502ad0953332daefb52 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Wed, 2 Dec 2020 14:33:03 -0700 Subject: [PATCH 7/8] Remove unnecessary step per @keewis recommendation --- .github/workflows/upstream-dev-ci.yaml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/upstream-dev-ci.yaml b/.github/workflows/upstream-dev-ci.yaml index 52a00cd57c5..9c2f16e4e13 100644 --- a/.github/workflows/upstream-dev-ci.yaml +++ b/.github/workflows/upstream-dev-ci.yaml @@ -43,15 +43,12 @@ jobs: bash ci/install-upstream-wheels.sh conda list - name: Run Tests + id: status run: | - set -o pipefail - python -m pytest -rf | tee output-${{ matrix.python-version }}-log - - name: Set availability status of logs - if: failure() - run: | - echo '::set-output name=ARTIFACTS_AVAILABLE::true' - exit 1 - + set -euo pipefail + python -m pytest -rf | tee output-${{ matrix.python-version }}-log || ( + echo '::set-output name=ARTIFACTS_AVAILABLE::true' && false + ) - name: Upload artifacts if: | failure() From e7219c1e6fb17e85a88ae580a324c7917ea211dc Mon Sep 17 00:00:00 2001 From: keewis Date: Fri, 4 Dec 2020 23:06:56 +0100 Subject: [PATCH 8/8] Update .github/workflows/upstream-dev-ci.yaml --- .github/workflows/upstream-dev-ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upstream-dev-ci.yaml b/.github/workflows/upstream-dev-ci.yaml index 9c2f16e4e13..6e14964592e 100644 --- a/.github/workflows/upstream-dev-ci.yaml +++ b/.github/workflows/upstream-dev-ci.yaml @@ -67,7 +67,7 @@ jobs: always() && github.event_name == 'schedule' && github.repository == 'pydata/xarray' - && needs.upstream-dev.outputs.artifacts_availability =='true' + && needs.upstream-dev.outputs.artifacts_availability == 'true' runs-on: ubuntu-latest defaults: run: