Gate APK releases on worker factory and Matrix regression tests
Build and Release APK / Build APK (push) Failing after 2m46s

This commit is contained in:
2026-10-21 23:00:00 +02:00
parent af4e7899e3
commit d27edde5e8
6 changed files with 258 additions and 3 deletions
+65
View File
@@ -0,0 +1,65 @@
#!/usr/bin/env python3
"""Require the critical runtime regression suites before publishing APKs."""
from pathlib import Path
import sys
import xml.etree.ElementTree as ET
ROOT = Path(__file__).resolve().parents[2]
WORKERS = 'dev.octoshrimpy.quik.worker.InjectionWorkerFactoryTest'
REQUIRED = {
WORKERS: {
'matrixCoroutineWorkerIsCreatedByTheApplicationFactory',
'matrixWatcherStartsTheExpectedService',
'housekeepingReceivesItsRepository',
'smsWorkerReceivesEveryRequiredDependency',
'mmsWorkerReceivesEveryRequiredDependency',
'eachRequestCreatesANewWorkerInstance',
},
'ch.skew.remotrix.bridge.BackfillRunnerTest': set(),
'ch.skew.remotrix.bridge.RoomResolverTest': set(),
'ch.skew.remotrix.bridge.CloseMatrixClientTest': set(),
'ch.skew.remotrix.bridge.BridgeResetTest': set(),
}
def check(report_dirs):
passed = {}
count = 0
for directory in report_dirs:
for path in Path(directory).glob('TEST-*.xml'):
suite = ET.parse(path).getroot()
for case in suite.iter('testcase'):
name = case.get('name', '')
classname = case.get('classname', suite.get('name', ''))
if case.find('failure') is not None or case.find('error') is not None:
raise ValueError(f'Failed test: {classname}.{name}')
if case.find('skipped') is not None:
if classname in REQUIRED:
raise ValueError(f'Skipped critical test: {classname}.{name}')
continue
passed.setdefault(classname, set()).add(name)
count += 1
for classname, names in REQUIRED.items():
if not passed.get(classname):
raise ValueError(f'Missing critical test suite: {classname}')
missing = names - passed[classname]
if missing:
raise ValueError(f'Missing critical tests in {classname}: {sorted(missing)}')
return count
def main():
try:
total = check([
ROOT / 'presentation/build/test-results/testDebugUnitTest',
ROOT / 'remotrix-sync/build/test-results/testDebugUnitTest',
])
except (OSError, ValueError, ET.ParseError) as error:
print(f'Release test gate failed: {error}', file=sys.stderr)
return 1
print(f'Release test gate passed: {total} tests, all critical suites present.')
return 0
if __name__ == '__main__':
sys.exit(main())
+54
View File
@@ -0,0 +1,54 @@
import importlib.util
from pathlib import Path
import tempfile
import unittest
import xml.etree.ElementTree as ET
spec = importlib.util.spec_from_file_location(
'test_results_gate', Path(__file__).parents[1] / 'scripts/check_test_results.py')
gate = importlib.util.module_from_spec(spec)
spec.loader.exec_module(gate)
class ReleaseTestGateTest(unittest.TestCase):
def setUp(self):
self.temp = tempfile.TemporaryDirectory()
self.addCleanup(self.temp.cleanup)
self.directory = Path(self.temp.name)
for classname, names in gate.REQUIRED.items():
suite = ET.Element('testsuite', name=classname)
for name in names or {'regressionTest'}:
ET.SubElement(suite, 'testcase', classname=classname, name=name)
ET.ElementTree(suite).write(self.directory / f'TEST-{classname}.xml')
def change_worker_report(self, change):
path = self.directory / f'TEST-{gate.WORKERS}.xml'
tree = ET.parse(path)
change(tree.getroot())
tree.write(path)
def test_all_required_tests_pass(self):
self.assertEqual(gate.check([self.directory]), 10)
def test_empty_report_directory_blocks_release(self):
with self.assertRaisesRegex(ValueError, 'Missing critical test suite'):
gate.check([self.directory / 'missing'])
def test_failed_worker_test_blocks_release(self):
self.change_worker_report(lambda r: ET.SubElement(r[0], 'failure'))
with self.assertRaisesRegex(ValueError, 'Failed test'):
gate.check([self.directory])
def test_skipped_worker_test_blocks_release(self):
self.change_worker_report(lambda r: ET.SubElement(r[0], 'skipped'))
with self.assertRaisesRegex(ValueError, 'Skipped critical test'):
gate.check([self.directory])
def test_removed_coroutine_worker_test_blocks_release(self):
def remove(root):
for case in list(root):
if case.get('name') == 'matrixCoroutineWorkerIsCreatedByTheApplicationFactory':
root.remove(case)
self.change_worker_report(remove)
with self.assertRaisesRegex(ValueError, 'Missing critical tests'):
gate.check([self.directory])
+5 -2
View File
@@ -63,8 +63,11 @@ jobs:
env:
BUILD_NUMBER: ${{ github.run_number }}
- name: Test Matrix bridge
run: ./gradlew :remotrix-sync:testDebugUnitTest
- name: Test worker factory and Matrix bridge
run: |
set -eu
./gradlew :presentation:cleanTestDebugUnitTest :remotrix-sync:cleanTestDebugUnitTest :presentation:testDebugUnitTest :remotrix-sync:testDebugUnitTest
python3 .gitea/scripts/check_test_results.py
- name: Build Debug APK
run: |