Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Doc with errors #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ commands:
[ "$CIRCLE_PR_NUMBER" = "" ]; then
export RELEASE_TAG='-t release'
fi
mkdir -p logs
make html O="-T $RELEASE_TAG -j4 -w /tmp/sphinxerrorswarnings.log"
rm -r build/html/_sources
working_directory: doc
Expand All @@ -154,20 +155,33 @@ commands:
- run:
name: Extract possible build errors and warnings
command: |
(grep "WARNING\|ERROR" /tmp/sphinxerrorswarnings.log ||
echo "No errors or warnings")
(grep "WARNING\|ERROR" /tmp/sphinxerrorswarnings.log ||
echo "No errors or warnings")
# Save logs as an artifact, and convert from absolute paths to
# repository-relative paths.
sed "s~$PWD/~~" /tmp/sphinxerrorswarnings.log > \
doc/logs/sphinx-errors-warnings.log
when: always
- store_artifacts:
path: doc/logs/sphinx-errors-warnings.log

doc-show-deprecations:
steps:
- run:
name: Extract possible deprecation warnings in examples and tutorials
command: |
(grep DeprecationWarning -r -l doc/build/html/gallery ||
echo "No deprecation warnings in gallery")
(grep DeprecationWarning -r -l doc/build/html/tutorials ||
echo "No deprecation warnings in tutorials")
(grep -rl DeprecationWarning doc/build/html/gallery ||
echo "No deprecation warnings in gallery")
(grep -rl DeprecationWarning doc/build/html/tutorials ||
echo "No deprecation warnings in tutorials")
# Save deprecations that are from this absolute directory, and
# convert to repository-relative paths.
(grep -Ero --no-filename "$PWD/.+DeprecationWarning.+$" \
doc/build/html/{gallery,tutorials} || echo) | \
sed "s~$PWD/~~" > doc/logs/sphinx-deprecations.log
when: always
- store_artifacts:
path: doc/logs/sphinx-deprecations.log

doc-bundle:
steps:
Expand Down
44 changes: 44 additions & 0 deletions .circleci/fetch_doc_logs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import json
import os
from pathlib import Path
import sys
from urllib.parse import urlparse
from urllib.request import urlopen


if len(sys.argv) != 2:
print('USAGE: fetch_doc_results.py CircleCi-build-url')
sys.exit()

target_url = urlparse(sys.argv[1])
*_, organization, repository, build_id = target_url.path.split('/')
print(f'Fetching artifacts from {organization}/{repository} for {build_id}')

artifact_url = (
f'https://circleci.com/api/v2/project/gh/'
f'{organization}/{repository}/{build_id}/artifacts'
)
print(artifact_url)
with urlopen(artifact_url) as response:
artifacts = json.load(response)
artifact_count = len(artifacts['items'])
print(f'Found {artifact_count} artifacts')

with open(os.environ['GITHUB_OUTPUT'], 'w+') as fd:
fd.write(f'count={artifact_count}\n')

logs = Path('logs')
logs.mkdir(exist_ok=True)

found = False
for item in artifacts['items']:
path = item['path']
if path.startswith('doc/logs/'):
path = Path(path).name
print(f'Downloading {path} from {item["url"]}')
with urlopen(item['url']) as response:
(logs / path).write_bytes(response.read())
found = True

if not found:
print('ERROR: Did not find any artifact logs!')
60 changes: 54 additions & 6 deletions .github/workflows/circleci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---
name: "CircleCI artifact handling"
on: [status]
permissions:
statuses: write
jobs:
circleci_artifacts_redirector_job:
runs-on: ubuntu-latest
if: "${{ github.event.context == 'ci/circleci: docs-python38' }}"
permissions:
statuses: write
runs-on: ubuntu-latest
name: Run CircleCI artifacts redirector
steps:
- name: GitHub Action step
Expand All @@ -15,7 +16,54 @@ jobs:
artifact-path: 0/doc/build/html/index.html
circleci-jobs: docs-python38
job-title: View the built docs
- name: Check the URL
if: github.event.status != 'pending'

post_warnings_as_review:
if: "${{ github.event.context == 'ci/circleci: docs-python38' }}"
permissions:
contents: read
checks: write
pull-requests: write
runs-on: ubuntu-latest
name: Post warnings/errors as review
steps:
- uses: actions/checkout@v3

- name: Fetch result artifacts
id: fetch-artifacts
run: |
python .circleci/fetch_doc_logs.py "${{ github.event.target_url }}"

- name: Set up reviewdog
if: "${{ steps.fetch-artifacts.outputs.count != 0 }}"
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest

- name: Post review
if: "${{ steps.fetch-artifacts.outputs.count != 0 }}"
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REVIEWDOG_SKIP_DOGHOUSE: "true"
CI_COMMIT: ${{ github.event.sha }}
CI_REPO_OWNER: ${{ github.event.repository.owner.login }}
CI_REPO_NAME: ${{ github.event.repository.name }}
run: |
curl --fail ${{ steps.step1.outputs.url }} | grep $GITHUB_SHA
# The 'status' event does not contain information in the way that
# reviewdog expects, so we unset those so it reads from the
# environment variables we set above.
unset GITHUB_ACTIONS GITHUB_EVENT_PATH
cat logs/sphinx-errors-warnings.log | \
reviewdog \
-efm '%f\:%l: %tEBUG: %m' \
-efm '%f\:%l: %tNFO: %m' \
-efm '%f\:%l: %tARNING: %m' \
-efm '%f\:%l: %tRROR: %m' \
-efm '%f\:%l: %tEVERE: %m' \
-efm '%f\:%s: %tARNING: %m' \
-efm '%f\:%s: %tRROR: %m' \
-name=sphinx -tee -fail-on-error=false \
-reporter=github-check -filter-mode=nofilter
cat logs/sphinx-deprecations.log | \
reviewdog \
-efm '%f\:%l: %m' \
-name=examples -tee -reporter=github-check -filter-mode=nofilter
2 changes: 1 addition & 1 deletion doc/devel/documenting_mpl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ for opening them in your default browser is:

make show

.. _writing-rest-pages:
.. _writing-rst-pages:

Writing ReST pages
==================
Expand Down
3 changes: 3 additions & 0 deletions examples/color/custom_cmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap


mpl.checkdep_usetex('')

# Make some illustrative fake data:

x = np.arange(0, np.pi, 0.1)
Expand Down