Merge pull request #68 from jdillard/patch-1 #615
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
pull_request: | |
push: | |
jobs: | |
build: | |
if: endsWith(github.head_ref || github.ref_name, '.changes') == false | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
# Builds are failing with py3.9+ because sphinx templates are different. | |
# python: ['3.7', '3.8', '3.9', '3.10', '3.11'] | |
python: ['3.7', '3.8'] | |
fail-fast: false | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install tools | |
run: | | |
sudo apt -y install libxml2-utils | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install -r test/requirements.txt | |
pip install . | |
- name: Build Unit Tests | |
run: | | |
cd test | |
find . -name '*.html' -exec rm {} \; | |
sed -i 's~, "log\.md"~~' conf.py | |
make html SPHINXOPTS='' 2>&1 | tee log.txt | |
git restore conf.py | |
(cd _build/html && rm genindex.html index.html search.html php-modindex.html) | |
(cd _build/html && find . -name '*.html' -exec sh -c 'xmllint {} --xpath '"'"'//div[@role="main"]'"'"' | xmllint --format - > ../../{}' \;) | |
sed -i -r 's~.*/(test/)~\1~;t;d' log.txt | |
- name: Apply Coding Style | |
if: matrix.python == '3.11' | |
run: | | |
pip install black | |
python -m black . | |
- name: Diff Unit Tests Output and Coding Style | |
run: | | |
cd test | |
rm -r _build | |
git add . -N && git diff --exit-code | |
- name: Push Unit Tests Output | |
if: failure() && github.repository_owner != 'markstory' && matrix.python == '3.11' | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
branch: ${{ github.head_ref || github.ref_name }}.changes | |
create_branch: true | |
push_options: '--force' | |
commit_message: Unit Tests Changes | |
commit_user_name: Bot | |
commit_user_email: bot@example.com | |
commit_author: Bot <bot@example.com> | |
- name: Build Unit Tests with '-W' option | |
run: | | |
cd test | |
make html SPHINXOPTS='-W' | |
sed -i 's~, "log\.md"~~' conf.py | |
! make html SPHINXOPTS='-W' || (echo 'Unexpected zero exit code'; false) | |
git restore conf.py | |
- name: Build Unit Tests with toc show_parents=hide | |
run: | | |
cd test | |
make html SPHINXOPTS='-W -D toc_object_entries_show_parents=hide' | |
- name: Build Unit Tests with toc show_parents=domain | |
run: | | |
cd test | |
make html SPHINXOPTS='-W -D toc_object_entries_show_parents=domain' | |
- name: Build Unit Tests with toc show_parents=all | |
run: | | |
cd test | |
make html SPHINXOPTS='-W -D toc_object_entries_show_parents=all' |