Skip to content

Commit ca57e5c

Browse files
authored
use the new action to create an issue from the output of reportlog (#7212)
* use the new action to create an issue from the output of reportlog * move report generation from a separate job to a step * [test-upstream] * remove the output declaration [skip-ci][test-upstream] * specify a version for the action [skip-ci][test-upstream] * consistent step name spelling [skip-ci]
1 parent 519abb7 commit ca57e5c

File tree

1 file changed

+6
-97
lines changed

1 file changed

+6
-97
lines changed

.github/workflows/upstream-dev-ci.yaml

Lines changed: 6 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ jobs:
4949
fail-fast: false
5050
matrix:
5151
python-version: ["3.10"]
52-
outputs:
53-
artifacts_availability: ${{ steps.status.outputs.ARTIFACTS_AVAILABLE }}
5452
steps:
5553
- uses: actions/checkout@v3
5654
with:
@@ -74,110 +72,21 @@ jobs:
7472
conda info -a
7573
conda list
7674
python xarray/util/print_versions.py
77-
- name: import xarray
75+
- name: Import xarray
7876
run: |
7977
python -c 'import xarray'
8078
- name: Run Tests
8179
if: success()
8280
id: status
8381
run: |
8482
python -m pytest --timeout=60 -rf \
85-
--report-log output-${{ matrix.python-version }}-log.jsonl \
86-
|| (
87-
echo '::set-output name=ARTIFACTS_AVAILABLE::true' && false
88-
)
89-
- name: Upload artifacts
83+
--report-log output-${{ matrix.python-version }}-log.jsonl
84+
- name: Generate and publish the report
9085
if: |
9186
failure()
9287
&& steps.status.outcome == 'failure'
9388
&& github.event_name == 'schedule'
94-
&& github.repository == 'pydata/xarray'
95-
uses: actions/upload-artifact@v3
96-
with:
97-
name: output-${{ matrix.python-version }}-log.jsonl
98-
path: output-${{ matrix.python-version }}-log.jsonl
99-
retention-days: 5
100-
101-
report:
102-
name: report
103-
needs: upstream-dev
104-
if: |
105-
failure()
106-
&& github.event_name == 'schedule'
107-
&& needs.upstream-dev.outputs.artifacts_availability == 'true'
108-
runs-on: ubuntu-latest
109-
defaults:
110-
run:
111-
shell: bash
112-
steps:
113-
- uses: actions/checkout@v3
114-
- uses: actions/setup-python@v4
89+
&& github.repository_owner == 'pydata'
90+
uses: xarray-contrib/issue-from-pytest-log@v0.1
11591
with:
116-
python-version: "3.x"
117-
- uses: actions/download-artifact@v3
118-
with:
119-
path: /tmp/workspace/logs
120-
- name: Move all log files into a single directory
121-
run: |
122-
rsync -a /tmp/workspace/logs/output-*/ ./logs
123-
ls -R ./logs
124-
- name: install dependencies
125-
run: |
126-
python -m pip install pytest
127-
- name: Parse logs
128-
run: |
129-
shopt -s globstar
130-
python .github/workflows/parse_logs.py logs/**/*-log*
131-
cat pytest-logs.txt
132-
- name: Report failures
133-
uses: actions/github-script@v6
134-
with:
135-
github-token: ${{ secrets.GITHUB_TOKEN }}
136-
script: |
137-
const fs = require('fs');
138-
const pytest_logs = fs.readFileSync('pytest-logs.txt', 'utf8');
139-
const title = "⚠️ Nightly upstream-dev CI failed ⚠️"
140-
const workflow_url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`
141-
const issue_body = `[Workflow Run URL](${workflow_url})\n${pytest_logs}`
142-
143-
// Run GraphQL query against GitHub API to find the most recent open issue used for reporting failures
144-
const query = `query($owner:String!, $name:String!, $creator:String!, $label:String!){
145-
repository(owner: $owner, name: $name) {
146-
issues(first: 1, states: OPEN, filterBy: {createdBy: $creator, labels: [$label]}, orderBy: {field: CREATED_AT, direction: DESC}) {
147-
edges {
148-
node {
149-
body
150-
id
151-
number
152-
}
153-
}
154-
}
155-
}
156-
}`;
157-
158-
const variables = {
159-
owner: context.repo.owner,
160-
name: context.repo.repo,
161-
label: 'CI',
162-
creator: "github-actions[bot]"
163-
}
164-
const result = await github.graphql(query, variables)
165-
166-
// If no issue is open, create a new issue,
167-
// else update the body of the existing issue.
168-
if (result.repository.issues.edges.length === 0) {
169-
github.rest.issues.create({
170-
owner: variables.owner,
171-
repo: variables.name,
172-
body: issue_body,
173-
title: title,
174-
labels: [variables.label]
175-
})
176-
} else {
177-
github.rest.issues.update({
178-
owner: variables.owner,
179-
repo: variables.name,
180-
issue_number: result.repository.issues.edges[0].node.number,
181-
body: issue_body
182-
})
183-
}
92+
log-path: output-${{ matrix.python-version }}-log.jsonl

0 commit comments

Comments
 (0)