Skip to content

Fix checker scripts invocation #2340

Fix checker scripts invocation

Fix checker scripts invocation #2340

name: build
on: # cf. https://github.community/t/how-to-trigger-an-action-on-push-or-pull-request-but-not-both/16662
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test:
strategy:
matrix:
python-version: ['3.10']
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout πŸ›ŽοΈ
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }} πŸ”§
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies βš™οΈ
if: matrix.platform == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install ghostscript libjpeg-dev qpdf
- name: Install Python dependencies βš™οΈ
run: pip install --upgrade .
- name: Checking all PDF samples β˜‘
if: matrix.python-version == '3.10' && matrix.platform == 'ubuntu-latest'
run: |
ls -l
ls -l scripts/
# Using Datalogics PDF Checker:
scripts/install-pdfchecker.sh
find . -name '*.pdf' | xargs -n 1 scripts/pdfchecker.py
scripts/pdfchecker.py # printing aggregated report
# Using VeraPDF:
scripts/install-verapdf.sh
find . -name '*.pdf' | xargs -n 1 scripts/verapdf.py
scripts/verapdf.py # printing aggregated report
- name: Running tests β˜‘
env:
CHECK_EXEC_TIME: ${{ matrix.python-version == '3.9' && 'test-enabled' || '' }}
CHECK_RSS_MEMORY: ${{ matrix.python-version == '3.11' && 'test-enabled' || '' }}
run: |
# Ensuring there is no `generate=True` left remaining in calls to assert_pdf_equal:
grep -IRF generate=True test/ && exit 1
# Executing all tests:
pytest -vv --trace-memory-usage
- name: Uploading coverage report to codecov.io β˜‘
if: matrix.python-version == '3.10' && matrix.platform == 'ubuntu-latest'
run: bash <(curl -s https://codecov.io/bash)
- name: Generating HTML documentation πŸ—οΈ
# As build_contributors_html_page.py can hang due to GitHub rate-limiting,
# we only execute this on master for now. And it should always be executed for one Python version only.
if: github.ref == 'refs/heads/master' && matrix.python-version == '3.10' && matrix.platform == 'ubuntu-latest'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p public/
# Setting PDF manual version:
sed -i "s/author:.*/author: v$(python setup.py -V 2>/dev/null)/" mkdocs.yml
cp tutorial/notebook.ipynb docs/
mkdocs build
pdoc --html -o public/ fpdf --config "git_link_template='https://github.com/PyFPDF/fpdf2/blob/{commit}/{path}#L{start_line}-L{end_line}'"
cd contributors/ && PYTHONUNBUFFERED=1 ./build_contributors_html_page.py PyFPDF/fpdf2
cp -t ../public/ contributors.html contributors-map-small.png
- name: Deploy documentation πŸš€
# GitHub Pages deployment should not be done for all Python versions,
# otherwise commits will conflict on the gh-pages branch:
if: github.ref == 'refs/heads/master' && matrix.python-version == '3.10' && matrix.platform == 'ubuntu-latest'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: public/
- name: Publish on Pypi πŸš€
# Similarly, we only publish a new version on Pypi once per pipeline running on master:
if: github.ref == 'refs/heads/master' && matrix.python-version == '3.10' && matrix.platform == 'ubuntu-latest'
run: |
echo Versions already released on Pypi: $(curl -Ls 'https://pypi.org/pypi/fpdf2/json' | jq -r '.releases|keys[]')
echo Current code version: $(python setup.py -V)
# Checking if current code version has already been released:
curl -Ls 'https://pypi.org/pypi/fpdf2/json' | jq -r '.releases|keys[]' | grep "^$(python setup.py -V)\$" && exit 0
# No? Then performing a release on Pypi now:
pip install --upgrade twine wheel
python setup.py sdist bdist_wheel
twine check dist/*
twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.FPDF2_GITHUB_ACTION_PUBLISH }}