Skip to content

Nightly CI

Nightly CI #2039

Workflow file for this run

name: Nightly CI
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "0 0 * * *"
permissions: {}
jobs:
detect-ci-trigger:
name: detect upstream-dev ci trigger
runs-on: ubuntu-latest
if: |
github.repository == 'xarray-contrib/sphinx-autosummary-accessors'
&& (github.event_name == 'push' || github.event_name == 'pull_request')
outputs:
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 2
persist-credentials: false
- uses: xarray-contrib/ci-trigger@10cd2bfec3484946a4058a421ddf9cfad101e715 # 1.2.1
id: detect-trigger
with:
keyword: "[test-upstream]"
upstream-dev:
name: upstream-dev
runs-on: ubuntu-latest
needs: detect-ci-trigger
if: |
always()
&& (
github.event_name == 'schedule'
|| needs.detect-ci-trigger.outputs.triggered == 'true'
)
strategy:
fail-fast: false
matrix:
python-version: ["3.12"]
outputs:
artifacts_availability: ${{ steps.status.outputs.ARTIFACTS_AVAILABLE }}
steps:
- name: checkout the repository
uses: actions/checkout@v6
with:
# need to fetch all tags to get a correct version
fetch-depth: 0 # fetch all branches and tags
persist-credentials: false
- name: setup python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: upgrade pip
run: python -m pip install --upgrade pip
- name: install sphinx
run: |
python -m pip install "git+https://github.com/sphinx-doc/sphinx"
- name: install other dependencies
run: python -m pip install -r ci/requirements.txt
- name: install the extension
run: python -m pip install .
- name: show versions
run: python -m pip list
- name: import sphinx_autosummary_accessors
run: |
python -c 'import sphinx_autosummary_accessors'
- name: build the documentation
run: |
set -euo pipefail
cd docs
python -m sphinx -M html -d _build/doctrees -EWT -a . _build/html \
| tee output-${{ matrix.python-version }}-log || (
echo "ARTIFACTS_AVAILABLE=true" >> $GITHUB_OUTPUT && false
)
report:
name: Report
runs-on: ubuntu-latest
needs: upstream-dev
if: |
always()
&& github.event_name == 'schedule'
&& github.repository == 'xarray-contrib/sphinx-autosummary-accessors'
&& needs.upstream-dev.outputs.artifacts_availability == 'true'
permissions:
issues: write
steps:
- name: checkout the repository
uses: actions/checkout@v6
with:
persist-credentials: false
- name: setup python
uses: actions/setup-python@v6
with:
python-version: "3.x"
- uses: actions/download-artifact@v6
with:
path: /tmp/workspace/logs
- name: Move all log files into a single directory
run: |
rsync -a /tmp/workspace/logs/output-*/ ./logs
ls -R ./logs
- name: Parse logs
run: |
shopt -s globstar
python .github/workflows/format-report.py logs/**/*-log sphinx-log.txt
- name: Report failures
uses: actions/github-script@v8
with:
github-token: ${{ github.token }}
script: |
const fs = require("fs");
const sphinx_logs = fs.readFileSync("sphinx-logs.txt", "utf8");
const title = "⚠️ Nightly upstream-dev CI failed ⚠️";
const workflow_url = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
const issue_body = `[Workflow Run URL](${workflow_url})\n${sphinx_logs}`;
const variables = {
owner: context.repo.owner,
name: context.repo.repo,
label: "CI"
creator: "app/github-actions",
title: title,
};
const query_string = `repo:${variables.owner}/${variables.name} author:${variables.creator} label:${variables:label} is:open in:title ${variables.title}`;
// Run GraphQL query against GitHub API to find the most recent open issue used for reporting failures
const query = `query {
search(query: "${query_string}", type:ISSUE, first: 1) {
edges {
node {
... on Issue {
body
id
number
}
}
}
}
}`;
const result = await github.graphql(query);
// If no issue is open, create a new issue,
// else update the body of the existing issue.
if (result.repository.issues.edges.length === 0) {
github.rest.issues.create({
owner: variables.owner,
repo: variables.name,
body: issue_body,
title: title,
labels: [variables.label]
});
} else {
github.rest.issues.update({
owner: variables.owner,
repo: variables.name,
issue_number: result.repository.issues.edges[0].node.number,
body: issue_body
});
}