forked from gramps-project/addons-source
-
Notifications
You must be signed in to change notification settings - Fork 0
218 lines (197 loc) · 6.93 KB
/
Copy pathci.yml
File metadata and controls
218 lines (197 loc) · 6.93 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
name: CI
on:
push:
branches: [maintenance/gramps60]
pull_request:
branches: [maintenance/gramps60]
env:
HEADLESS_IMAGE: ghcr.io/${{ github.repository }}/gramps-headless:gramps60
GTK_IMAGE: ghcr.io/${{ github.repository }}/gramps-gtk:gramps60
jobs:
# -----------------------------------------------------------------
# Lint (headless container)
# -----------------------------------------------------------------
lint:
name: Lint
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository }}/gramps-headless:gramps60
steps:
- uses: actions/checkout@v4
- name: Run ruff (syntax and import errors only)
run: ruff check --select=E9,F63,F7,F82 --no-fix --exclude='*.gpr.py' .
- name: Check trailing whitespace in Python files
run: |
if git --no-pager grep --color -n --full-name '[ \t]$' -- '*.py'; then
echo "::error::Trailing whitespace found in Python files"
exit 1
fi
# -----------------------------------------------------------------
# Addon structure (bare runner — just bash, no deps needed)
# -----------------------------------------------------------------
addon-structure:
name: Addon Structure
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check all addons have po/template.pot
run: |
failed=0
for gpr in */*.gpr.py; do
addon_dir="$(dirname "$gpr")"
if [ ! -d "$addon_dir/po" ]; then
echo "::error::$addon_dir is missing po/ directory"
failed=1
elif [ ! -f "$addon_dir/po/template.pot" ]; then
echo "::error::$addon_dir is missing po/template.pot"
failed=1
fi
done
if [ "$failed" -eq 0 ]; then
echo "All addons have po/template.pot"
fi
exit $failed
# -----------------------------------------------------------------
# Compile check (headless container)
# -----------------------------------------------------------------
compile-check:
name: Compile Check
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository }}/gramps-headless:gramps60
steps:
- uses: actions/checkout@v4
- name: Compile all Python files (excluding .gpr.py)
run: |
failed=0
while IFS= read -r f; do
if ! python3 -m py_compile "$f" 2>&1; then
failed=1
fi
done < <(find . -name '*.py' ! -name '*.gpr.py' ! -path './.git/*' ! -path '*/__pycache__/*')
exit $failed
# -----------------------------------------------------------------
# Unit tests — Linux (headless container)
# -----------------------------------------------------------------
unit-test-linux:
name: Unit Tests (Linux)
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository }}/gramps-headless:gramps60
steps:
- uses: actions/checkout@v4
- name: Run per-addon unit tests
env:
PYTHONPATH: .
run: |
test_dirs=""
for d in */tests/; do
if ls "$d"/test_*.py 1>/dev/null 2>&1; then
test_dirs="$test_dirs $d"
fi
done
for f in */test_*.py; do
if [ -f "$f" ]; then
test_dirs="$test_dirs $(dirname "$f")"
fi
done
if [ -n "$test_dirs" ]; then
echo "Running unit tests in: $test_dirs"
python3 -m pytest $test_dirs -v --tb=short \
--ignore-glob='**/test_integration*.py' \
-m 'not gui'
else
echo "No per-addon unit test files found"
fi
# -----------------------------------------------------------------
# Unit tests — Windows (bare runner, pip install)
# -----------------------------------------------------------------
unit-test-windows:
name: Unit Tests (Windows)
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: pip install gramps orjson pytest dbf
- name: Run per-addon unit tests
env:
PYTHONPATH: .
shell: bash
run: |
test_dirs=""
for d in */tests/; do
if ls "$d"/test_*.py 1>/dev/null 2>&1; then
test_dirs="$test_dirs $d"
fi
done
for f in */test_*.py; do
if [ -f "$f" ]; then
test_dirs="$test_dirs $(dirname "$f")"
fi
done
if [ -n "$test_dirs" ]; then
echo "Running unit tests in: $test_dirs"
python -m pytest $test_dirs -v --tb=short \
--ignore-glob='**/test_integration*.py' \
-m 'not gui'
else
echo "No per-addon unit test files found"
fi
# -----------------------------------------------------------------
# Integration tests — Gramps (GTK container)
# -----------------------------------------------------------------
integration-test:
name: Integration Tests (Gramps)
runs-on: ubuntu-latest
needs: [unit-test-linux]
container:
image: ghcr.io/${{ github.repository }}/gramps-gtk:gramps60
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Run plugin registration tests
env:
PYTHONPATH: .
run: xvfb-run python3 -m pytest tests/ -v --tb=short
- name: Run per-addon integration tests
env:
PYTHONPATH: .
run: |
integration_tests=""
for f in */tests/test_integration*.py */test_integration*.py; do
if [ -f "$f" ]; then
integration_tests="$integration_tests $f"
fi
done
if [ -n "$integration_tests" ]; then
echo "Running per-addon integration tests: $integration_tests"
xvfb-run python3 -m pytest $integration_tests -v --tb=short
else
echo "No per-addon integration test files found"
fi
# -----------------------------------------------------------------
# Build (headless container — has intltool/gettext)
# -----------------------------------------------------------------
build:
name: Build
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository }}/gramps-headless:gramps60
steps:
- uses: actions/checkout@v4
- name: Determine GRAMPSPATH
id: gramps-path
run: |
GPATH=$(python3 -c "import gramps, os; print(os.path.dirname(os.path.dirname(gramps.__file__)))")
echo "path=$GPATH" >> "$GITHUB_OUTPUT"
- name: Build all addons
env:
GRAMPSPATH: ${{ steps.gramps-path.outputs.path }}
run: |
mkdir -p ../download
python3 make.py gramps60 build all