Skip to content

Commit

Permalink
Improve upstream CI report (#9603)
Browse files Browse the repository at this point in the history
Co-authored-by: Charles Blackmon-Luca <20627856+charlesbluca@users.noreply.github.com>
  • Loading branch information
jrbourbeau and charlesbluca committed Oct 27, 2022
1 parent da9a257 commit 97c22be
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 62 deletions.
76 changes: 14 additions & 62 deletions .github/workflows/upstream.yml
Expand Up @@ -63,69 +63,21 @@ jobs:

- name: Run tests
id: run_tests
env:
XTRATESTARGS: "--report-log output-log.jsonl"
run: source continuous_integration/scripts/run_tests.sh

- name: Open or update issue on failure
if: |
failure()
&& github.event_name != 'pull_request'
&& github.repository == 'dask/dask'
&& steps.run_tests.outcome == 'failure'
uses: xarray-contrib/issue-from-pytest-log@v1.1
with:
log-path: output-log.jsonl
issue-title: ⚠️ Upstream CI failed ⚠️
issue-label: upstream

- name: Coverage
uses: codecov/codecov-action@v3

report:
name: report
needs: build
if: |
always()
&& github.event_name != 'pull_request'
&& github.repository == 'dask/dask'
&& needs.build.result == 'failure'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3.1.0
- name: Report failures
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const title = "⚠️ Upstream 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})`
// 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: 'upstream',
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.rest.issues.create({
owner: variables.owner,
repo: variables.name,
body: issue_body,
title: title,
labels: [variables.label]
})
} else {
github.rest.issues.update({
owner: variables.owner,
repo: variables.name,
issue_number: result.repository.issues.edges[0].node.number,
body: issue_body
})
}
3 changes: 3 additions & 0 deletions continuous_integration/scripts/install.sh
Expand Up @@ -35,6 +35,9 @@ if [[ ${UPSTREAM_DEV} ]]; then
git+https://github.com/dask/distributed \
git+https://github.com/dask/fastparquet \
git+https://github.com/zarr-developers/zarr-python

# Used when automatically opening an issue when the `upstream` CI build fails
mamba install pytest-reportlog
fi

# Install dask
Expand Down

0 comments on commit 97c22be

Please sign in to comment.