diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d667e574..65510c45 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -190,6 +190,8 @@ ubuntu_lts_ppa: test_deploy_to_s3_with_rclone: image: debian:bookworm-slim <<: *apt-template + tags: + - saas-linux-small-amd64 # the shared runners are known to support Docker. services: - name: docker:dind command: ["--tls=false"] @@ -208,6 +210,8 @@ test_deploy_to_s3_with_rclone: git python3-venv rclone + # This job requires working docker but will silently fail if docker is not available + - docker info - python3 -m venv --system-site-packages test-venv - . test-venv/bin/activate - pip install testcontainers[minio] diff --git a/tests/test_integration.py b/tests/test_integration.py index 70fe4f7b..2cdf19d9 100755 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -5,7 +5,6 @@ import platform import re import shlex import shutil -import stat import subprocess import sys import threading @@ -43,8 +42,13 @@ common.find_apksigner(conf) USE_APKSIGNER = "apksigner" in conf -def docker_socket_exists(path="/var/run/docker.sock"): - return os.path.exists(path) and stat.S_ISSOCK(os.stat(path).st_mode) +def docker_exists(): + try: + subprocess.check_output(["docker", "info"]) + except Exception: + return False + else: + return True @unittest.skipIf(sys.byteorder == 'big', 'androguard is not ported to big-endian') @@ -1565,8 +1569,11 @@ class IntegrationTest(unittest.TestCase): ) self.assertIn("CurrentVersionCode: 1", Path("metadata/fake.yml").read_text()) - @unittest.skipUnless(docker_socket_exists(), "Docker is not available") + @unittest.skipUnless(docker_exists(), "Docker is not available") def test_update_remote_storage_with_rclone_and_minio(self): + # This test shows how an entire repo can be deployed using rclone. + # To avoid multiple files being copied in the repo since the repo + # directory can change, only two files are used. try: from testcontainers.minio import MinioContainer except ImportError: @@ -1621,7 +1628,7 @@ class IntegrationTest(unittest.TestCase): {'fdroid/repo/SpeedoMeterApp.main_1.apk', 'fdroid/repo/index-v2.json'}, ) - @unittest.skipUnless(docker_socket_exists(), "Docker is not available") + @unittest.skipUnless(docker_exists(), "Docker is not available") def test_update_remote_storage_with_rclone_and_minio_in_index_only_mode(self): try: from testcontainers.minio import MinioContainer @@ -1638,8 +1645,7 @@ class IntegrationTest(unittest.TestCase): repo_section = 'repo' repo = Path(repo_section) repo.mkdir(parents=True, exist_ok=True) - shutil.copy(basedir / 'SpeedoMeterApp.main_1.apk', repo) - shutil.copy(basedir / 'repo/index-v2.json', repo) + shutil.copytree(basedir / repo, repo, dirs_exist_ok=True) # write out config for test use rclone_config = configparser.ConfigParser() @@ -1674,4 +1680,12 @@ class IntegrationTest(unittest.TestCase): # check if apk and index file are available bucket_content = client.list_objects('test-bucket', recursive=True) files_in_bucket = {obj.object_name for obj in bucket_content} - self.assertEqual(files_in_bucket, {'fdroid/repo/index-v2.json'}) + self.assertEqual( + files_in_bucket, + { + 'fdroid/repo/index-v2.json', + 'fdroid/repo/index.xml', + 'fdroid/repo/entry.json', + 'fdroid/repo/index-v1.json', + }, + )