mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-10 17:30:11 +01:00
💇 implement review nits
Implement review nits as requested bei @eighthave in https://gitlab.com/fdroid/fdroidserver/-/merge_requests/1471
This commit is contained in:
parent
3cf3685280
commit
0fa88c5c20
@ -231,16 +231,15 @@
|
|||||||
#
|
#
|
||||||
# github_token: {env: GITHUB_TOKEN}
|
# github_token: {env: GITHUB_TOKEN}
|
||||||
# github_releases:
|
# github_releases:
|
||||||
# - repo: f-droid/fdroidclient
|
# - projectUrl: https://github.com/f-droid/fdroidclient
|
||||||
# packages:
|
# packageNames:
|
||||||
# - org.fdroid.basic
|
# - org.fdroid.basic
|
||||||
# - org.fdroid.fdroid
|
# - org.fdroid.fdroid
|
||||||
# release_notes_prepend: |
|
# release_notes_prepend: |
|
||||||
# Re-post of official F-Droid App release from https://f-droid.org
|
# Re-post of official F-Droid App release from https://f-droid.org
|
||||||
# - repo: example/app
|
# - projectUrl: https://github.com/example/app
|
||||||
|
# packageNames: com.example.app
|
||||||
# token: {env: GITHUB_TOKEN_EXAMPLE}
|
# token: {env: GITHUB_TOKEN_EXAMPLE}
|
||||||
# packages:
|
|
||||||
# - com.example.app
|
|
||||||
|
|
||||||
|
|
||||||
# Most git hosting services have hard size limits for each git repo.
|
# Most git hosting services have hard size limits for each git repo.
|
||||||
|
@ -1167,7 +1167,7 @@ def upload_to_github_releases(repo_section, gh_config, global_gh_token):
|
|||||||
|
|
||||||
package_names = []
|
package_names = []
|
||||||
for repo_conf in gh_config:
|
for repo_conf in gh_config:
|
||||||
for package_name in repo_conf.get('packages', []):
|
for package_name in repo_conf.get('packageNames', []):
|
||||||
package_names.append(package_name)
|
package_names.append(package_name)
|
||||||
|
|
||||||
release_infos = fdroidserver.deploy.find_release_infos(
|
release_infos = fdroidserver.deploy.find_release_infos(
|
||||||
@ -1179,12 +1179,12 @@ def upload_to_github_releases(repo_section, gh_config, global_gh_token):
|
|||||||
|
|
||||||
|
|
||||||
def upload_to_github_releases_repo(repo_conf, release_infos, global_gh_token):
|
def upload_to_github_releases_repo(repo_conf, release_infos, global_gh_token):
|
||||||
repo = repo_conf.get("repo")
|
projectUrl = repo_conf.get("projectUrl")
|
||||||
if not repo:
|
if not projectUrl:
|
||||||
logging.warning(
|
logging.warning(
|
||||||
_(
|
_(
|
||||||
"One of the 'github_releases' config items is missing the "
|
"One of the 'github_releases' config items is missing the "
|
||||||
"'repo' value. skipping ..."
|
"'projectUrl' value. skipping ..."
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@ -1197,12 +1197,14 @@ def upload_to_github_releases_repo(repo_conf, release_infos, global_gh_token):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
packages = repo_conf.get("packages", [])
|
conf_package_names = repo_conf.get("packageNames", [])
|
||||||
if not packages:
|
if type(conf_package_names) == str:
|
||||||
|
conf_package_names = [conf_package_names]
|
||||||
|
if not conf_package_names:
|
||||||
logging.warning(
|
logging.warning(
|
||||||
_(
|
_(
|
||||||
"One of the 'github_releases' config itmes is missing the "
|
"One of the 'github_releases' config itmes is missing the "
|
||||||
"'packages' value. skipping ..."
|
"'packageNames' value. skipping ..."
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@ -1210,11 +1212,11 @@ def upload_to_github_releases_repo(repo_conf, release_infos, global_gh_token):
|
|||||||
# lookup all versionNames (git tags) for all packages available in the
|
# lookup all versionNames (git tags) for all packages available in the
|
||||||
# local fdroid repo
|
# local fdroid repo
|
||||||
all_local_versions = set()
|
all_local_versions = set()
|
||||||
for package_name in repo_conf['packages']:
|
for package_name in conf_package_names:
|
||||||
for version in release_infos.get(package_name, {}).keys():
|
for version in release_infos.get(package_name, {}).keys():
|
||||||
all_local_versions.add(version)
|
all_local_versions.add(version)
|
||||||
|
|
||||||
gh = fdroidserver.github.GithubApi(token, repo)
|
gh = fdroidserver.github.GithubApi(token, projectUrl)
|
||||||
unreleased_tags = gh.list_unreleased_tags()
|
unreleased_tags = gh.list_unreleased_tags()
|
||||||
|
|
||||||
for version in all_local_versions:
|
for version in all_local_versions:
|
||||||
@ -1223,20 +1225,22 @@ def upload_to_github_releases_repo(repo_conf, release_infos, global_gh_token):
|
|||||||
# is set. (releaseChannels usually mean it's e.g. an alpha or beta
|
# is set. (releaseChannels usually mean it's e.g. an alpha or beta
|
||||||
# version)
|
# version)
|
||||||
if (
|
if (
|
||||||
not release_infos.get(packages[0], {})
|
not release_infos.get(conf_package_names[0], {})
|
||||||
.get(version, {})
|
.get(version, {})
|
||||||
.get('hasReleaseChannels')
|
.get('hasReleaseChannels')
|
||||||
):
|
):
|
||||||
# collect files associated with this github release
|
# collect files associated with this github release
|
||||||
files = []
|
files = []
|
||||||
for package in packages:
|
for package in conf_package_names:
|
||||||
files.extend(
|
files.extend(
|
||||||
release_infos.get(package, {}).get(version, {}).get('files', [])
|
release_infos.get(package, {}).get(version, {}).get('files', [])
|
||||||
)
|
)
|
||||||
# always use the whatsNew text from the first app listed in
|
# always use the whatsNew text from the first app listed in
|
||||||
# config.qml github_releases.packages
|
# config.yml github_releases.packageNames
|
||||||
text = (
|
text = (
|
||||||
release_infos.get(packages[0], {}).get(version, {}).get('whatsNew')
|
release_infos.get(conf_package_names[0], {})
|
||||||
|
.get(version, {})
|
||||||
|
.get('whatsNew')
|
||||||
or ''
|
or ''
|
||||||
)
|
)
|
||||||
if 'release_notes_prepend' in repo_conf:
|
if 'release_notes_prepend' in repo_conf:
|
||||||
@ -1330,7 +1334,8 @@ def main():
|
|||||||
logging.warning(
|
logging.warning(
|
||||||
_('No option set! Edit your config.yml to set at least one of these:')
|
_('No option set! Edit your config.yml to set at least one of these:')
|
||||||
+ '\nserverwebroot, servergitmirrors, local_copy_dir, awsbucket, '
|
+ '\nserverwebroot, servergitmirrors, local_copy_dir, awsbucket, '
|
||||||
+ 'virustotal_apikey, androidobservatory, or binary_transparency_remote'
|
+ 'virustotal_apikey, androidobservatory, github_releases '
|
||||||
|
+ 'or binary_transparency_remote'
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -33,7 +33,10 @@ class GithubApi:
|
|||||||
|
|
||||||
def __init__(self, api_token, repo_path):
|
def __init__(self, api_token, repo_path):
|
||||||
self._api_token = api_token
|
self._api_token = api_token
|
||||||
self._repo_path = repo_path
|
if repo_path.startswith("https://github.com/"):
|
||||||
|
self._repo_path = repo_path[19:]
|
||||||
|
else:
|
||||||
|
self._repo_path = repo_path
|
||||||
|
|
||||||
def _req(self, url, data=None):
|
def _req(self, url, data=None):
|
||||||
h = {
|
h = {
|
||||||
|
@ -1313,12 +1313,12 @@ class GitHubReleasesTest(unittest.TestCase):
|
|||||||
def test_upload_to_github_releases(self):
|
def test_upload_to_github_releases(self):
|
||||||
gh_config = [
|
gh_config = [
|
||||||
{
|
{
|
||||||
"repo": "example/app",
|
"projectUrl": "https://github.com/example/app",
|
||||||
"packages": ["com.example.app", "another.app"],
|
"packageNames": ["com.example.app", "another.app"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"repo": "custom/app",
|
"projectUrl": "https://github.com/custom/app",
|
||||||
"packages": ["more.custom.app"],
|
"packageNames": ["more.custom.app"],
|
||||||
"token": "custom_token",
|
"token": "custom_token",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@ -1343,21 +1343,22 @@ class GitHubReleasesTest(unittest.TestCase):
|
|||||||
["com.example.app", "another.app", "more.custom.app"],
|
["com.example.app", "another.app", "more.custom.app"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.maxDiff = None
|
||||||
self.assertListEqual(
|
self.assertListEqual(
|
||||||
urr_mock.call_args_list,
|
urr_mock.call_args_list,
|
||||||
[
|
[
|
||||||
unittest.mock.call(
|
unittest.mock.call(
|
||||||
{
|
{
|
||||||
"repo": "example/app",
|
"projectUrl": "https://github.com/example/app",
|
||||||
"packages": ["com.example.app", "another.app"],
|
"packageNames": ["com.example.app", "another.app"],
|
||||||
},
|
},
|
||||||
"fri_result",
|
"fri_result",
|
||||||
"fake_global_token",
|
"fake_global_token",
|
||||||
),
|
),
|
||||||
unittest.mock.call(
|
unittest.mock.call(
|
||||||
{
|
{
|
||||||
"repo": "custom/app",
|
"projectUrl": "https://github.com/custom/app",
|
||||||
"packages": ["more.custom.app"],
|
"packageNames": ["more.custom.app"],
|
||||||
"token": "custom_token",
|
"token": "custom_token",
|
||||||
},
|
},
|
||||||
"fri_result",
|
"fri_result",
|
||||||
@ -1370,8 +1371,8 @@ class GitHubReleasesTest(unittest.TestCase):
|
|||||||
class Test_UploadToGithubReleasesRepo(unittest.TestCase):
|
class Test_UploadToGithubReleasesRepo(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.repo_conf = {
|
self.repo_conf = {
|
||||||
"repo": "example/app",
|
"projectUrl": "https://github.com/example/app",
|
||||||
"packages": ["com.example.app", "com.example.altapp", "another.app"],
|
"packageNames": ["com.example.app", "com.example.altapp", "another.app"],
|
||||||
}
|
}
|
||||||
self.release_infos = {
|
self.release_infos = {
|
||||||
"com.example.app": {
|
"com.example.app": {
|
||||||
@ -1414,7 +1415,9 @@ class Test_UploadToGithubReleasesRepo(unittest.TestCase):
|
|||||||
"global_token",
|
"global_token",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.api_constructor.assert_called_once_with("global_token", "example/app")
|
self.api_constructor.assert_called_once_with(
|
||||||
|
"global_token", "https://github.com/example/app"
|
||||||
|
)
|
||||||
|
|
||||||
self.assertListEqual(
|
self.assertListEqual(
|
||||||
self.api.create_release.call_args_list,
|
self.api.create_release.call_args_list,
|
||||||
@ -1441,7 +1444,9 @@ class Test_UploadToGithubReleasesRepo(unittest.TestCase):
|
|||||||
"global_token",
|
"global_token",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.api_constructor.assert_called_once_with("local_token", "example/app")
|
self.api_constructor.assert_called_once_with(
|
||||||
|
"local_token", "https://github.com/example/app"
|
||||||
|
)
|
||||||
|
|
||||||
self.assertListEqual(
|
self.assertListEqual(
|
||||||
self.api.create_release.call_args_list,
|
self.api.create_release.call_args_list,
|
||||||
|
Loading…
Reference in New Issue
Block a user