Skip to content

Version 3.22

Version 3.22 #482

Workflow file for this run

# GitHub Actions docs: https://docs.github.com/en/actions/learn-github-actions
# Reference syntax: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
# Env. vars: https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
# Add'l variables (contexts): https://docs.github.com/en/actions/learn-github-actions/contexts
# Requires encrypted secret (see https://docs.github.com/en/actions/security-guides/encrypted-secrets)
# secrets.pypi_password
# This file is automatically "updated" with PRs by the "pre-commit ci" app in GitHub https://pre-commit.ci; it is
# currently scheduled weekly at approximately 16:00 UTC Monday.
name: Test and deploy release
on: [push, pull_request, workflow_dispatch]
env:
FORCE_COLOR: 1
PYTHONUNBUFFERED: 1
PYTHONUTF8: 1
jobs:
# Set the job key. The key is displayed as the job name
# when a job name is not provided
# PRE-COMMIT IS ALREADY DONE BY GIT
# pre-commit:
# # Name the Job
# name: Quality assurance (pre-commit)
# # Set the type of machine to run on
# runs-on: ubuntu-latest
#
# steps:
# # Checks out a copy of the repository per https://github.com/actions/checkout
# - name: Check out repo
# uses: actions/checkout@main
#
# # Build Python and packages per https://github.com/actions/setup-python
# - name: Set up Python
# uses: actions/setup-python@main
# with:
# python-version: '3.11' # same as https://docs.readthedocs.io/en/stable/config-file/v2.html#build-tools-python
# cache: 'pip'
# cache-dependency-path: |
# requirements.txt
# tests/requirements_pre-commit.txt
# docs/requirements.txt
#
# # Install dependencies needed by the repo: local in .pre-commit-config.yaml
# - name: Install dependencies
# run: |
# pip install --upgrade pip setuptools wheel
# pip install --upgrade -r requirements.txt -r tests/requirements_pre-commit.txt -r docs/requirements.txt
#
# # The below has been replaced with the integration in GitHub of the "pre-commit ci" app https://pre-commit.ci
# # # Run pre-commit cache per https://github.com/pre-commit/action
# # - name: Run pre-commit
# # uses: pre-commit/action@v2.0.3
test_ubuntu:
name: "Test ${{ matrix.python-version }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
# Identifies any jobs that must complete successfully before this job will run
# needs: [pre-commit]
# A strategy creates a build matrix for your jobs. You can define different variations to run each job in
strategy:
matrix:
# Python versions at https://github.com/actions/python-versions/releases
python-version: ['3.12', '3.11', '3.10', '3.9']
# python-version: ['3.12']
os: [ubuntu-latest]
# Set up Redis per https://docs.github.com/en/actions/guides/creating-redis-service-containers
# If you are using GitHub-hosted runners, you must use an Ubuntu runner
services:
# Label used to access the service container
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps port 6379 on service container to the host
- 6379:6379
env:
commitmsg: ${{ github.event.head_commit.message }} # only available at check-out; becomes env.commitmsg
TELEGRAM_TOKEN: ${{ secrets.telegram_token }} # for telegram testing
REDIS_URI: redis://localhost:6379
steps:
# Checks out a copy of the repository per https://github.com/actions/checkout
- name: Check out repo
uses: actions/checkout@main
# Build Python and packages per https://github.com/actions/setup-python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@main
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
requirements.txt
tests/requirements_pytest.txt
- name: Upgrade pip etc.
run: |
pip install --upgrade pip setuptools wheel
# - name: Install build dependencies for Python 3.10 for wheel-less lxml (Linux)
# # https://lxml.de/installation.html#installation
# if: matrix.python-version == '3.10.0-beta.4' && runner.os == 'Linux'
# run: |
# sudo apt-get -y update
# sudo apt-get -y install libxml2-dev libxslt-dev python3-dev
# CFLAGS="-O0" pip install lxml
- name: Install pdf2text and ocr dependencies (Linux Python latest)
# do full install and testing of pdf2text and ocr only on latest Python version
if: matrix.python-version == '3.12' && runner.os == 'Linux'
# https://github.com/jalan/pdftotext#os-dependencies
run: |
sudo apt-get -y update
sudo apt-get -y install python3-dbus build-essential libpoppler-cpp-dev pkg-config python3-dev tesseract-ocr
pip install --upgrade pdftotext pytesseract
- name: Install all other dependencies
# if: matrix.python-version < '3.12'
run: |
pip install --upgrade coveralls -r requirements.txt -r tests/requirements_pytest.txt
# - name: Install all other dependencies (py12)
# if: matrix.python-version == '3.12'
# run: |
# pip install --upgrade --no-deps playwright >=1.37 greenlet==3.0 pyee==11.0
# pip install --upgrade coveralls -r requirements.txt -r tests/requirements_pytest_312.txt
# pip install --upgrade --no-deps pyee==11.0
- name: Run tests
# python -m required to get it to run in the correct directory; '>' folded style scalar (allows splitting line)
run: >
python -m pytest -v --cov=./ --cov-report=term --cov-report=xml --cov-config=.coveragerc tests/
- name: Upload coverage data to coveralls.io (parallel)
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
COVERALLS_FLAG_NAME: tests-${{ matrix.python-version }}-${{ matrix.os }}
COVERALLS_PARALLEL: true
test_macos:
# No redis (only works on ubuntu)
name: "Test ${{ matrix.python-version }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
# Identifies any jobs that must complete successfully before this job will run
# needs: [pre-commit]
# A strategy creates a build matrix for your jobs. You can define different variations to run each job in
strategy:
matrix:
# Python versions at https://github.com/actions/python-versions/releases
python-version: ['3.12', '3.11', '3.10', '3.9']
# python-version: ['3.12']
os: [macos-latest]
# Python 3.9 is not on macos-latest (macos-14-arm64) but only on macos-13
# https://github.com/actions/setup-python/issues/696#issuecomment-1637587760
exclude:
- { python-version: '3.9', os: 'macos-latest' }
include:
- { python-version: '3.9', os: 'macos-13' }
env:
commitmsg: ${{ github.event.head_commit.message }} # only available at check-out; becomes env.commitmsg
TELEGRAM_TOKEN: ${{ secrets.telegram_token }} # for telegram testing
# REDIS_URI: redis://localhost:6379 # no redis running
steps:
# Checks out a copy of the repository per https://github.com/actions/checkout
- name: Check out repo
uses: actions/checkout@main
# Build Python and packages per https://github.com/actions/setup-python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@main
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
requirements.txt
tests/requirements_pytest.txt
- name: Upgrade pip etc.
run: |
pip install --upgrade pip setuptools wheel
# - name: Install wheel-less lxml for Python 3.10
# # https://lxml.de/installation.html#installation
# if: matrix.python-version == '3.10.0-beta.4'
# run: |
# STATIC_DEPS=true sudo -H pip install lxml
- name: Install pdf2text and ocr dependencies (Python latest)
# do full install and testing of pdf2text and ocr only on latest Python version
if: matrix.python-version == '3.12'
run: |
brew install poppler tesseract
pip install --upgrade pdftotext pytesseract
- name: Install all other dependencies
# if: matrix.python-version < '3.12'
run: |
pip install --upgrade coveralls -r requirements.txt -r tests/requirements_pytest.txt
# - name: Install all other dependencies (py12)
# if: matrix.python-version == '3.12'
# run: |
# pip install --upgrade --no-deps playwright >=1.37 greenlet==3.0 pyee==11.0
# pip install --upgrade coveralls -r requirements.txt -r tests/requirements_pytest_312.txt
# pip install --upgrade --no-deps pyee==11.0
- name: Run tests
# python -m required to get it to run in the correct directory; '>' folded style scalar (allows splitting line)
run: >
python -m pytest -v --cov=./ --cov-report=term --cov-report=xml --cov-config=.coveragerc tests/
- name: Upload coverage data to coveralls.io (parallel)
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
COVERALLS_FLAG_NAME: tests-${{ matrix.python-version }}-${{ matrix.os }}
COVERALLS_PARALLEL: true
# NOTES FROM 15-Apr-2024:
# No need to install poppler, tesseract etc. (tests will skip)
# However, pytest would simply crash at collecting (Error: Process completed with exit code 1) so no good.
# Was doing the same on 02-Sep-2023
# test_windows:
# # No redis (only works on ubuntu), only run on latest python-version
# name: "Test ${{ matrix.python-version }} on ${{ matrix.os }}"
# runs-on: ${{ matrix.os }}
# # Identifies any jobs that must complete successfully before this job will run
# # needs: [pre-commit]
# # A strategy creates a build matrix for your jobs. You can define different variations to run each job in
# strategy:
# matrix:
# # Python versions at https://github.com/actions/python-versions/releases
# python-version: ['3.12']
# os: [windows-latest]
#
# env:
# commitmsg: ${{ github.event.head_commit.message }} # only available at check-out; becomes env.commitmsg
# TELEGRAM_TOKEN: ${{ secrets.telegram_token }} # for telegram testing
# REDIS_URI: redis://localhost:6379
#
# steps:
# # Checks out a copy of the repository per https://github.com/actions/checkout
# - name: Check out repo
# uses: actions/checkout@main
#
# # Build Python and packages per https://github.com/actions/setup-python
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@main
# with:
# python-version: ${{ matrix.python-version }}
# cache: 'pip'
# cache-dependency-path: |
# requirements.txt
# tests/requirements_pytest.txt
#
# - name: Upgrade pip etc.
# run: |
# pip install --upgrade pip setuptools wheel
#
## ISSUE WITH THE BELOW:
## Hangs at start /wait "" Miniconda3-latest-Windows-x86_64.exe /RegisterPython=0 /D=%temp%\Miniconda3
## - name: Install pdf2text and ocr dependencies (Python 3.11)
## # do full install and testing of pdf2text and ocr only on latest Python version
## if: matrix.python-version == '3.11'
## run: |
## cd %temp%
## dir
## rem # install conda per https://conda.io/projects/conda/en/stable/user-guide/install/windows.html
## curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -O
## powershell Get-FileHash Miniconda3-latest-Windows-x86_64.exe -Algorithm SHA256
## echo hash should match the one at https://docs.conda.io/projects/miniconda/en/latest/
## rem # below, /S = silent mode
## start /wait "" Miniconda3-latest-Windows-x86_64.exe /RegisterPython=0 /D=%temp%\Miniconda3
## del Miniconda3-latest-Windows-x86_64.exe /f
## call "%temp%\Miniconda3\conda" install -y -c conda-forge poppler
## rem # *** get latest tesseract filename from https://digi.bib.uni-mannheim.de/tesseract/?C=M;O=D
## set TESSERACT=tesseract-ocr-w64-setup-5.3.1.20230401.exe
## curl https://digi.bib.uni-mannheim.de/tesseract/%TESSERACT% -O
## start /wait "" %TESSERACT% /S
## del %TESSERACT% /f
## pip install --upgrade keyring pdftotext Pillow pytesseract
## shell: cmd
#
# - name: Install all other dependencies
## if: matrix.python-version <= '3.11'
# run: |
# pip install --upgrade coveralls -r requirements.txt -r tests/requirements_pytest.txt
#
## - name: Install all other dependencies (Python 3.12)
## if: matrix.python-version > '3.11'
## run: |
## pip install --upgrade greenlet==3.0.0a1 coveralls -r requirements.txt -r tests/requirements_pytest.txt
#
# - name: Run tests
# # workaround for Windows fatal exception: access violation
# # python -m required to get it to run in the correct directory; '>' folded style scalar (allows splitting line)
# run: >
# python -m pytest -v --cov=./ --cov-report=term --cov-report=xml --cov-config=.coveragerc tests/ -p
# no:faulthandler
#
# - name: Upload coverage data to coveralls.io (parallel)
# run: coveralls --service=github
# env:
# GITHUB_TOKEN: ${{ secrets.github_token }}
# COVERALLS_FLAG_NAME: tests-${{ matrix.python-version }}-${{ matrix.os }}
# COVERALLS_PARALLEL: true
coveralls:
name: Completion -> coveralls.io
# needs: [test_ubuntu, test_macos, test_windows]
needs: [test_ubuntu, test_macos]
runs-on: ubuntu-latest
steps:
- name: Coveralls parallel finished
uses: coverallsapp/github-action@main
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
deploy:
name: Deploy release
# needs: [test_ubuntu, test_macos, test_windows]
needs: [test_ubuntu, test_macos]
# ref https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@main
- name: Set up Python
uses: actions/setup-python@main
with:
python-version: '3.12'
cache: 'pip'
# Install pip dependencies
- name: Install dependencies
run: |
pip install --upgrade pip build
# build https://pypa-build.readthedocs.io/en/latest/
- name: Build dist
run: |
python -m build
# PyPI publish GitHub Action from https://github.com/pypa/gh-action-pypi-publish
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}
- name: Create GitHub release
id: create_release
uses: actions/create-release@main
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body_path: RELEASE.rst
draft: false
prerelease: false