From 40465d4a1132bf42385997d8e100a260403ca38a Mon Sep 17 00:00:00 2001 From: Ray Bell Date: Tue, 20 Apr 2021 23:38:45 -0400 Subject: [PATCH 1/9] add upstream.yml --- .github/workflows/upstream.yml | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/upstream.yml diff --git a/.github/workflows/upstream.yml b/.github/workflows/upstream.yml new file mode 100644 index 00000000..217f6d76 --- /dev/null +++ b/.github/workflows/upstream.yml @@ -0,0 +1,46 @@ +name: Upstream + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.9] + + steps: + - name: Checkout source + uses: actions/checkout@v2 + + - name: Setup Conda Environment + uses: conda-incubator/setup-miniconda@v2 + with: + miniconda-version: "latest" + python-version: ${{ matrix.python-version }} + mamba-version: '*' + environment-file: ci/minimum-tests.yml + activate-environment: xskillscore-minimum-tests + auto-activate-base: false + + - name: Install upstream packages + shell: bash -l {0} + run: | + python -m pip install git+https://github.com/pydata/xarray.git + python -m pip install git+https://github.com/dask/dask.git + python -m pip install git+https://github.com/xgcm/xhistogram.git + + - name: Install + shell: bash -l {0} + run: python -m pip install -e . + + - name: List installed packages + shell: bash -l {0} + run: conda list + + - name: Run tests + shell: bash -l {0} + run: python -m pytest --cov=xskillscore --cov-report=xml xskillscore + + - name: Coverage + uses: codecov/codecov-action@v1 \ No newline at end of file From e6416d50e51f62dfa409c148c1aca14443e918f0 Mon Sep 17 00:00:00 2001 From: Ray Bell Date: Wed, 21 Apr 2021 21:24:58 -0400 Subject: [PATCH 2/9] match climpred ustream dev ci --- .github/workflows/upstream-dev-ci.yml | 172 ++++++++++++++++++++++++++ .github/workflows/upstream.yml | 46 ------- ci/install-upstream-wheels.sh | 36 ++++++ 3 files changed, 208 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/upstream-dev-ci.yml delete mode 100644 .github/workflows/upstream.yml create mode 100644 ci/install-upstream-wheels.sh diff --git a/.github/workflows/upstream-dev-ci.yml b/.github/workflows/upstream-dev-ci.yml new file mode 100644 index 00000000..b7b106d7 --- /dev/null +++ b/.github/workflows/upstream-dev-ci.yml @@ -0,0 +1,172 @@ +name: CI Upstream +on: + push: + branches: + - main + pull_request: + branches: + - main + schedule: + - cron: "0 0 * * 4" # Thursdays “At 00:00” UTC + workflow_dispatch: # allows you to trigger the workflow run manually + +jobs: + detect-ci-trigger: + name: detect upstream-dev ci trigger + runs-on: ubuntu-latest + if: github.event_name == 'push' || github.event_name == 'pull_request' + outputs: + triggered: ${{ steps.detect-trigger.outputs.trigger-found }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 2 + - uses: xarray-contrib/ci-trigger@v1.1 + id: detect-trigger + with: + keyword: "[test-upstream]" + + upstream-dev: + name: upstream-dev + runs-on: ubuntu-latest + needs: detect-ci-trigger + if: | + always() + && github.repository == 'xarray-contrib/xskillscore' + && ( + (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') + || needs.detect-ci-trigger.outputs.triggered == 'true' + ) + defaults: + run: + shell: bash -l {0} + strategy: + fail-fast: false + matrix: + python-version: ["3.8"] + outputs: + artifacts_availability: ${{ steps.status.outputs.ARTIFACTS_AVAILABLE }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Fetch all history for all branches and tags. + - uses: conda-incubator/setup-miniconda@v2 + with: + channels: conda-forge + channel-priority: strict + mamba-version: "*" + activate-environment: xskillscore-dev + auto-update-conda: false + python-version: ${{ matrix.python-version }} + - name: Set up conda environment + run: | + mamba env update -f ci/requirements/dev.yml + bash ci/install-upstream-wheels.sh + - name: Install xskillscore + run: | + python -m pip install --no-deps -e . + - name: Version info + run: | + conda info -a + conda list + - name: import xskillscore + run: | + python -c 'import xskillscore; xskillscore.show_versions()' + - name: Run Tests + if: success() + id: status + run: | + set -euo pipefail + python -m pytest --timeout=60 -rf | tee output-${{ matrix.python-version }}-log || ( + echo '::set-output name=ARTIFACTS_AVAILABLE::true' && false + ) + - name: Upload artifacts + if: | + failure() + && steps.status.outcome == 'failure' + && github.event_name == 'schedule' + && github.repository == 'xarray-contrib/xskillscore' + uses: actions/upload-artifact@v2 + with: + name: output-${{ matrix.python-version }}-log + path: output-${{ matrix.python-version }}-log + retention-days: 5 + + report: + name: report + needs: upstream-dev + if: | + always() + && github.event_name == 'schedule' + && github.repository == 'xarray-contrib/xskillscore' + && needs.upstream-dev.outputs.artifacts_availability == 'true' + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: "3.x" + - uses: actions/download-artifact@v2 + with: + path: /tmp/workspace/logs + - name: Move all log files into a single directory + run: | + rsync -a /tmp/workspace/logs/output-*/ ./logs + ls -R ./logs + - name: Parse logs + run: | + shopt -s globstar + wget https://raw.githubusercontent.com/pydata/xarray/master/.github/workflows/parse_logs.py + python parse_logs.py logs/**/*-log + - name: Report failures + uses: actions/github-script@v3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const fs = require('fs'); + const pytest_logs = fs.readFileSync('pytest-logs.txt', 'utf8'); + 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) { + issues(first: 1, states: OPEN, filterBy: {createdBy: $creator, labels: [$label]}, orderBy: {field: CREATED_AT, direction: DESC}) { + edges { + node { + body + id + number + } + } + } + } + }`; + const variables = { + owner: context.repo.owner, + name: context.repo.repo, + label: 'CI', + creator: "github-actions[bot]" + } + const result = await github.graphql(query, variables) + // 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, + body: issue_body, + title: title, + labels: [variables.label] + }) + } else { + github.issues.update({ + owner: variables.owner, + repo: variables.name, + issue_number: result.repository.issues.edges[0].node.number, + body: issue_body + }) + } \ No newline at end of file diff --git a/.github/workflows/upstream.yml b/.github/workflows/upstream.yml deleted file mode 100644 index 217f6d76..00000000 --- a/.github/workflows/upstream.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Upstream - -on: [push, pull_request] - -jobs: - test: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.9] - - steps: - - name: Checkout source - uses: actions/checkout@v2 - - - name: Setup Conda Environment - uses: conda-incubator/setup-miniconda@v2 - with: - miniconda-version: "latest" - python-version: ${{ matrix.python-version }} - mamba-version: '*' - environment-file: ci/minimum-tests.yml - activate-environment: xskillscore-minimum-tests - auto-activate-base: false - - - name: Install upstream packages - shell: bash -l {0} - run: | - python -m pip install git+https://github.com/pydata/xarray.git - python -m pip install git+https://github.com/dask/dask.git - python -m pip install git+https://github.com/xgcm/xhistogram.git - - - name: Install - shell: bash -l {0} - run: python -m pip install -e . - - - name: List installed packages - shell: bash -l {0} - run: conda list - - - name: Run tests - shell: bash -l {0} - run: python -m pytest --cov=xskillscore --cov-report=xml xskillscore - - - name: Coverage - uses: codecov/codecov-action@v1 \ No newline at end of file diff --git a/ci/install-upstream-wheels.sh b/ci/install-upstream-wheels.sh new file mode 100644 index 00000000..ab395624 --- /dev/null +++ b/ci/install-upstream-wheels.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +conda uninstall -y --force \ + numpy \ + pandas \ + dask \ + cftime \ + bottleneck \ + xarray \ + xhistogram \ + xskillscore + + +# to limit the runtime of Upstream CI +python -m pip install pytest-timeout +python -m pip install \ + -i https://pypi.anaconda.org/scipy-wheels-nightly/simple \ + --no-deps \ + --pre \ + --upgrade \ + numpy \ + pandas +python -m pip install \ + -f https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com \ + --no-deps \ + --pre \ + --upgrade \ + matplotlib +python -m pip install \ + --no-deps \ + --upgrade \ + git+https://github.com/dask/dask \ + git+https://github.com/Unidata/cftime \ + git+https://github.com/pydata/xarray \ + git+https://github.com/pydata/bottleneck \ + git+https://github.com/xgcm/xhistogram \ No newline at end of file From 94f9096e63b91a171bffca5cc8f350761da067a0 Mon Sep 17 00:00:00 2001 From: Aaron Spring Date: Thu, 22 Apr 2021 14:04:22 +0200 Subject: [PATCH 3/9] Update upstream-dev-ci.yml --- .github/workflows/upstream-dev-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/upstream-dev-ci.yml b/.github/workflows/upstream-dev-ci.yml index b7b106d7..a45c9e61 100644 --- a/.github/workflows/upstream-dev-ci.yml +++ b/.github/workflows/upstream-dev-ci.yml @@ -169,4 +169,5 @@ jobs: issue_number: result.repository.issues.edges[0].node.number, body: issue_body }) - } \ No newline at end of file + } + From 347759fefda3ca7d1a56f22617952fdb0603e766 Mon Sep 17 00:00:00 2001 From: Aaron Spring Date: Thu, 22 Apr 2021 14:04:43 +0200 Subject: [PATCH 4/9] Update install-upstream-wheels.sh --- ci/install-upstream-wheels.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/install-upstream-wheels.sh b/ci/install-upstream-wheels.sh index ab395624..1b694b03 100644 --- a/ci/install-upstream-wheels.sh +++ b/ci/install-upstream-wheels.sh @@ -33,4 +33,4 @@ python -m pip install \ git+https://github.com/Unidata/cftime \ git+https://github.com/pydata/xarray \ git+https://github.com/pydata/bottleneck \ - git+https://github.com/xgcm/xhistogram \ No newline at end of file + git+https://github.com/xgcm/xhistogram From 5a903daa4d89ccd0d59592d8357876f8588339ad Mon Sep 17 00:00:00 2001 From: Aaron Spring Date: Thu, 22 Apr 2021 14:29:27 +0200 Subject: [PATCH 5/9] Update upstream-dev-ci.yml From 369ba682a081b3fed6edd408593807de7985b4b2 Mon Sep 17 00:00:00 2001 From: Aaron Spring Date: Thu, 22 Apr 2021 16:34:44 +0200 Subject: [PATCH 6/9] Update upstream-dev-ci.yml From 897ed0baec1b2de24b9183247309d3c25103b843 Mon Sep 17 00:00:00 2001 From: Aaron Spring Date: Thu, 22 Apr 2021 16:37:16 +0200 Subject: [PATCH 7/9] Update upstream-dev-ci.yml --- .github/workflows/upstream-dev-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/upstream-dev-ci.yml b/.github/workflows/upstream-dev-ci.yml index a45c9e61..d3e9c19c 100644 --- a/.github/workflows/upstream-dev-ci.yml +++ b/.github/workflows/upstream-dev-ci.yml @@ -170,4 +170,3 @@ jobs: body: issue_body }) } - From c8adf82251e9af1cd01cd27a864907ed7d7f3171 Mon Sep 17 00:00:00 2001 From: Aaron Spring Date: Thu, 22 Apr 2021 16:43:23 +0200 Subject: [PATCH 8/9] Update upstream-dev-ci.yml --- .github/workflows/upstream-dev-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upstream-dev-ci.yml b/.github/workflows/upstream-dev-ci.yml index d3e9c19c..b8e468fb 100644 --- a/.github/workflows/upstream-dev-ci.yml +++ b/.github/workflows/upstream-dev-ci.yml @@ -7,7 +7,7 @@ on: branches: - main schedule: - - cron: "0 0 * * 4" # Thursdays “At 00:00” UTC + - cron: "0 0 * * 4" # Thursdays At 00:00 UTC workflow_dispatch: # allows you to trigger the workflow run manually jobs: From 801ceb89caae2415e4a10d332c5901dccdee594b Mon Sep 17 00:00:00 2001 From: Aaron Spring Date: Thu, 22 Apr 2021 16:43:56 +0200 Subject: [PATCH 9/9] [test-upstream] --- .github/workflows/upstream-dev-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upstream-dev-ci.yml b/.github/workflows/upstream-dev-ci.yml index b8e468fb..aa99b129 100644 --- a/.github/workflows/upstream-dev-ci.yml +++ b/.github/workflows/upstream-dev-ci.yml @@ -7,7 +7,7 @@ on: branches: - main schedule: - - cron: "0 0 * * 4" # Thursdays At 00:00 UTC + - cron: "0 0 * * 4" # Thursdays At 00:00 UTC workflow_dispatch: # allows you to trigger the workflow run manually jobs: