4
4
branches :
5
5
- main
6
6
pull_request :
7
+ types : [opened, reopened, synchronize, labeled]
7
8
branches :
8
9
- main
9
10
schedule :
@@ -15,165 +16,45 @@ concurrency:
15
16
cancel-in-progress : true
16
17
17
18
jobs :
18
- detect-ci-trigger :
19
- name : detect upstream-dev ci trigger
20
- runs-on : ubuntu-latest
21
- if : |
22
- github.repository == 'xarray-contrib/cf-xarray'
23
- && (github.event_name == 'push' || github.event_name == 'pull_request')
24
- outputs :
25
- triggered : ${{ steps.detect-trigger.outputs.trigger-found }}
26
- steps :
27
- - uses : actions/checkout@v3
28
- with :
29
- fetch-depth : 2
30
- -
uses :
xarray-contrib/[email protected]
31
- id : detect-trigger
32
- with :
33
- keyword : " [test-upstream]"
34
-
35
19
upstream-dev :
36
20
name : upstream-dev
37
21
runs-on : ubuntu-latest
38
- needs : detect-ci-trigger
39
- if : |
40
- always()
41
- && (
42
- (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
43
- || needs.detect-ci-trigger.outputs.triggered == 'true'
44
- )
22
+ if : ${{ contains( github.event.pull_request.labels.*.name, 'test-upstream') && github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
45
23
defaults :
46
24
run :
47
25
shell : bash -l {0}
48
26
strategy :
49
27
fail-fast : false
50
28
matrix :
51
29
python-version : ["3.10"]
52
- outputs :
53
- artifacts_availability : ${{ steps.status.outputs.ARTIFACTS_AVAILABLE }}
54
30
steps :
55
31
- uses : actions/checkout@v3
56
32
with :
57
33
fetch-depth : 0 # Fetch all history for all branches and tags.
34
+ - name : Set environment variables
35
+ run : |
36
+ echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
58
37
- name : Set up conda environment
59
- uses : mamba-org/provision-with-micromamba@f347426e5745fe3dfc13ec5baf20496990d0281f
38
+ uses : mamba-org/provision-with-micromamba@v14
60
39
with :
61
40
environment-file : ci/upstream-dev-env.yml
62
41
environment-name : cf_xarray_test
63
42
extra-specs : |
64
- python=${{ matrix.python-version }}
43
+ python=" ${{ matrix.python-version }}"
65
44
pytest-reportlog
66
- - name : Install cf-xarray
45
+ - name : Install cf_xarray
67
46
run : |
68
47
python -m pip install --no-deps -e .
69
- - name : Version info
70
- run : |
71
- conda info -a
72
- conda list
73
- - name : import cf_xarray
74
- run : |
75
- python -c 'import cf_xarray'
76
48
- name : Run Tests
77
- if : success()
78
- id : status
79
49
run : |
80
- python -m pytest -n 2 -rf \
81
- --report-log output-${{ matrix.python-version }}-log.jsonl \
82
- || (
83
- echo '::set-output name=ARTIFACTS_AVAILABLE::true' && false
84
- )
85
- - name : Upload artifacts
50
+ pytest -rf -n auto --cov=./ --cov-report=xml \
51
+ --report-log output-${{ matrix.python-version }}-log.jsonl
52
+ - name : Generate and publish the report
86
53
if : |
87
54
failure()
88
55
&& steps.status.outcome == 'failure'
89
56
&& github.event_name == 'schedule'
90
- && github.repository == 'xarray-contrib/cf-xarray'
91
- uses : actions/upload-artifact@v3
92
- with :
93
- name : output-${{ matrix.python-version }}-log.jsonl
94
- path : output-${{ matrix.python-version }}-log.jsonl
95
- retention-days : 5
96
-
97
- report :
98
- name : report
99
- needs : upstream-dev
100
- if : |
101
- failure()
102
- && github.event_name == 'schedule'
103
- && needs.upstream-dev.outputs.artifacts_availability == 'true'
104
- runs-on : ubuntu-latest
105
- defaults :
106
- run :
107
- shell : bash
108
- steps :
109
- - uses : actions/checkout@v3
110
- - uses : actions/setup-python@v4
111
- with :
112
- python-version : " 3.x"
113
- - uses : actions/download-artifact@v3
114
- with :
115
- path : /tmp/workspace/logs
116
- - name : Move all log files into a single directory
117
- run : |
118
- rsync -a /tmp/workspace/logs/output-*/ ./logs
119
- ls -R ./logs
120
- - name : install dependencies
121
- run : |
122
- python -m pip install pytest
123
- - name : Parse logs
124
- run : |
125
- shopt -s globstar
126
- python .github/workflows/parse_logs.py logs/**/*-log*
127
- cat pytest-logs.txt
128
- - name : Report failures
129
- uses : actions/github-script@v6
57
+ && github.repository_owner == 'xarray-contrib'
58
+ uses : xarray-contrib/issue-from-pytest-log@v1
130
59
with :
131
- github-token : ${{ secrets.GITHUB_TOKEN }}
132
- script : |
133
- const fs = require('fs');
134
- const pytest_logs = fs.readFileSync('pytest-logs.txt', 'utf8');
135
- const title = "⚠️ Nightly upstream-dev CI failed ⚠️"
136
- const workflow_url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`
137
- const issue_body = `[Workflow Run URL](${workflow_url})\n${pytest_logs}`
138
-
139
- // Run GraphQL query against GitHub API to find the most recent open issue used for reporting failures
140
- const query = `query($owner:String!, $name:String!, $creator:String!, $label:String!){
141
- repository(owner: $owner, name: $name) {
142
- issues(first: 1, states: OPEN, filterBy: {createdBy: $creator, labels: [$label]}, orderBy: {field: CREATED_AT, direction: DESC}) {
143
- edges {
144
- node {
145
- body
146
- id
147
- number
148
- }
149
- }
150
- }
151
- }
152
- }`;
153
-
154
- const variables = {
155
- owner: context.repo.owner,
156
- name: context.repo.repo,
157
- label: 'CI',
158
- creator: "github-actions[bot]"
159
- }
160
- const result = await github.graphql(query, variables)
161
-
162
- // If no issue is open, create a new issue,
163
- // else update the body of the existing issue.
164
- if (result.repository.issues.edges.length === 0) {
165
- github.rest.issues.create({
166
- owner: variables.owner,
167
- repo: variables.name,
168
- body: issue_body,
169
- title: title,
170
- labels: [variables.label]
171
- })
172
- } else {
173
- github.rest.issues.update({
174
- owner: variables.owner,
175
- repo: variables.name,
176
- issue_number: result.repository.issues.edges[0].node.number,
177
- body: issue_body
178
- })
179
- }
60
+ log-path : output-${{ matrix.python-version }}-log.jsonl
0 commit comments