49
49
fail-fast : false
50
50
matrix :
51
51
python-version : ["3.10"]
52
- outputs :
53
- artifacts_availability : ${{ steps.status.outputs.ARTIFACTS_AVAILABLE }}
54
52
steps :
55
53
- uses : actions/checkout@v3
56
54
with :
@@ -74,110 +72,21 @@ jobs:
74
72
conda info -a
75
73
conda list
76
74
python xarray/util/print_versions.py
77
- - name : import xarray
75
+ - name : Import xarray
78
76
run : |
79
77
python -c 'import xarray'
80
78
- name : Run Tests
81
79
if : success()
82
80
id : status
83
81
run : |
84
82
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
90
85
if : |
91
86
failure()
92
87
&& steps.status.outcome == 'failure'
93
88
&& 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
115
91
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