Skip to content

Commit

Permalink
Add GHA scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Sep 13, 2023
1 parent f38bb30 commit f725d4a
Show file tree
Hide file tree
Showing 4 changed files with 346 additions and 0 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Coverage

on: [push, pull_request, workflow_dispatch]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
FORCE_COLOR: "1"
PYTHONDEVMODE: "1" # -X dev
PYTHONWARNDEFAULTENCODING: "1" # -X warn_default_encoding
PYTHONWARNINGS: "error" # -W error

jobs:
with-deps:
name: Test with dependencies
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: "3"
cache: pip
cache-dependency-path: .github/workflows/coverage.yml

- name: Install dependencies
run: |
cd docutils
python -m pip install --upgrade pip
python -m pip install coverage pytest
python -m pip install .
python -m pip install "pygments<=2.13"
# for recommonmark
python -m pip install commonmark
python -m pip install recommonmark --no-deps
# for visual inspection
python -m pip list
env:
PYTHONWARNINGS: ""

- name: Run test suite
run: |
coverage run --parallel-mode -m pytest ./docutils/test -vv
- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: coverage_data
path: .coverage.*

coverage:
name: Coverage
needs: with-deps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: "3"
cache: pip
cache-dependency-path: .github/workflows/coverage.yml

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install coverage
env:
PYTHONWARNINGS: ""

- name: Download coverage data
uses: actions/download-artifact@v3
with:
name: coverage_data

- name: Combine coverage data
run: |
python -m coverage combine
python -m coverage report --show-missing --skip-covered
python -m coverage json
python -m coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
verbose: true
32 changes: 32 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Lint

on: [push, pull_request, workflow_dispatch]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
flake8:
name: Lint using flake8
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3
cache: pip
cache-dependency-path: .github/workflows/linting.yml

- name: Install dependencies
run: pip install "flake8<6"

- name: Run flake8
run: |
cd docutils
flake8 docutils
75 changes: 75 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Documentation

on: [push, pull_request, workflow_dispatch]

permissions:
contents: write

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
render:
name: Publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: 3
cache: pip
cache-dependency-path: .github/workflows/pages.yml

- name: Install dependencies
run: |
cd docutils
python -m pip install --upgrade pip
python -m pip install -e .
python -m pip install pygments
# for recommonmark
python -m pip install commonmark
python -m pip install recommonmark --no-deps
# for visual inspection
python -m pip list
- name: Run tools/buildhtml
run: |
cd docutils
# copy files from web/
cp ../web/index.txt ./index.txt
cp ../web/rst.txt ./rst.txt
cp ../web/python.png ./python.png
cp ../web/rst.png ./rst.png
# convert reStructuredText source to HTML
python tools/buildhtml.py --writer html5 --local .
python tools/buildhtml.py --writer html5 ./docs
# Remove files under docutils/ except the CSS files
mkdir tmp_css
mv docutils/writers/html5_polyglot/* tmp_css/
find tmp_css/ -type f ! -name '*.css' -delete
rm -r docutils/
mkdir -p docutils/writers/html5_polyglot
mv tmp_css/* docutils/writers/html5_polyglot/
# Remove other files
rm -r licenses/ test/ tools/
rm docutils.conf pyproject.toml setup.py tox.ini
# Add files for GitHub Pages
touch .nojekyll
echo "www.docutils.org" > ./docs/CNAME
- name: Deploy to GitHub pages
# This allows CI to build branches for testing
if: github.repository_owner == 'docutils' && github.ref == 'refs/heads/master'
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: docutils
single-commit: true # Delete existing files
146 changes: 146 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: Test

on: [push, pull_request, workflow_dispatch]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
FORCE_COLOR: "1"
PYTHONDEVMODE: "1" # -X dev
PYTHONWARNDEFAULTENCODING: "1" # -X warn_default_encoding
PYTHONWARNINGS: "error" # -W error

jobs:
tests:
name: Python ${{ matrix.python }}; LANG=${{ matrix.lang[0] }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12-dev"
lang:
# -["full lang code", "code for locale-gen"]
- ["C.UTF-8", "--help"] # for the default locale we skip locale-gen
include:
- python: "3"
lang: ["en_GB.iso88591", "en_GB"]
- python: "3"
lang: ["de_DE.UTF-8", "de_DE.UTF-8"]
- python: "3"
lang: ["fr_FR.iso88591", "fr_FR"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: .github/workflows/test.yml
env:
PYTHONWARNINGS: ""

- name: Install dependencies
run: |
cd docutils
python -m pip install --upgrade pip
python -m pip install .
python -m pip install pytest pytest-subtests pygments
# for recommonmark
python -m pip install commonmark
python -m pip install recommonmark --no-deps
# for visual inspection
python -m pip list
env:
PYTHONWARNINGS: ""

- name: Generate locale
if: matrix.lang[0] != 'C.UTF-8'
run: |
sudo locale-gen ${{ matrix.lang[1] }}
sudo update-locale LANG=${{ matrix.lang[0] }}
export LANG=${{ matrix.lang[0] }}
export LANGUAGE=${{ matrix.lang[0] }}
export LC_ALL=${{ matrix.lang[0] }}
locale
- name: Run test suite (pytest ./test)
if: always()
env:
LANG: ${{ matrix.lang[0] }}
LANGUAGE: ${{ matrix.lang[0] }}
LC_ALL: ${{ matrix.lang[0] }}
run: |
cd docutils
python -m pytest -vv ./test
- name: Run test suite (pytest .)
if: always()
env:
LANG: ${{ matrix.lang[0] }}
LANGUAGE: ${{ matrix.lang[0] }}
LC_ALL: ${{ matrix.lang[0] }}
run: |
cd docutils
python -m pytest -vv .
- name: Run test suite (pytest . in ./test)
if: always()
env:
LANG: ${{ matrix.lang[0] }}
LANGUAGE: ${{ matrix.lang[0] }}
LC_ALL: ${{ matrix.lang[0] }}
run: |
cd docutils/test
python -m pytest -vv .
- name: Run test suite (python -m unittest discover -v)
if: always()
env:
LANG: ${{ matrix.lang[0] }}
LANGUAGE: ${{ matrix.lang[0] }}
LC_ALL: ${{ matrix.lang[0] }}
run: |
cd docutils
python -m unittest discover -v
- name: Run test suite (python -m unittest discover -v in ./test)
if: always()
env:
LANG: ${{ matrix.lang[0] }}
LANGUAGE: ${{ matrix.lang[0] }}
LC_ALL: ${{ matrix.lang[0] }}
run: |
cd docutils/test
python -m unittest discover -v
- name: Run test suite (alltests.py)
if: always()
env:
LANG: ${{ matrix.lang[0] }}
LANGUAGE: ${{ matrix.lang[0] }}
LC_ALL: ${{ matrix.lang[0] }}
run: |
cd docutils
python test/alltests.py
- name: Run test suite (alltests.py in ./test)
if: always()
env:
LANG: ${{ matrix.lang[0] }}
LANGUAGE: ${{ matrix.lang[0] }}
LC_ALL: ${{ matrix.lang[0] }}
run: |
cd docutils/test
python alltests.py

0 comments on commit f725d4a

Please sign in to comment.