Skip to content

Commit d840dce

Browse files
committed
CI: Add workflows for unstable dependencies
This copies over the workflows from MetPy. This adds a job to run with unstable dependencies on a "nightly"/cronjob basis, as well as a job for a PR to run these as needed.
1 parent ea0114b commit d840dce

File tree

3 files changed

+204
-0
lines changed

3 files changed

+204
-0
lines changed

.github/workflows/nightly-builds.yml

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Nightly Checks
2+
3+
on:
4+
schedule:
5+
# Runs at 09Z (3am MDT)
6+
- cron: "0 9 * * 2"
7+
8+
# Allow a manual run
9+
workflow_dispatch:
10+
11+
# Run if we modify the workflow
12+
push:
13+
branches:
14+
- main
15+
paths:
16+
- .github/workflows/nightly-builds.yml
17+
- .github/workflows/unstable-builds.yml
18+
pull_request:
19+
paths:
20+
- .github/workflows/nightly-builds.yml
21+
- .github/workflows/unstable-builds.yml
22+
23+
jobs:
24+
Builds:
25+
uses: ./.github/workflows/unstable-builds.yml
26+
27+
Report:
28+
name: Report
29+
needs: Builds
30+
if: failure() || github.event_name == 'pull_request'
31+
runs-on: ubuntu-latest
32+
permissions:
33+
issues: write
34+
35+
steps:
36+
- name: Download logs
37+
uses: actions/download-artifact@v4
38+
with:
39+
path: /tmp/workspace/logs
40+
41+
- name: Grab log files
42+
run: |
43+
cp /tmp/workspace/logs/log-*/*.log . || true
44+
touch tests-nightly.log build.log linkchecker.log
45+
46+
- name: Report failures
47+
uses: actions/github-script@v7
48+
with:
49+
script: |
50+
const fs = require('fs');
51+
const title = "Nightly build is failing";
52+
const workflow_url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
53+
body = `The [Nightly workflow](${workflow_url}) is failing.\n`;
54+
55+
if ('${{ needs.Builds.outputs.tests_result }}' === 'failure') {
56+
const test_log = fs.readFileSync('tests-nightly.log', 'utf8').substring(0, 21000);
57+
body += `The tests failed.\nLog:\n<details><pre>${test_log}</pre></details>`;
58+
}
59+
if ('${{ needs.Builds.outputs.docs_result }}' === 'failure') {
60+
const build_log = fs.readFileSync('build.log', 'utf8').substring(0, 21000);
61+
const linkchecker = fs.readFileSync('linkchecker.log', 'utf8').substring(0, 21000);
62+
body += `The documentation build failed.\nLog:\n<details><pre>${build_log}</pre></details>`;
63+
body += `\nLinkchecker output:\n<details><pre>${linkchecker}</pre></details>`;
64+
}
65+
66+
// See if we have an existing issue
67+
const items = await github.rest.issues.listForRepo({
68+
owner: context.repo.owner,
69+
repo: context.repo.repo,
70+
state: 'open',
71+
creator: 'github-actions[bot]'
72+
});
73+
const existing = items.data.filter(i => i.title === title);
74+
75+
params = {
76+
owner: context.repo.owner,
77+
repo: context.repo.repo,
78+
body: body,
79+
title: title,
80+
labels: ['Type: Maintenance']
81+
};
82+
83+
// On PRs, avoid actually issuing an API request, since we don't have permission
84+
if ( context.eventName === 'pull_request' ) {
85+
github.hook.wrap('request', (request, options) => { return {}; })
86+
}
87+
88+
if (existing.length === 0) {
89+
console.log('Creating new issue.')
90+
github.rest.issues.create(params)
91+
} else {
92+
params.issue_number = existing[0].number;
93+
console.log(`Updating existing issue: ${params.issue_number}`)
94+
github.rest.issues.update(params)
95+
}

.github/workflows/run-unstable-pr.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: PR Unstable Builds
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
- labeled
10+
11+
jobs:
12+
Builds:
13+
if: |
14+
((github.event.action == 'labeled' && github.event.label.name == 'nightly-ci') ||
15+
contains(github.event.pull_request.labels.*.name, 'nightly-ci'))
16+
uses: ./.github/workflows/unstable-builds.yml

.github/workflows/unstable-builds.yml

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Unstable Builds
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
tests_result:
7+
description: "Result from running tests"
8+
value: ${{ jobs.Tests.outputs.result }}
9+
docs_result:
10+
description: "Result from running docs"
11+
value: ${{ jobs.Docs.outputs.result }}
12+
13+
jobs:
14+
Tests:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
result: ${{ steps.tests.outcome }}
18+
steps:
19+
- name: Checkout source
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 150
23+
fetch-tags: true
24+
25+
- name: Assemble test requirements
26+
run: |
27+
echo git+https://github.com/pydata/xarray@main#egg=xarray > ci/extra_requirements.txt
28+
29+
- name: Install using PyPI
30+
uses: Unidata/MetPy/.github/actions/install-pypi@main
31+
with:
32+
need-extras: true
33+
type: test
34+
version-file: Prerelease
35+
python-version: 3.12
36+
need-cartopy: 'false'
37+
38+
- name: Run tests
39+
id: tests
40+
uses: Unidata/MetPy/.github/actions/run-tests@main
41+
with:
42+
run-doctests: false
43+
key: nightly
44+
upload-coverage: false
45+
pytest-args: ''
46+
47+
- name: Upload test log
48+
if: failure()
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: log-nightly-tests
52+
path: tests-nightly.log
53+
retention-days: 5
54+
55+
Docs:
56+
runs-on: ubuntu-latest
57+
outputs:
58+
result: ${{ steps.build.outcome }}
59+
steps:
60+
- name: Checkout source
61+
uses: actions/checkout@v4
62+
with:
63+
fetch-depth: 150
64+
fetch-tags: true
65+
66+
- name: Assemble doc requirements
67+
run: |
68+
echo git+https://github.com/pydata/xarray@main#egg=xarray > ci/extra_requirements.txt
69+
70+
- name: Install using PyPI
71+
uses: Unidata/MetPy/.github/actions/install-pypi@main
72+
with:
73+
type: doc
74+
version-file: Prerelease
75+
python-version: 3.12
76+
77+
- name: Build docs
78+
id: build
79+
uses: Unidata/MetPY/.github/actions/build-docs@main
80+
with:
81+
run-linkchecker: true
82+
key: nightly
83+
make-targets: ''
84+
85+
- name: Upload build log
86+
if: failure()
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: log-nightly-docs
90+
path: |
91+
build.log
92+
linkchecker.log
93+
retention-days: 5

0 commit comments

Comments
 (0)