-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (118 loc) · 4.21 KB
/
test-python-bindings.yml
File metadata and controls
138 lines (118 loc) · 4.21 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Test Python Bindings
on:
pull_request:
paths:
- 'crates/**'
- 'Cargo.toml'
- 'pyproject.toml'
- '.github/workflows/test-python-bindings.yml'
push:
branches: [main]
paths:
- 'crates/**'
- 'Cargo.toml'
- 'pyproject.toml'
workflow_dispatch:
jobs:
test:
name: Test (${{ matrix.os }}, Python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.10', '3.14']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: Swatinem/rust-cache@v2
with:
key: py${{ matrix.python-version }}
- name: Create virtual environment
shell: bash
run: python -m venv .venv
- name: Install maturin and build (Linux/macOS)
if: runner.os != 'Windows'
shell: bash
run: |
source .venv/bin/activate
pip install maturin
maturin develop --release
- name: Install maturin and build (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
source .venv/Scripts/activate
pip install maturin
maturin develop --release
- name: Test import and functionality (Linux/macOS)
if: runner.os != 'Windows'
shell: bash
run: |
source .venv/bin/activate
python -c "
import ofd_validator
# Test types
r = ofd_validator.ValidationResult()
assert r.is_valid == True
assert r.error_count == 0
assert r.warning_count == 0
# Test error creation
e = ofd_validator.ValidationError(ofd_validator.ValidationLevel.Error, 'Test', 'test msg', '/path')
r.add_error(e)
assert r.error_count == 1
assert r.is_valid == False
# Test to_dict
d = r.to_dict()
assert d['error_count'] == 1
assert d['is_valid'] == False
# Test all functions exist
assert callable(ofd_validator.validate_all)
assert callable(ofd_validator.validate_json_files)
assert callable(ofd_validator.validate_logo_files)
assert callable(ofd_validator.validate_folder_names)
assert callable(ofd_validator.validate_store_ids)
assert callable(ofd_validator.validate_gtin_ean)
assert callable(ofd_validator.validate_required_files)
assert callable(ofd_validator.validate_logo_file)
assert callable(ofd_validator.validate_folder_name)
print('All tests passed')
"
- name: Test import and functionality (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
source .venv/Scripts/activate
python -c "
import ofd_validator
# Test types
r = ofd_validator.ValidationResult()
assert r.is_valid == True
assert r.error_count == 0
assert r.warning_count == 0
# Test error creation
e = ofd_validator.ValidationError(ofd_validator.ValidationLevel.Error, 'Test', 'test msg', '/path')
r.add_error(e)
assert r.error_count == 1
assert r.is_valid == False
# Test to_dict
d = r.to_dict()
assert d['error_count'] == 1
assert d['is_valid'] == False
# Test all functions exist
assert callable(ofd_validator.validate_all)
assert callable(ofd_validator.validate_json_files)
assert callable(ofd_validator.validate_logo_files)
assert callable(ofd_validator.validate_folder_names)
assert callable(ofd_validator.validate_store_ids)
assert callable(ofd_validator.validate_gtin_ean)
assert callable(ofd_validator.validate_required_files)
assert callable(ofd_validator.validate_logo_file)
assert callable(ofd_validator.validate_folder_name)
print('All tests passed')
"