|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [maintenance/gramps60] |
| 6 | + pull_request: |
| 7 | + branches: [maintenance/gramps60] |
| 8 | + |
| 9 | +env: |
| 10 | + HEADLESS_IMAGE: ghcr.io/${{ github.repository }}/gramps-headless:gramps60 |
| 11 | + GTK_IMAGE: ghcr.io/${{ github.repository }}/gramps-gtk:gramps60 |
| 12 | + |
| 13 | +jobs: |
| 14 | + # ----------------------------------------------------------------- |
| 15 | + # Lint (headless container) |
| 16 | + # ----------------------------------------------------------------- |
| 17 | + lint: |
| 18 | + name: Lint |
| 19 | + runs-on: ubuntu-latest |
| 20 | + container: |
| 21 | + image: ghcr.io/${{ github.repository }}/gramps-headless:gramps60 |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Run ruff (syntax and import errors only) |
| 26 | + run: ruff check --select=E9,F63,F7,F82 --no-fix --exclude='*.gpr.py' . |
| 27 | + |
| 28 | + - name: Check trailing whitespace in Python files |
| 29 | + run: | |
| 30 | + if git --no-pager grep --color -n --full-name '[ \t]$' -- '*.py'; then |
| 31 | + echo "::error::Trailing whitespace found in Python files" |
| 32 | + exit 1 |
| 33 | + fi |
| 34 | +
|
| 35 | + # ----------------------------------------------------------------- |
| 36 | + # Addon structure (bare runner — just bash, no deps needed) |
| 37 | + # ----------------------------------------------------------------- |
| 38 | + addon-structure: |
| 39 | + name: Addon Structure |
| 40 | + runs-on: ubuntu-latest |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v4 |
| 43 | + |
| 44 | + - name: Check all addons have po/template.pot |
| 45 | + run: | |
| 46 | + failed=0 |
| 47 | + for gpr in */*.gpr.py; do |
| 48 | + addon_dir="$(dirname "$gpr")" |
| 49 | + if [ ! -d "$addon_dir/po" ]; then |
| 50 | + echo "::error::$addon_dir is missing po/ directory" |
| 51 | + failed=1 |
| 52 | + elif [ ! -f "$addon_dir/po/template.pot" ]; then |
| 53 | + echo "::error::$addon_dir is missing po/template.pot" |
| 54 | + failed=1 |
| 55 | + fi |
| 56 | + done |
| 57 | + if [ "$failed" -eq 0 ]; then |
| 58 | + echo "All addons have po/template.pot" |
| 59 | + fi |
| 60 | + exit $failed |
| 61 | +
|
| 62 | + # ----------------------------------------------------------------- |
| 63 | + # Compile check (headless container) |
| 64 | + # ----------------------------------------------------------------- |
| 65 | + compile-check: |
| 66 | + name: Compile Check |
| 67 | + runs-on: ubuntu-latest |
| 68 | + container: |
| 69 | + image: ghcr.io/${{ github.repository }}/gramps-headless:gramps60 |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@v4 |
| 72 | + |
| 73 | + - name: Compile all Python files (excluding .gpr.py) |
| 74 | + run: | |
| 75 | + failed=0 |
| 76 | + while IFS= read -r f; do |
| 77 | + if ! python3 -m py_compile "$f" 2>&1; then |
| 78 | + failed=1 |
| 79 | + fi |
| 80 | + done < <(find . -name '*.py' ! -name '*.gpr.py' ! -path './.git/*' ! -path '*/__pycache__/*') |
| 81 | + exit $failed |
| 82 | +
|
| 83 | + # ----------------------------------------------------------------- |
| 84 | + # Unit tests — Linux (headless container) |
| 85 | + # ----------------------------------------------------------------- |
| 86 | + unit-test-linux: |
| 87 | + name: Unit Tests (Linux) |
| 88 | + runs-on: ubuntu-latest |
| 89 | + container: |
| 90 | + image: ghcr.io/${{ github.repository }}/gramps-headless:gramps60 |
| 91 | + steps: |
| 92 | + - uses: actions/checkout@v4 |
| 93 | + |
| 94 | + - name: Run per-addon unit tests |
| 95 | + env: |
| 96 | + PYTHONPATH: . |
| 97 | + run: | |
| 98 | + test_dirs="" |
| 99 | + for d in */tests/; do |
| 100 | + if ls "$d"/test_*.py 1>/dev/null 2>&1; then |
| 101 | + test_dirs="$test_dirs $d" |
| 102 | + fi |
| 103 | + done |
| 104 | + for f in */test_*.py; do |
| 105 | + if [ -f "$f" ]; then |
| 106 | + test_dirs="$test_dirs $(dirname "$f")" |
| 107 | + fi |
| 108 | + done |
| 109 | + if [ -n "$test_dirs" ]; then |
| 110 | + echo "Running unit tests in: $test_dirs" |
| 111 | + python3 -m pytest $test_dirs -v --tb=short \ |
| 112 | + --ignore-glob='**/test_integration*.py' \ |
| 113 | + -m 'not gui' |
| 114 | + else |
| 115 | + echo "No per-addon unit test files found" |
| 116 | + fi |
| 117 | +
|
| 118 | + # ----------------------------------------------------------------- |
| 119 | + # Unit tests — Windows (bare runner, pip install) |
| 120 | + # ----------------------------------------------------------------- |
| 121 | + unit-test-windows: |
| 122 | + name: Unit Tests (Windows) |
| 123 | + runs-on: windows-latest |
| 124 | + steps: |
| 125 | + - uses: actions/checkout@v4 |
| 126 | + |
| 127 | + - name: Set up Python |
| 128 | + uses: actions/setup-python@v5 |
| 129 | + with: |
| 130 | + python-version: "3.12" |
| 131 | + |
| 132 | + - name: Install dependencies |
| 133 | + run: pip install gramps orjson pytest dbf |
| 134 | + |
| 135 | + - name: Run per-addon unit tests |
| 136 | + env: |
| 137 | + PYTHONPATH: . |
| 138 | + shell: bash |
| 139 | + run: | |
| 140 | + test_dirs="" |
| 141 | + for d in */tests/; do |
| 142 | + if ls "$d"/test_*.py 1>/dev/null 2>&1; then |
| 143 | + test_dirs="$test_dirs $d" |
| 144 | + fi |
| 145 | + done |
| 146 | + for f in */test_*.py; do |
| 147 | + if [ -f "$f" ]; then |
| 148 | + test_dirs="$test_dirs $(dirname "$f")" |
| 149 | + fi |
| 150 | + done |
| 151 | + if [ -n "$test_dirs" ]; then |
| 152 | + echo "Running unit tests in: $test_dirs" |
| 153 | + python -m pytest $test_dirs -v --tb=short \ |
| 154 | + --ignore-glob='**/test_integration*.py' \ |
| 155 | + -m 'not gui' |
| 156 | + else |
| 157 | + echo "No per-addon unit test files found" |
| 158 | + fi |
| 159 | +
|
| 160 | + # ----------------------------------------------------------------- |
| 161 | + # Integration tests — Gramps (GTK container) |
| 162 | + # ----------------------------------------------------------------- |
| 163 | + integration-test: |
| 164 | + name: Integration Tests (Gramps) |
| 165 | + runs-on: ubuntu-latest |
| 166 | + needs: [unit-test-linux] |
| 167 | + container: |
| 168 | + image: ghcr.io/${{ github.repository }}/gramps-gtk:gramps60 |
| 169 | + steps: |
| 170 | + - uses: actions/checkout@v4 |
| 171 | + with: |
| 172 | + lfs: true |
| 173 | + |
| 174 | + - name: Run plugin registration tests |
| 175 | + env: |
| 176 | + PYTHONPATH: . |
| 177 | + run: xvfb-run python3 -m pytest tests/ -v --tb=short |
| 178 | + |
| 179 | + - name: Run per-addon integration tests |
| 180 | + env: |
| 181 | + PYTHONPATH: . |
| 182 | + run: | |
| 183 | + integration_tests="" |
| 184 | + for f in */tests/test_integration*.py */test_integration*.py; do |
| 185 | + if [ -f "$f" ]; then |
| 186 | + integration_tests="$integration_tests $f" |
| 187 | + fi |
| 188 | + done |
| 189 | + if [ -n "$integration_tests" ]; then |
| 190 | + echo "Running per-addon integration tests: $integration_tests" |
| 191 | + xvfb-run python3 -m pytest $integration_tests -v --tb=short |
| 192 | + else |
| 193 | + echo "No per-addon integration test files found" |
| 194 | + fi |
| 195 | +
|
| 196 | + # ----------------------------------------------------------------- |
| 197 | + # Build (headless container — has intltool/gettext) |
| 198 | + # ----------------------------------------------------------------- |
| 199 | + build: |
| 200 | + name: Build |
| 201 | + runs-on: ubuntu-latest |
| 202 | + container: |
| 203 | + image: ghcr.io/${{ github.repository }}/gramps-headless:gramps60 |
| 204 | + steps: |
| 205 | + - uses: actions/checkout@v4 |
| 206 | + |
| 207 | + - name: Determine GRAMPSPATH |
| 208 | + id: gramps-path |
| 209 | + run: | |
| 210 | + GPATH=$(python3 -c "import gramps, os; print(os.path.dirname(os.path.dirname(gramps.__file__)))") |
| 211 | + echo "path=$GPATH" >> "$GITHUB_OUTPUT" |
| 212 | +
|
| 213 | + - name: Build all addons |
| 214 | + env: |
| 215 | + GRAMPSPATH: ${{ steps.gramps-path.outputs.path }} |
| 216 | + run: | |
| 217 | + mkdir -p ../download |
| 218 | + python3 make.py gramps60 build all |
0 commit comments