-
Notifications
You must be signed in to change notification settings - Fork 48
112 lines (95 loc) · 3.19 KB
/
ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: CI
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
validate:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Install Dependencies
if: steps.python-cache.outputs.cache-hit != 'true'
run: uv sync
- name: Load Cached Pre-Commit Dependencies
id: cached-pre-commit-dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit/
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Execute Pre-Commit
run: uv run pre-commit run --show-diff-on-failure --color=always --all-files
test:
strategy:
matrix:
os: [ ubuntu-latest, macOS-latest, windows-latest ]
python: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
runs-on: ${{ matrix.os }}
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Cache Python Dependencies
id: python-cache
uses: actions/cache@v4
with:
path: |
~/.cache/uv
.venv
key: python-dependencies-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('uv.lock') }}
restore-keys: |
python-dependencies-${{ runner.os }}-${{ matrix.python }}-
- name: Install Dependencies
if: steps.python-cache.outputs.cache-hit != 'true'
run: uv sync --all-extras --dev
- name: Cache Test Artifacts
uses: actions/cache@v4
with:
path: .pytest_cache/
key: pytest-cache-${{ runner.os }}-${{ matrix.python }}
- name: Cache and Install Homebrew (macOS)
if: runner.os == 'macOS'
uses: tecolicom/actions-use-homebrew-tools@v1
with:
tools: 'tesseract tesseract-lang pandoc'
key: 'homebrew-tools-${{ runner.os }}'
cache: yes
verbose: false
- name: Cache and Install APT Packages (Linux)
if: runner.os == 'Linux'
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: tesseract-ocr tesseract-ocr-deu pandoc
version: 1.0
- name: Install System Dependencies (Windows)
if: runner.os == 'Windows'
run: |
choco install -y tesseract pandoc
Write-Output "C:\Program Files\Tesseract-OCR" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
Write-Output "C:\Program Files\Pandoc" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$env:PATH = "C:\Program Files\Tesseract-OCR;C:\Program Files\Pandoc;" + $env:PATH
tesseract --version
pandoc --version
- name: Run Tests
run: uv run pytest