-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (144 loc) · 6.33 KB
/
Copy pathunit-tests.yml
File metadata and controls
159 lines (144 loc) · 6.33 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
name: Unit Tests
on:
push:
branches: [main]
pull_request:
schedule:
# Nightly drift check at 05:00 UTC — 1h after upstream-sync.yml rebases
# the forks at 04:00 UTC, so this run exercises whatever landed on
# maintenance/gramps61 overnight. Surfaces upstream regressions in a
# scheduled failure instead of the next contributor's PR.
- cron: '0 5 * * *'
workflow_dispatch:
inputs:
gramps_repo:
description: 'gramps repo (owner/name); empty = same-owner fork'
default: ''
gramps_ref:
description: 'gramps branch/tag/sha; empty = matrix defaults'
default: ''
# See interface-tests.yml for rationale — dorny/test-reporter needs
# checks: write + pull-requests: write, and the repo's default token
# permissions are restrictive.
permissions:
contents: read
checks: write
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
unit-tests:
name: '[upstream] Gramps Unit Tests (${{ matrix.gramps_ref }})'
runs-on: ubuntu-24.04
timeout-minutes: 20
# Advisory gate. This job runs gramps' own *_test.py suite against an
# upstream gramps checkout — failures here almost always reflect
# upstream regressions or transient flakiness, not testbed bugs.
# continue-on-error lets testbed PRs merge on upstream-caused red;
# the blocking gate for the testbed is the interface smoke suite in
# interface-tests.yml. Re-evaluate if the upstream suite stabilises.
continue-on-error: true
strategy:
fail-fast: false
matrix:
# Supported Gramps minors. Add new maintenance branches here when
# they exist upstream (e.g. - maintenance/gramps60) — each entry
# produces a parallel job.
gramps_ref:
- maintenance/gramps61
steps:
- name: Checkout testbed
uses: actions/checkout@v4
with:
path: gramps-testbed
# Repo resolution (in order): workflow input → repository variable
# → same-owner fork. Ref resolution: workflow input → matrix cell.
# Matches interface-tests.yml so forking this testbed alone is
# enough configuration.
- name: Checkout gramps fork
uses: actions/checkout@v4
with:
repository: ${{ github.event.inputs.gramps_repo || vars.GRAMPS_REPO || format('{0}/gramps', github.repository_owner) }}
ref: ${{ github.event.inputs.gramps_ref || matrix.gramps_ref }}
path: gramps
- name: Install system dependencies
# No xvfb/dbus/at-spi — unit tests do not launch the GUI. GTK
# introspection bindings are still required because gramps.gen
# imports gi at module load time.
#
# python3-venv / python3-pip are installed here so the next step
# can build a venv that inherits python3-gi from the system
# interpreter.
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
python3 python3-venv python3-pip \
python3-gi python3-gi-cairo python3-cairo python3-icu \
gir1.2-gtk-3.0 gir1.2-osmgpsmap-1.0 gir1.2-goocanvas-2.0 gir1.2-gexiv2-0.10 \
libgirepository1.0-dev \
gettext intltool \
librsvg2-common
- name: Set up Python venv (inherits python3-gi from apt)
# Ubuntu 24.04's apt python3-gi installs PyGObject into the system
# Python's dist-packages only; a fresh interpreter from
# setup-python@v5 can't see those bindings, and gramps.gen imports
# gi on module load — so every gramps-touching command dies with
# ModuleNotFoundError. --system-site-packages keeps pip installs
# in the venv but inherits apt-provided bindings (gi, cairo, icu).
# Replaces actions/setup-python@v5; pip cache is restored below
# via actions/cache.
uses: ./gramps-testbed/.github/actions/setup-gramps-venv
- name: Restore pip cache
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip-${{ runner.os }}-${{ hashFiles('gramps-testbed/requirements-test.txt') }}
restore-keys: |
pip-${{ runner.os }}-
- name: Install Python dependencies
run: |
pip install -r gramps-testbed/requirements-test.txt
# [testing] extras pulls in jsonschema/mock/lxml from gramps setup.py,
# which some of gramps' own *_test.py files import.
pip install -e 'gramps[testing]'
- name: Compile Gramps translations
# Keeps gramps.gen imports quiet during test collection. Shared with
# interface-tests.yml / addon-unit-tests.yml via the composite action.
uses: ./gramps-testbed/.github/actions/compile-gramps-mo
with:
gramps-path: gramps
- name: Run unit tests
# Mirrors the canonical command from ../gramps/AGENTS.md:
# GRAMPS_RESOURCES=. python3 -m unittest discover -p "*_test.py"
# xmlrunner is a drop-in replacement for unittest that also writes
# JUnit XML. GRAMPS_RESOURCES=. is load-bearing — without it,
# several plugin tests fail to locate resource files.
working-directory: gramps
env:
GRAMPS_RESOURCES: .
run: |
mkdir -p "$GITHUB_WORKSPACE/gramps-testbed/test-results"
python -m xmlrunner discover \
-p '*_test.py' \
-o "$GITHUB_WORKSPACE/gramps-testbed/test-results/" \
-v
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
# Matrix-scoped artifact name so parallel cells don't collide.
name: unit-test-results-${{ strategy.job-index }}
path: gramps-testbed/test-results/
- name: Publish test report
if: always()
uses: dorny/test-reporter@v1
with:
# See interface-tests.yml for the working-directory rationale —
# checkouts use `path:` subdirs so the workflow root isn't a
# git repo; anchor on the testbed checkout.
working-directory: gramps-testbed
name: '[upstream] Gramps Unit Tests (${{ matrix.gramps_ref }})'
path: test-results/*.xml
reporter: java-junit
fail-on-error: false # report, don't gate — see interface-tests.yml