Skip to content

Commit 4e1642d

Browse files
Update logic for opening a new issue with upstream failures (#882)
* Update logic for opening a new issue with upstream failures * Update .github/workflows/test-upstream.yml Co-authored-by: Charles Blackmon-Luca <[email protected]> * Use issue-from-pytest-log to file/update issue * Temporarily remove repo checks * Manually install pytest-reportlog * Use one label for issue * Force-fail tests to test issue opening * Upload test logs for all operating systems * cat test logs output * Don't skip log cat * Download and output single pytest result log * Remove debugging code * Update .github/workflows/test-upstream.yml Co-authored-by: Charles Blackmon-Luca <[email protected]>
1 parent 0d8836e commit 4e1642d

File tree

1 file changed

+43
-52
lines changed

1 file changed

+43
-52
lines changed

.github/workflows/test-upstream.yml

Lines changed: 43 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ jobs:
3434
test-dev:
3535
name: "Test upstream dev (${{ matrix.os }}, python: ${{ matrix.python }})"
3636
runs-on: ${{ matrix.os }}
37-
if: github.repository == 'dask-contrib/dask-sql'
3837
env:
3938
CONDA_FILE: continuous_integration/environment-${{ matrix.python }}-dev.yaml
4039
defaults:
@@ -76,9 +75,22 @@ jobs:
7675
if: env.which_upstream == 'Dask'
7776
run: |
7877
mamba install --no-channel-priority dask/label/dev::dask
78+
- name: Install pytest-reportlog
79+
run: |
80+
# TODO: add pytest-reportlog to testing environments if we move over to JSONL output
81+
mamba install pytest-reportlog
7982
- name: Test with pytest
83+
id: run_tests
8084
run: |
81-
pytest --junitxml=junit/test-results.xml --cov-report=xml -n auto tests --dist loadfile
85+
pytest --report-log test-${{ matrix.os }}-py${{ matrix.python }}-results.jsonl --cov-report=xml -n auto tests --dist loadfile
86+
- name: Upload pytest results for failure
87+
if: |
88+
always()
89+
&& steps.run_tests.outcome != 'skipped'
90+
uses: actions/upload-artifact@v3
91+
with:
92+
name: test-${{ matrix.os }}-py${{ matrix.python }}-results
93+
path: test-${{ matrix.os }}-py${{ matrix.python }}-results.jsonl
8294

8395
cluster-dev:
8496
name: "Test upstream dev in a dask cluster"
@@ -104,7 +116,8 @@ jobs:
104116
python setup.py build install
105117
- name: Install cluster dependencies
106118
run: |
107-
mamba install python-blosc lz4 -c conda-forge
119+
# TODO: add pytest-reportlog to testing environments if we move over to JSONL output
120+
mamba install pytest-reportlog python-blosc lz4 -c conda-forge
108121
109122
which python
110123
pip list
@@ -127,8 +140,17 @@ jobs:
127140
docker logs dask-scheduler
128141
docker logs dask-worker
129142
- name: Test with pytest while running an independent dask cluster
143+
id: run_tests
130144
run: |
131-
DASK_SQL_TEST_SCHEDULER="tcp://127.0.0.1:8786" pytest --junitxml=junit/test-cluster-results.xml --cov-report=xml -n auto tests --dist loadfile
145+
DASK_SQL_TEST_SCHEDULER="tcp://127.0.0.1:8786" pytest --report-log test-cluster-results.jsonl --cov-report=xml -n auto tests --dist loadfile
146+
- name: Upload pytest results for failure
147+
if: |
148+
always()
149+
&& steps.run_tests.outcome != 'skipped'
150+
uses: actions/upload-artifact@v3
151+
with:
152+
name: test-cluster-results
153+
path: test-cluster-results.jsonl
132154

133155
import-dev:
134156
name: "Test importing with bare requirements and upstream dev"
@@ -168,59 +190,28 @@ jobs:
168190
169191
report-failures:
170192
name: Open issue for upstream dev failures
171-
needs: [test-dev, cluster-dev]
193+
needs: [test-dev, cluster-dev, import-dev]
172194
if: |
173195
always()
174196
&& (
175-
needs.test-dev.result == 'failure' || needs.cluster-dev.result == 'failure'
197+
needs.test-dev.result == 'failure'
198+
|| needs.cluster-dev.result == 'failure'
199+
|| needs.import-dev.result == 'failure'
176200
)
201+
&& github.repository == 'dask-contrib/dask-sql'
177202
runs-on: ubuntu-latest
178203
steps:
179204
- uses: actions/checkout@v3
180-
- name: Report failures
181-
uses: actions/github-script@v6
205+
- uses: actions/download-artifact@v3
206+
with:
207+
name: test-ubuntu-latest-py3.10-results
208+
- name: Prepare issue label
209+
run: |
210+
# convert which_upstream to lowercase
211+
echo "which_upstream_lower=${which_upstream,,}" >> $GITHUB_ENV
212+
- name: Open or update issue on failure
213+
uses: xarray-contrib/[email protected]
182214
with:
183-
github-token: ${{ secrets.GITHUB_TOKEN }}
184-
script: |
185-
const title = "⚠️ Upstream CI ${{ env.which_upstream }} failed ⚠️"
186-
const workflow_url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`
187-
const issue_body = `[Workflow Run URL](${workflow_url})`
188-
// Run GraphQL query against GitHub API to find the most recent open issue used for reporting failures
189-
const query = `query($owner:String!, $name:String!, $creator:String!, $label:String!){
190-
repository(owner: $owner, name: $name) {
191-
issues(first: 1, states: OPEN, filterBy: {createdBy: $creator, labels: [$label]}, orderBy: {field: CREATED_AT, direction: DESC}) {
192-
edges {
193-
node {
194-
body
195-
id
196-
number
197-
}
198-
}
199-
}
200-
}
201-
}`;
202-
const variables = {
203-
owner: context.repo.owner,
204-
name: context.repo.repo,
205-
label: 'upstream',
206-
creator: "github-actions[bot]"
207-
}
208-
const result = await github.graphql(query, variables)
209-
// If no issue is open, create a new issue,
210-
// else update the body of the existing issue.
211-
if (result.repository.issues.edges.length === 0) {
212-
github.issues.create({
213-
owner: variables.owner,
214-
repo: variables.name,
215-
body: issue_body,
216-
title: title,
217-
labels: [variables.label]
218-
})
219-
} else {
220-
github.issues.update({
221-
owner: variables.owner,
222-
repo: variables.name,
223-
issue_number: result.repository.issues.edges[0].node.number,
224-
body: issue_body
225-
})
226-
}
215+
log-path: test-ubuntu-latest-py3.10-results.jsonl
216+
issue-title: ⚠️ Upstream CI ${{ env.which_upstream }} failed ⚠️
217+
issue-label: upstream-${{ env.which_upstream_lower }}

0 commit comments

Comments
 (0)