25
25
- uses : actions/checkout@v3
26
26
with :
27
27
fetch-depth : 2
28
- - uses : keewis /ci-trigger@v1.1
28
+ - uses : xarray-contrib /ci-trigger@v1.2
29
29
id : detect-trigger
30
30
with :
31
31
keyword : " [test-upstream]"
60
60
fetch-depth : 0 # fetch all branches and tags
61
61
62
62
- name : setup python
63
- uses : actions/setup-python@v3
63
+ uses : actions/setup-python@v4
64
64
with :
65
65
python-version : ${{ matrix.python-version }}
66
66
@@ -82,110 +82,16 @@ jobs:
82
82
run : python -m pip list
83
83
84
84
- name : run tests
85
+ if : success()
85
86
id : status
86
87
run : |
87
- set -euo pipefail
88
- python -m pytest -rf --report-log output-${{ matrix.python-version }}-log.jsonl || (
89
- echo '::set-output name=ARTIFACTS_AVAILABLE::true' && false
90
- )
88
+ python -m pytest -rf --report-log=pytest-log.jsonl
91
89
92
- - name : Upload artifacts
90
+ - name : report failures
93
91
if : |
94
92
failure()
95
- && steps.status .outcome == 'failure'
93
+ && steps.tests .outcome == 'failure'
96
94
&& github.event_name == 'schedule'
97
- uses : actions/upload-artifact@v3
95
+ uses : xarray-contrib/issue-from-pytest-log@v1
98
96
with :
99
- name : output-${{ matrix.python-version }}-log.jsonl
100
- path : output-${{ matrix.python-version }}-log.jsonl
101
- retention-days : 5
102
-
103
- report :
104
- name : Report
105
- runs-on : ubuntu-latest
106
- needs : upstream-dev
107
- if : |
108
- always()
109
- && github.event_name == 'schedule'
110
- && github.repository == 'xarray-contrib/pint-xarray'
111
- && needs.upstream-dev.outputs.artifacts_availability == 'true'
112
- steps :
113
- - name : checkout the repository
114
- uses : actions/checkout@v3
115
-
116
- - name : setup python
117
- uses : actions/setup-python@v3
118
- with :
119
- python-version : " 3.x"
120
-
121
- - name : setup environment
122
- run : |
123
- python -m pip install --upgrade pip
124
- python -m pip install pytest
125
-
126
- - uses : actions/download-artifact@v3
127
- with :
128
- path : /tmp/workspace/logs
129
-
130
- - name : Move all log files into a single directory
131
- run : |
132
- rsync -a /tmp/workspace/logs/output-*/ ./logs
133
- ls -R ./logs
134
-
135
- - name : Parse logs
136
- run : |
137
- shopt -s globstar
138
- python .github/workflows/parse_logs.py logs/**/*-log.jsonl
139
-
140
- - name : Report failures
141
- uses : actions/github-script@v6
142
- with :
143
- github-token : ${{ secrets.GITHUB_TOKEN }}
144
- script : |
145
- const fs = require('fs');
146
- const pytest_logs = fs.readFileSync('pytest-logs.txt', 'utf8');
147
- const title = "⚠️ Nightly upstream-dev CI failed ⚠️"
148
- const workflow_url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`
149
- const issue_body = `[Workflow Run URL](${workflow_url})\n${pytest_logs}`
150
-
151
- // Run GraphQL query against GitHub API to find the most recent open issue used for reporting failures
152
- const query = `query($owner:String!, $name:String!, $creator:String!, $label:String!){
153
- repository(owner: $owner, name: $name) {
154
- issues(first: 1, states: OPEN, filterBy: {createdBy: $creator, labels: [$label]}, orderBy: {field: CREATED_AT, direction: DESC}) {
155
- edges {
156
- node {
157
- body
158
- id
159
- number
160
- }
161
- }
162
- }
163
- }
164
- }`;
165
-
166
- const variables = {
167
- owner: context.repo.owner,
168
- name: context.repo.repo,
169
- label: 'CI',
170
- creator: "github-actions[bot]"
171
- }
172
- const result = await github.graphql(query, variables)
173
-
174
- // If no issue is open, create a new issue,
175
- // else update the body of the existing issue.
176
- if (result.repository.issues.edges.length === 0) {
177
- github.rest.issues.create({
178
- owner: variables.owner,
179
- repo: variables.name,
180
- body: issue_body,
181
- title: title,
182
- labels: [variables.label]
183
- })
184
- } else {
185
- github.rest.issues.update({
186
- owner: variables.owner,
187
- repo: variables.name,
188
- issue_number: result.repository.issues.edges[0].node.number,
189
- body: issue_body
190
- })
191
- }
97
+ log-path : pytest-log.jsonl
0 commit comments