From 299e3e5f4cc55dae7123e610dc068806f2b9002b Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 24 Apr 2024 14:53:30 +0200 Subject: [PATCH 1/3] index: handle image processing diffs across various Python versions Apparently, the newest Python thingies strip the PNGs a tiny bit smaller, so a fixed file size will lead to the test failing: https://gitlab.com/fdroid/fdroidserver/-/jobs/6703386074 ``` Traceback (most recent call last): File "/builds/fdroid/fdroidserver/tests/index.TestCase", line 704, in test_package_metadata self.assertEqual(36027, metadata['featureGraphic']['en-US']['size']) AssertionError: 36027 != 35619 ``` --- tests/index.TestCase | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/index.TestCase b/tests/index.TestCase index 2f137608..633c0e5f 100755 --- a/tests/index.TestCase +++ b/tests/index.TestCase @@ -701,8 +701,14 @@ class IndexTest(unittest.TestCase): app = apps[appid] metadata = index.package_metadata(app, 'repo') # files - self.assertEqual(36027, metadata['featureGraphic']['en-US']['size']) - self.assertEqual(1413, metadata['icon']['en-US']['size']) + self.assertEqual( + os.path.getsize(f'repo/{appid}/en-US/featureGraphic.png'), + metadata['featureGraphic']['en-US']['size'], + ) + self.assertEqual( + os.path.getsize(f'repo/{appid}/en-US/icon.png'), + metadata['icon']['en-US']['size'], + ) # localized strings self.assertEqual({'en-US': 'title'}, metadata['name']) self.assertEqual({'en-US': 'video'}, metadata['video']) From 1b65e3383503fa44bf2e38b6c81691d506ed6ba2 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 25 Apr 2024 16:10:59 +0200 Subject: [PATCH 2/3] make it easy to keep test artifacts from jobs When troubleshooting things that are difficult to reproduce locally, like different behaviors in the fedora_latest job, these changes make it easy to keep the test files around after the tests run. For example, if PNGs are processed differently by newer Python versions. --- tests/nightly.TestCase | 5 ++++- tests/testcommon.py | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/nightly.TestCase b/tests/nightly.TestCase index b6d47447..9e505c7f 100755 --- a/tests/nightly.TestCase +++ b/tests/nightly.TestCase @@ -70,7 +70,10 @@ class NightlyTest(unittest.TestCase): def tearDown(self): self.tempdir.cleanup() - os.rmdir(self.testroot) + try: + os.rmdir(self.testroot) + except OSError: # other test modules might have left stuff around + pass def _copy_test_debug_keystore(self): self.dot_android.mkdir() diff --git a/tests/testcommon.py b/tests/testcommon.py index fe3728ba..069ac42e 100644 --- a/tests/testcommon.py +++ b/tests/testcommon.py @@ -18,6 +18,9 @@ import os import sys import tempfile +import unittest + +from pathlib import Path class TmpCwd: @@ -60,3 +63,12 @@ def mkdtemp(): return tempfile.TemporaryDirectory() else: return tempfile.TemporaryDirectory(ignore_cleanup_errors=True) + + +def mkdir_testfiles(localmodule, test): + """Keep the test files in a labeled test dir for easy reference""" + testroot = Path(localmodule) / '.testfiles' + testroot.mkdir(exist_ok=True) + testdir = testroot / unittest.TestCase.id(test) + testdir.mkdir(exist_ok=True) + return tempfile.mkdtemp(dir=testdir) From 5df3d27126e58797f492a691ce1d412b262285da Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 30 Apr 2024 19:23:52 +0200 Subject: [PATCH 3/3] gitlab-ci: stay on Fedora 39 until it is no longer supported We can rely on the debian:testing job to test the bleeding edge, and it is a lot easier to troubleshoot. The Fedora job is a lot harder to troubleshoot than the Debian-based jobs, and they are often quite bleeding edge. Currently, there is a change to either Python or an image processing lib (Pillow?) that now compresses PNGs differently than all previous releases. That breaks the tests based on processing images and checking the SHA-256 matches. 70e7e720b9c2f3cbcf3ae44105abf613fd96767d fdroidserver!669 --- .gitlab-ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 79eb1d45..2b0ab577 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -285,9 +285,7 @@ black: - black --check --diff --color $CI_PROJECT_DIR fedora_latest: - image: fedora:latest - only: - - master@fdroid/fdroidserver + image: fedora:39 # support ends on 2024-11-12 script: # tricks to hopefully make runs more reliable - echo "timeout=600" >> /etc/dnf/dnf.conf