From 16438c131234841df22ca8b7acd6df1933ffbb5d Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Fri, 2 Apr 2021 01:34:14 -0700 Subject: [PATCH] Begin GitHub Actions migration --- .github/workflows/build.yml | 227 ++++++++++++++++++++++++++++++++++++ .gitignore | 1 + azure-pipelines.yml | 1 + setup.cfg | 4 +- 4 files changed, 230 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..d94fbd7b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,227 @@ +name: Build and upload to PyPI + +on: + push: + branches: + - master + - ci + - release/* + paths-ignore: + - README* + pull_request: + +jobs: + test_linux: + name: Test ${{ matrix.os }} with Python ${{ matrix.python }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-18.04] #, ubuntu-20.04] + python: ["3.6"] #, "3.7", "3.8", "3.9"] + + env: + OS: ${{ matrix.os }} + PYTHON: ${{ matrix.python }} + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: "0" # 0=all, needed for setuptools-scm to resolve version tags + + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: ${{ matrix.python }} + + - name: Install common packages + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + curl \ + ghostscript \ + img2pdf \ + libffi-dev \ + liblept5 \ + libsm6 libxext6 libxrender-dev \ + pngquant \ + poppler-utils \ + tesseract-ocr \ + tesseract-ocr-deu \ + tesseract-ocr-eng \ + unpaper \ + zlib1g + + - name: Install Ubuntu 18.04 packages + if: matrix.os == 'ubuntu-18.04' + run: | + sudo apt-get install -y --no-install-recommends \ + libexempi3 + + - name: Install Ubuntu 20.04 packages + if: matrix.os == 'ubuntu-20.04' + run: | + sudo apt-get install -y --no-install-recommends \ + libexempi8 + + - name: Install Python packages + run: | + python -m pip install -r requirements/main.txt -r requirements/test.txt . + + - name: Report versions + run: | + tesseract --version + gs --version + pngquant --version + unpaper --version + img2pdf --version + + - name: Test + run: | + python -m pytest --cov-report xml --cov=ocrmypdf --cov=tests/ -n0 tests/test_main.py::test_quick + + # - name: Upload coverage to Codecov + # uses: codecov/codecov-action@v1 + # with: + # files: ./coverage.xml + # env_vars: OS,PYTHON + + test_macos: + name: Test macOS + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest] + python: ["3.9"] + + env: + OS: ${{ matrix.os }} + PYTHON: ${{ matrix.python }} + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: "0" # 0=all, needed for setuptools-scm to resolve version tags + + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: ${{ matrix.python }} + + - name: Install Homebrew deps + run: | + brew update + brew install \ + exempi \ + ghostscript \ + jbig2enc \ + leptonica \ + openjpeg \ + pngquant \ + tesseract + + - name: Install Python packages + run: | + python -m pip install --upgrade pip + python -m pip install -r requirements/main.txt -r requirements/test.txt . + + - name: Report versions + run: | + tesseract --version + gs --version + pngquant --version + img2pdf --version + + - name: Test + run: | + python -m pytest --cov-report xml --cov=ocrmypdf --cov=tests/ -n0 tests/test_main.py::test_quick + + # - name: Upload coverage to Codecov + # uses: codecov/codecov-action@v1 + # with: + # files: ./coverage.xml + # env_vars: OS,PYTHON + + test_windows: + name: Test Windows + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest] + python: ["3.9"] + + env: + OS: ${{ matrix.os }} + PYTHON: ${{ matrix.python }} + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: "0" # 0=all, needed for setuptools-scm to resolve version tags + + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: ${{ matrix.python }} + + - name: Install system packages + run: | + choco install --yes --no-progress --pre tesseract + choco install --yes --no-progress ghostscript + choco install --yes --no-progress pngquant + + - name: Install Python packages + run: | + python -m pip install --upgrade pip + python -m pip install -r requirements/main.txt -r requirements/test.txt . + + - name: Test + run: | + python -m pytest --cov-report xml --cov=ocrmypdf --cov=tests/ -n0 tests/test_main.py::test_quick + + # - name: Upload coverage to Codecov + # uses: codecov/codecov-action@v1 + # with: + # files: ./coverage.xml + # env_vars: OS,PYTHON + + wheel_sdist_linux: + name: Build sdist and wheels + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: "0" # 0=all, needed for setuptools-scm to resolve version tags + + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: "3.6" + + - name: Make wheels and sdist + run: | + python -m pip install --upgrade pip wheel + python setup.py sdist + python setup.py bdist_wheel + + - uses: actions/upload-artifact@v2 + with: + path: | + ./dist/*.whl + ./dist/*.tar.gz + + upload_pypi: + name: Deploy artifacts to PyPI + needs: [wheel_sdist_linux, test_linux, test_macos, test_windows] + runs-on: ubuntu-latest + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') + steps: + - uses: actions/download-artifact@v2 + with: + name: artifact + path: dist + + - uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.TOKEN_PYPI }} + # repository_url: https://test.pypi.org/legacy/ diff --git a/.gitignore b/.gitignore index 7fc65e63..60de406b 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ venv*/ /debug_tests.py *.traineddata /private +/coverage.xml # Package building *.egg-info/ diff --git a/azure-pipelines.yml b/azure-pipelines.yml index db05746c..2f50df24 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,6 +7,7 @@ trigger: - "*" exclude: - "travis" + - "ci" stages: - stage: "Test" diff --git a/setup.cfg b/setup.cfg index 44ed90c5..36545d66 100644 --- a/setup.cfg +++ b/setup.cfg @@ -32,14 +32,12 @@ license_file = LICENSE [coverage:paths] source = - src/ + src/ocrmypdf [coverage:run] branch = true parallel = true concurrency = multiprocessing -source = - src/ocrmypdf [coverage:report] # Regexes for lines to exclude from consideration