Skip to content

Updates doc folder with requirements.txt for ReadTheDocs #143

Updates doc folder with requirements.txt for ReadTheDocs

Updates doc folder with requirements.txt for ReadTheDocs #143

Workflow file for this run

# Run test when triggering the workflow on push and pull request,
# but only for the master branch
name: test
on:
push:
branches:
- master
pull_request:
branches:
- master
# -----------------------------------------------------------------------------------------------------
# To leverage the benefit of Github Action, the testing process is divided into three jobs:
# 1. pdf2docx: convert sample pdf to docx -> linux runner
# 2. docx2pdf: convert generated docx to pdf for comparing -> specific runner with MS Word installed
# 3. check_quality: convert page to image and compare similarity with python-opencv -> linux runner
# -----------------------------------------------------------------------------------------------------
jobs:
pdf2docx:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov codecov
python setup.py develop
- name: Run unit test
run: |
pytest -v ./test/test.py::TestConversion --cov=./pdf2docx --cov-report=xml
- name: Upload coverage reports to Codecov
run: |
codecov
env: # Or as an environment variable
super_secret: ${{ secrets.CODECOV_TOKEN }}
# upload docx for further job
- name: Archive package
uses: actions/upload-artifact@v2
with:
name: outputs
path: ./test/outputs
docx2pdf:
# a specific runner with MS Word installed
runs-on: self-hosted
needs: pdf2docx
steps:
- name: Checkout code
uses: actions/checkout@v2
# download artifacts from depending job
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: outputs
path: test\outputs
# convert docx to pdf with OfficeToPDF
- name: Convert to PDF
run: |
cd test\outputs
$files = Get-ChildItem "."
for ($i=0; $i -lt $files.Count; $i++) {
$name = $files[$i].name;
echo "Converting $name to pdf...";
OfficeToPDF $files[$i]
}
del *.docx
# upload pdf for further job
- name: Archive package
uses: actions/upload-artifact@v2
with:
name: outputs
path: test\outputs
check_quality:
runs-on: ubuntu-latest
needs: docx2pdf
steps:
- name: Check out code
uses: actions/checkout@v2
# download artifacts from depending job
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: outputs
path: ./test/outputs
- name: Set up Python 3.x
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest
python setup.py develop
- name: Check converting quality
run: |
pytest -sv ./test/test.py::TestQuality