Skip to content

Commit d1bad37

Browse files
authored
restructure the nightly CI (#198)
* update the version and repository of the commit tag detection action * replace the custom github script with an action * manually update `setup-python` to `v4`
1 parent 5931628 commit d1bad37

File tree

1 file changed

+8
-102
lines changed

1 file changed

+8
-102
lines changed

.github/workflows/nightly.yml

Lines changed: 8 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- uses: actions/checkout@v3
2626
with:
2727
fetch-depth: 2
28-
- uses: keewis/ci-trigger@v1.1
28+
- uses: xarray-contrib/ci-trigger@v1.2
2929
id: detect-trigger
3030
with:
3131
keyword: "[test-upstream]"
@@ -60,7 +60,7 @@ jobs:
6060
fetch-depth: 0 # fetch all branches and tags
6161

6262
- name: setup python
63-
uses: actions/setup-python@v3
63+
uses: actions/setup-python@v4
6464
with:
6565
python-version: ${{ matrix.python-version }}
6666

@@ -82,110 +82,16 @@ jobs:
8282
run: python -m pip list
8383

8484
- name: run tests
85+
if: success()
8586
id: status
8687
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
9189
92-
- name: Upload artifacts
90+
- name: report failures
9391
if: |
9492
failure()
95-
&& steps.status.outcome == 'failure'
93+
&& steps.tests.outcome == 'failure'
9694
&& github.event_name == 'schedule'
97-
uses: actions/upload-artifact@v3
95+
uses: xarray-contrib/issue-from-pytest-log@v1
9896
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

Comments
 (0)