1name: CI
2
3on:
4  push:
5    branches:
6      - master
7      - '*.x'
8  pull_request:
9    branches:
10      - master
11      - '*.x'
12
13jobs:
14  tests:
15    if: "!contains(github.event.head_commit.message, '[skip ci]')"
16    name: ${{ matrix.name }}
17    runs-on: ${{ matrix.os }}
18    strategy:
19      fail-fast: true
20      matrix:
21        include:
22          - {name: '3.10', python: '3.10', os: ubuntu-20.04, tox: py310}
23          - {name: '3.9', python: '3.9', os: ubuntu-20.04, tox: py39}
24          - {name: '3.8', python: '3.8', os: ubuntu-18.04, tox: py38}
25          - {name: '3.7', python: '3.7', os: ubuntu-18.04, tox: py37}
26    steps:
27      - uses: actions/checkout@v2
28
29      - name: Setup Python
30        uses: actions/setup-python@v2
31        with:
32          python-version: ${{ matrix.python }}
33
34      - name: Upgrade bootstrap packages
35        run: python -m pip install --upgrade pip tox
36
37      - name: Get pip cache dir
38        id: pip-cache
39        run: echo "::set-output name=dir::$(pip cache dir)"
40
41      - name: Cache pip
42        uses: actions/cache@v2
43        with:
44          path: ${{ steps.pip-cache.outputs.dir }}
45          key: pip-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('setup.py') }}
46          restore-keys: pip-${{ runner.os }}-${{ matrix.python }}-
47
48      - name: Set Python version
49        # See https://pre-commit.com/#github-actions-example
50        run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
51
52      - name: Install tesseract
53        run: sudo apt-get -y update && sudo apt-get install -y tesseract-ocr tesseract-ocr-fra
54
55      - name: Print tesseract version
56        run: echo $(tesseract --version)
57
58      - name: Run tox
59        run: tox -e ${{ matrix.tox }}
60        env:
61          PY_COLORS: 1
62          TOX_TESTENV_PASSENV: PY_COLORS
63
64      - name: Test pytesseract package installation
65        run: pip install -U git+${{ github.server_url }}/${{ github.repository }} && pip show pytesseract && python -c 'import pytesseract'
66