-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add GH action for running tests against upstream dev #4583
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c710290
Add Upstream dev GH action
andersy005 0f25e5e
Remove unnecessary dependencies
andersy005 c3de711
Add build matrix for different python versions
andersy005 15f8f79
Use pypi nightly wheels for numpy, scipy, etc
andersy005 b14415f
Remove debugging statements
andersy005 c5fe9fe
Trigger on pull request events
andersy005 425cda4
Cancel previous runs that are not completed
andersy005 19b390d
Test against Python 3.8 only
andersy005 0435d2a
Merge branch 'master' of github.com:pydata/xarray into upstream-dev-ci
andersy005 dc6ba90
Put wheels installation commands into standalone script
andersy005 f7e0d9e
if no candidate issue exists; create a new issue, else update an exis…
andersy005 8341a44
Update whats-new
andersy005 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# type: ignore | ||
import pathlib | ||
|
||
files = pathlib.Path("logs").rglob("**/*-log") | ||
files = sorted(filter(lambda x: x.is_file(), files)) | ||
|
||
message = "\n" | ||
|
||
print("Parsing logs ...") | ||
for file in files: | ||
with open(file) as fpt: | ||
print(f"Parsing {file.absolute()}") | ||
data = fpt.read().split("test summary info")[-1].splitlines()[1:-1] | ||
data = "\n".join(data) | ||
py_version = file.name.split("-")[1] | ||
message = f"{message}\n<details>\n<summary>\nPython {py_version} Test Summary Info\n</summary>\n\n```bash\n{data}\n```\n</details>\n" | ||
|
||
output_file = pathlib.Path("pytest-logs.txt") | ||
with open(output_file, "w") as fpt: | ||
print(f"Writing output file to: {output_file.absolute()} ") | ||
fpt.write(message) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
schedule: | ||
- cron: "0 0 * * *" # Daily “At 00:00” UTC | ||
workflow_dispatch: # allows you to trigger the workflow run manually | ||
|
||
jobs: | ||
upstream-dev: | ||
name: upstream-dev | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.8"] | ||
steps: | ||
- name: Cancel previous runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
- uses: actions/checkout@v2 | ||
- uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
channels: conda-forge | ||
mamba-version: "*" | ||
activate-environment: xarray-tests | ||
auto-update-conda: false | ||
python-version: ${{ matrix.python-version }} | ||
- name: Set up conda environment | ||
run: | | ||
mamba env update -f ci/requirements/py38.yml | ||
bash ci/install-upstream-wheels.sh | ||
conda list | ||
- name: Run Tests | ||
run: | | ||
python -m pytest --verbose -rf > output-${{ matrix.python-version }}-log | ||
|
||
- name: Upload artifacts | ||
if: "failure()&&(github.event_name == 'schedule')&&(github.repository == 'pydata/xarray')" # Check the exit code of previous step | ||
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 == 'pydata/xarray')" | ||
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: | | ||
python .github/workflows/parse_logs.py | ||
- 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) | ||
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') { | ||
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: issue_info.number, | ||
body: issue_body | ||
}) | ||
} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
|
||
conda uninstall -y --force \ | ||
numpy \ | ||
scipy \ | ||
pandas \ | ||
matplotlib \ | ||
dask \ | ||
distributed \ | ||
zarr \ | ||
cftime \ | ||
rasterio \ | ||
pint \ | ||
bottleneck \ | ||
sparse | ||
python -m pip install \ | ||
-i https://pypi.anaconda.org/scipy-wheels-nightly/simple \ | ||
--no-deps \ | ||
--pre \ | ||
--upgrade \ | ||
numpy \ | ||
scipy \ | ||
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/dask/distributed \ | ||
git+https://github.com/zarr-developers/zarr \ | ||
git+https://github.com/Unidata/cftime \ | ||
git+https://github.com/mapbox/rasterio \ | ||
git+https://github.com/hgrecco/pint \ | ||
git+https://github.com/pydata/bottleneck |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confident this gives us what we want in terms of reporting failures:, i.e.:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very impressive. I think this is the best of all worlds.