|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [maintenance/gramps60] |
| 6 | + pull_request: |
| 7 | + branches: [maintenance/gramps60] |
| 8 | + |
| 9 | +env: |
| 10 | + CI_IMAGE: ghcr.io/${{ github.repository }}/gramps-ci:gramps60 |
| 11 | + |
| 12 | +jobs: |
| 13 | + # ----------------------------------------------------------------- |
| 14 | + # Lint (ci container) |
| 15 | + # ----------------------------------------------------------------- |
| 16 | + lint: |
| 17 | + name: Lint |
| 18 | + runs-on: ubuntu-latest |
| 19 | + # Non-blocking until the existing ruff E9/F63/F7/F82 errors across the |
| 20 | + # addon set are cleaned up in a follow-up PR. Flip this off in that PR. |
| 21 | + continue-on-error: true |
| 22 | + container: |
| 23 | + image: ghcr.io/${{ github.repository }}/gramps-ci:gramps60 |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Run ruff (syntax and import errors only) |
| 28 | + run: ruff check --select=E9,F63,F7,F82 --no-fix --exclude='*.gpr.py' . |
| 29 | + |
| 30 | + - name: Check trailing whitespace in Python files |
| 31 | + run: | |
| 32 | + if git --no-pager grep --color -n --full-name '[ \t]$' -- '*.py'; then |
| 33 | + echo "::error::Trailing whitespace found in Python files" |
| 34 | + exit 1 |
| 35 | + fi |
| 36 | +
|
| 37 | + # ----------------------------------------------------------------- |
| 38 | + # Addon structure (bare runner — just bash, no deps needed) |
| 39 | + # ----------------------------------------------------------------- |
| 40 | + addon-structure: |
| 41 | + name: Addon Structure |
| 42 | + runs-on: ubuntu-latest |
| 43 | + # Non-blocking until the four addons missing po/template.pot are fixed |
| 44 | + # in a follow-up PR. Flip this off in that PR. |
| 45 | + continue-on-error: true |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Check all addons have po/template.pot |
| 50 | + run: | |
| 51 | + failed=0 |
| 52 | + for gpr in */*.gpr.py; do |
| 53 | + addon_dir="$(dirname "$gpr")" |
| 54 | + if [ ! -d "$addon_dir/po" ]; then |
| 55 | + echo "::error::$addon_dir is missing po/ directory" |
| 56 | + failed=1 |
| 57 | + elif [ ! -f "$addon_dir/po/template.pot" ]; then |
| 58 | + echo "::error::$addon_dir is missing po/template.pot" |
| 59 | + failed=1 |
| 60 | + fi |
| 61 | + done |
| 62 | + if [ "$failed" -eq 0 ]; then |
| 63 | + echo "All addons have po/template.pot" |
| 64 | + fi |
| 65 | + exit $failed |
| 66 | +
|
| 67 | + # ----------------------------------------------------------------- |
| 68 | + # Compile check (ci container) |
| 69 | + # ----------------------------------------------------------------- |
| 70 | + compile-check: |
| 71 | + name: Compile Check |
| 72 | + runs-on: ubuntu-latest |
| 73 | + container: |
| 74 | + image: ghcr.io/${{ github.repository }}/gramps-ci:gramps60 |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v4 |
| 77 | + |
| 78 | + - name: Compile all Python files (excluding .gpr.py) |
| 79 | + shell: bash |
| 80 | + run: | |
| 81 | + failed=0 |
| 82 | + while IFS= read -r f; do |
| 83 | + if ! python3 -m py_compile "$f" 2>&1; then |
| 84 | + failed=1 |
| 85 | + fi |
| 86 | + done < <(find . -name '*.py' ! -name '*.gpr.py' ! -path './.git/*' ! -path '*/__pycache__/*') |
| 87 | + exit $failed |
| 88 | +
|
| 89 | + # ----------------------------------------------------------------- |
| 90 | + # Unit tests — Linux (ci container) |
| 91 | + # ----------------------------------------------------------------- |
| 92 | + unit-test-linux: |
| 93 | + name: Unit Tests (Linux) |
| 94 | + runs-on: ubuntu-latest |
| 95 | + # Non-blocking until the currently-broken addon unit modules (import |
| 96 | + # failures, stale API usage) are sorted out in follow-up PRs. |
| 97 | + continue-on-error: true |
| 98 | + container: |
| 99 | + image: ghcr.io/${{ github.repository }}/gramps-ci:gramps60 |
| 100 | + steps: |
| 101 | + - uses: actions/checkout@v4 |
| 102 | + |
| 103 | + - name: Run per-addon unit tests |
| 104 | + env: |
| 105 | + PYTHONPATH: . |
| 106 | + run: | |
| 107 | + modules="" |
| 108 | + for f in */tests/test_*.py; do |
| 109 | + [ -f "$f" ] || continue |
| 110 | + case "$(basename "$f")" in |
| 111 | + test_integration*) continue ;; |
| 112 | + esac |
| 113 | + case "$f" in |
| 114 | + Sqlite/tests/test_sqlite.py) continue ;; |
| 115 | + esac |
| 116 | + mod="${f%.py}" |
| 117 | + mod="${mod//\//.}" |
| 118 | + modules="$modules $mod" |
| 119 | + done |
| 120 | + if [ -n "$modules" ]; then |
| 121 | + echo "Running unit tests:$modules" |
| 122 | + python3 -m unittest -v $modules |
| 123 | + else |
| 124 | + echo "No per-addon unit test modules found" |
| 125 | + fi |
| 126 | +
|
| 127 | + # ----------------------------------------------------------------- |
| 128 | + # Unit tests — Windows (conda-forge: bundles PyGObject + GTK + Gramps) |
| 129 | + # ----------------------------------------------------------------- |
| 130 | + unit-test-windows: |
| 131 | + name: Unit Tests (Windows) |
| 132 | + runs-on: windows-latest |
| 133 | + # Non-blocking for the same reason as unit-test-linux. |
| 134 | + continue-on-error: true |
| 135 | + defaults: |
| 136 | + run: |
| 137 | + shell: bash -el {0} |
| 138 | + steps: |
| 139 | + - uses: actions/checkout@v4 |
| 140 | + |
| 141 | + - name: Set up Miniforge |
| 142 | + uses: conda-incubator/setup-miniconda@v3 |
| 143 | + with: |
| 144 | + miniforge-version: latest |
| 145 | + activate-environment: addons-ci |
| 146 | + environment-file: .github/environment.yml |
| 147 | + use-mamba: true |
| 148 | + |
| 149 | + - name: Verify environment |
| 150 | + run: | |
| 151 | + mamba info |
| 152 | + mamba list | head -30 |
| 153 | + python -c "import gramps, gi; print('deps OK')" |
| 154 | +
|
| 155 | + - name: Run per-addon unit tests |
| 156 | + env: |
| 157 | + PYTHONPATH: . |
| 158 | + run: | |
| 159 | + modules="" |
| 160 | + for f in */tests/test_*.py; do |
| 161 | + [ -f "$f" ] || continue |
| 162 | + case "$(basename "$f")" in |
| 163 | + test_integration*) continue ;; |
| 164 | + esac |
| 165 | + case "$f" in |
| 166 | + Sqlite/tests/test_sqlite.py) continue ;; |
| 167 | + esac |
| 168 | + mod="${f%.py}" |
| 169 | + mod="${mod//\//.}" |
| 170 | + modules="$modules $mod" |
| 171 | + done |
| 172 | + if [ -n "$modules" ]; then |
| 173 | + echo "Running unit tests:$modules" |
| 174 | + python -m unittest -v $modules |
| 175 | + else |
| 176 | + echo "No per-addon unit test modules found" |
| 177 | + fi |
| 178 | +
|
| 179 | + # ----------------------------------------------------------------- |
| 180 | + # Integration tests — Gramps (ci container, xvfb available) |
| 181 | + # ----------------------------------------------------------------- |
| 182 | + integration-test: |
| 183 | + name: Integration Tests (Gramps) |
| 184 | + runs-on: ubuntu-latest |
| 185 | + needs: [unit-test-linux] |
| 186 | + container: |
| 187 | + image: ghcr.io/${{ github.repository }}/gramps-ci:gramps60 |
| 188 | + options: --init |
| 189 | + steps: |
| 190 | + - uses: actions/checkout@v4 |
| 191 | + |
| 192 | + - name: Run plugin registration tests |
| 193 | + env: |
| 194 | + PYTHONPATH: . |
| 195 | + run: python3 -m unittest discover -s tests -p "test_*.py" -t . -v |
| 196 | + |
| 197 | + - name: Run per-addon integration tests |
| 198 | + env: |
| 199 | + PYTHONPATH: . |
| 200 | + run: | |
| 201 | + modules="" |
| 202 | + for f in */tests/test_integration*.py; do |
| 203 | + [ -f "$f" ] || continue |
| 204 | + mod="${f%.py}" |
| 205 | + mod="${mod//\//.}" |
| 206 | + modules="$modules $mod" |
| 207 | + done |
| 208 | + if [ -n "$modules" ]; then |
| 209 | + echo "Running per-addon integration tests:$modules" |
| 210 | + python3 -m unittest -v $modules |
| 211 | + else |
| 212 | + echo "No per-addon integration test modules found" |
| 213 | + fi |
| 214 | +
|
| 215 | + # ----------------------------------------------------------------- |
| 216 | + # Build (ci container) |
| 217 | + # ----------------------------------------------------------------- |
| 218 | + build: |
| 219 | + name: Build |
| 220 | + runs-on: ubuntu-latest |
| 221 | + container: |
| 222 | + image: ghcr.io/${{ github.repository }}/gramps-ci:gramps60 |
| 223 | + steps: |
| 224 | + - uses: actions/checkout@v4 |
| 225 | + |
| 226 | + - name: Determine GRAMPSPATH |
| 227 | + id: gramps-path |
| 228 | + run: | |
| 229 | + GPATH=$(python3 -c "import gramps, os; print(os.path.dirname(os.path.dirname(gramps.__file__)))") |
| 230 | + echo "path=$GPATH" >> "$GITHUB_OUTPUT" |
| 231 | +
|
| 232 | + - name: Build all addons |
| 233 | + env: |
| 234 | + GRAMPSPATH: ${{ steps.gramps-path.outputs.path }} |
| 235 | + run: | |
| 236 | + mkdir -p ../download |
| 237 | + python3 make.py gramps60 build all |
0 commit comments