Skip to content

Commit f478335

Browse files
andersy005keewis
andauthored
Amend upstream-dev GitHub action + Bug fixes (#4604)
* Set artifcats availability status * Fix bug during issue creation/update * write if condition on multiple lines * Enforce channel priority. Thank you, @mathause * Set channel priority to `strict` * multi-line conditional expressions * Remove unnecessary step per @keewis recommendation * Update .github/workflows/upstream-dev-ci.yaml Co-authored-by: keewis <[email protected]>
1 parent 7152b41 commit f478335

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

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

+22-11
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
fail-fast: false
2222
matrix:
2323
python-version: ["3.8"]
24+
outputs:
25+
artifacts_availability: ${{ steps.status.outputs.ARTIFACTS_AVAILABLE }}
2426
steps:
2527
- name: Cancel previous runs
2628
uses: styfle/[email protected]
@@ -30,6 +32,7 @@ jobs:
3032
- uses: conda-incubator/setup-miniconda@v2
3133
with:
3234
channels: conda-forge
35+
channel-priority: strict
3336
mamba-version: "*"
3437
activate-environment: xarray-tests
3538
auto-update-conda: false
@@ -40,12 +43,17 @@ jobs:
4043
bash ci/install-upstream-wheels.sh
4144
conda list
4245
- name: Run Tests
46+
id: status
4347
run: |
44-
set -o pipefail
45-
python -m pytest -rf | tee output-${{ matrix.python-version }}-log
46-
48+
set -euo pipefail
49+
python -m pytest -rf | tee output-${{ matrix.python-version }}-log || (
50+
echo '::set-output name=ARTIFACTS_AVAILABLE::true' && false
51+
)
4752
- name: Upload artifacts
48-
if: "failure()&&(github.event_name == 'schedule')&&(github.repository == 'pydata/xarray')" # Check the exit code of previous step
53+
if: |
54+
failure()
55+
&& github.event_name == 'schedule'
56+
&& github.repository == 'pydata/xarray'
4957
uses: actions/upload-artifact@v2
5058
with:
5159
name: output-${{ matrix.python-version }}-log
@@ -55,7 +63,11 @@ jobs:
5563
report:
5664
name: report
5765
needs: upstream-dev
58-
if: "always()&&(github.event_name == 'schedule')&&(github.repository == 'pydata/xarray')"
66+
if: |
67+
always()
68+
&& github.event_name == 'schedule'
69+
&& github.repository == 'pydata/xarray'
70+
&& needs.upstream-dev.outputs.artifacts_availability == 'true'
5971
runs-on: ubuntu-latest
6072
defaults:
6173
run:
@@ -86,7 +98,7 @@ jobs:
8698
const title = "⚠️ Nightly upstream-dev CI failed ⚠️"
8799
const workflow_url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`
88100
const issue_body = `[Workflow Run URL](${workflow_url})\n${pytest_logs}`
89-
101+
90102
// Run GraphQL query against GitHub API to find the most recent open issue used for reporting failures
91103
const query = `query($owner:String!, $name:String!, $creator:String!, $label:String!){
92104
repository(owner: $owner, name: $name) {
@@ -109,11 +121,10 @@ jobs:
109121
creator: "github-actions[bot]"
110122
}
111123
const result = await github.graphql(query, variables)
112-
const issue_info = result.repository.issues.edges[0].node
113124
114-
// If no issue is open, create a new issue, else update the
115-
// body of the existing issue.
116-
if (typeof issue_info.number === 'undefined') {
125+
// If no issue is open, create a new issue,
126+
// else update the body of the existing issue.
127+
if (result.repository.issues.edges.length === 0) {
117128
github.issues.create({
118129
owner: variables.owner,
119130
repo: variables.name,
@@ -125,7 +136,7 @@ jobs:
125136
github.issues.update({
126137
owner: variables.owner,
127138
repo: variables.name,
128-
issue_number: issue_info.number,
139+
issue_number: result.repository.issues.edges[0].node.number,
129140
body: issue_body
130141
})
131142
}

0 commit comments

Comments
 (0)