1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-04 22:40:12 +01:00

Merge branch 'fix-ci-post-1134' into 'master'

fix CI jobs post !1134

See merge request fdroid/fdroidserver!1144
This commit is contained in:
Jochen Sprickerhof 2022-06-10 11:01:45 +00:00
commit 6f8afd340d
3 changed files with 109 additions and 13 deletions

View File

@ -281,35 +281,27 @@ fedora_latest:
findutils
git
gnupg
java-1.8.0-openjdk-devel
java-17-openjdk-devel
python3
python3-babel
python3-matplotlib
python3-pip
rsync
unzip
wget
which
- $pip install sdkmanager
- ./setup.py sdist
- useradd -m -c "test account" --password "fakepassword" testuser
- su testuser --login --command "cd `pwd`; $pip install --user dist/fdroidserver-*.tar.gz"
- test -e ~testuser/.local/share/locale/de/LC_MESSAGES/fdroidserver.mo
- wget --no-verbose -O tools.zip https://dl.google.com/android/repository/tools_r25.2.5-linux.zip
- unzip -q tools.zip
- rm tools.zip
- export BUILD_TOOLS_VERSION=`sed -n "s,^MINIMUM_APKSIGNER_BUILD_TOOLS_VERSION\s*=\s*['\"]\(.*\)[['\"],\1,p" fdroidserver/common.py`
- export JAVA_HOME=/etc/alternatives/jre
- export ANDROID_HOME=`pwd`/android-sdk
- mkdir $ANDROID_HOME
- mv tools $ANDROID_HOME/
- mkdir -p $ANDROID_HOME/licenses/
- printf "\n8933bad161af4178b1185d1a37fbf41ea5269c55\nd56f5187479451eabf01fb78af6dfcb131a6481e\n24333f8a63b6825ea9c5514f83c2829b004d1fee" > $ANDROID_HOME/licenses/android-sdk-license
- printf "\n84831b9409646a918e30573bab4c9c91346d8abd" > $ANDROID_HOME/licenses/android-sdk-preview-license
- printf "\n79120722343a6f314e0719f863036c702b0e6b2a\n84831b9409646a918e30573bab4c9c91346d8abd" > $ANDROID_HOME/licenses/android-sdk-preview-license-old
- mkdir ~/.android
- touch ~/.android/repositories.cfg
- echo y | $ANDROID_HOME/tools/bin/sdkmanager "platform-tools" > /dev/null
- echo y | $ANDROID_HOME/tools/bin/sdkmanager "build-tools;$BUILD_TOOLS_VERSION" > /dev/null
- sdkmanager "platform-tools" "build-tools;$BUILD_TOOLS_VERSION"
- chown -R testuser .
- cd tests
- su testuser --login --command
@ -453,7 +445,7 @@ plugin_fetchsrclibs:
# test a full update and deploy cycle to gitlab.com
servergitmirrors:
image: debian:buster
image: debian:bullseye-backports
<<: *apt-template
only:
- master@fdroid/fdroidserver
@ -470,12 +462,15 @@ servergitmirrors:
python3-pil
python3-pip
python3-pycparser
python3-setuptools
python3-venv
rsync
wget
- apt-get install -t bullseye-backports apksigner
- python3 -m venv --system-site-packages env
- . env/bin/activate
- export PYTHONPATH=`pwd`
- export SETUPTOOLS_USE_DISTUTILS=stdlib # https://github.com/pypa/setuptools/issues/2956
- $pip install -e .
- mkdir /root/.ssh/
- ./tests/key-tricks.py

View File

@ -26,6 +26,7 @@ import fdroidserver.build
import fdroidserver.common
import fdroidserver.metadata
import fdroidserver.scanner
import fdroidserver.vmtools
class FakeProcess:
@ -544,6 +545,93 @@ class BuildTest(unittest.TestCase):
self.assertFalse(os.path.exists(production_result))
self.assertFalse(os.path.exists(production_compare_file))
@mock.patch('fdroidserver.vmtools.get_build_vm')
@mock.patch('fdroidserver.vmtools.get_clean_builder')
@mock.patch('paramiko.SSHClient')
@mock.patch('subprocess.check_output')
def test_build_server_cmdline(
self,
subprocess_check_output,
paramiko_SSHClient,
fdroidserver_vmtools_get_clean_builder,
fdroidserver_vmtools_get_build_vm,
):
"""Test command line flags passed to the buildserver"""
global cmdline_args
test_flag = ['', False]
def _exec_command(args):
flag = test_flag[0]
if test_flag[1]:
self.assertTrue(flag in args, flag + ' should be present')
else:
self.assertFalse(flag in args, flag + ' should not be present')
testdir = tempfile.mkdtemp(
prefix=inspect.currentframe().f_code.co_name, dir=self.tmpdir
)
os.chdir(testdir)
os.mkdir('tmp')
chan = mock.MagicMock()
chan.exec_command = _exec_command
chan.recv_exit_status = lambda: 0
transport = mock.MagicMock()
transport.open_session = mock.Mock(return_value=chan)
sshs = mock.MagicMock()
sshs.get_transport = mock.Mock(return_value=transport)
paramiko_SSHClient.return_value = sshs
subprocess_check_output.return_value = (
b'0123456789abcdef0123456789abcdefcafebabe'
)
fdroidserver_vmtools_get_clean_builder.side_effect = lambda s: {
'hostname': 'example.com',
'idfile': '/path/to/id/file',
'port': 123,
'user': 'fake',
}
fdroidserver.common.config = {'sdk_path': '/fake/android/sdk/path'}
fdroidserver.build.options = mock.MagicMock()
vcs = mock.Mock()
vcs.getsrclib = mock.Mock(return_value=None)
app = fdroidserver.metadata.App()
app['metadatapath'] = 'metadata/fake.id.yml'
app['id'] = 'fake.id'
app['RepoType'] = 'git'
build = fdroidserver.metadata.Build(
{
'versionCode': 123,
'versionName': '1.2.3',
'commit': '1.2.3',
'disable': False,
}
)
app['Builds'] = [build]
test_flag = ('--on-server', True)
fdroidserver.build.build_server(app, build, vcs, '', '', '', False)
self.assertTrue(fdroidserver_vmtools_get_build_vm.called)
for force in (True, False):
test_flag = ('--force', force)
fdroidserver.build.build_server(app, build, vcs, '', '', '', force)
fdroidserver.build.options.notarball = True
test_flag = ('--no-tarball', True)
fdroidserver.build.build_server(app, build, vcs, '', '', '', False)
fdroidserver.build.options.notarball = False
test_flag = ('--no-tarball', False)
fdroidserver.build.build_server(app, build, vcs, '', '', '', False)
fdroidserver.build.options.skipscan = False
test_flag = ('--scan-binary', True)
fdroidserver.build.build_server(app, build, vcs, '', '', '', False)
fdroidserver.build.options.skipscan = True
test_flag = ('--scan-binary', False)
fdroidserver.build.build_server(app, build, vcs, '', '', '', False)
test_flag = ('--skip-scan', True)
fdroidserver.build.build_server(app, build, vcs, '', '', '', False)
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))

View File

@ -21,6 +21,7 @@ import textwrap
import yaml
import gzip
import stat
from distutils.version import LooseVersion
from zipfile import BadZipFile, ZipFile, ZipInfo
from unittest import mock
from pathlib import Path
@ -782,6 +783,7 @@ class CommonTest(unittest.TestCase):
self.assertEqual(apksigner, config.get('apksigner'))
def test_find_apksigner_system_package_android_home(self):
"""Test that apksigner v30 or newer is found"""
testdir = tempfile.mkdtemp(
prefix=inspect.currentframe().f_code.co_name, dir=self.tmpdir
)
@ -789,8 +791,19 @@ class CommonTest(unittest.TestCase):
android_home = os.getenv('ANDROID_HOME')
if not android_home or not os.path.isdir(android_home):
self.skipTest('SKIPPING since ANDROID_HOME (%s) is not a dir!' % android_home)
if not glob.glob(os.path.join(android_home, 'build-tools', '*', 'apksigner')):
build_tools = glob.glob(os.path.join(android_home, 'build-tools', '*', 'apksigner'))
if not build_tools:
self.skipTest('SKIPPING since ANDROID_HOME (%s) build-tools has no apksigner!' % android_home)
min_version = fdroidserver.common.MINIMUM_APKSIGNER_BUILD_TOOLS_VERSION
version = '0'
for bt in sorted(build_tools):
v = bt.split('/')[-2]
if v == 'debian':
continue
if LooseVersion(version) < LooseVersion(v):
version = v
if LooseVersion(version) < LooseVersion(min_version):
self.skipTest('SKIPPING since build-tools %s or higher is required!' % min_version)
fdroidserver.common.config = {'sdk_path': android_home}
os.environ['PATH'] = '/fake/path/to/avoid/conflicts'
config = fdroidserver.common.read_config()