mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-05 18:50:09 +02:00
nightly: update Raw URLs to fix breakage and avoid redirects
This commit is contained in:
parent
b352e9a9cc
commit
c6cf0468ed
@ -131,6 +131,17 @@ def _ssh_key_from_debug_keystore(keystore=KEYSTORE_FILE):
|
|||||||
return ssh_private_key_file
|
return ssh_private_key_file
|
||||||
|
|
||||||
|
|
||||||
|
def get_repo_base_url(clone_url, repo_git_base, force_type=None):
|
||||||
|
if force_type is None:
|
||||||
|
force_type = urlparse(clone_url).netloc
|
||||||
|
if force_type == 'gitlab.com':
|
||||||
|
return clone_url + '/-/raw/master/fdroid'
|
||||||
|
if force_type == 'github.com':
|
||||||
|
return 'https://raw.githubusercontent.com/%s/master/fdroid' % repo_git_base
|
||||||
|
print(_('ERROR: unsupported git host "%s", patches welcome!') % force_type)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
parser = ArgumentParser()
|
parser = ArgumentParser()
|
||||||
@ -200,11 +211,12 @@ def main():
|
|||||||
cibase = os.getcwd()
|
cibase = os.getcwd()
|
||||||
os.makedirs(repodir, exist_ok=True)
|
os.makedirs(repodir, exist_ok=True)
|
||||||
|
|
||||||
|
# the 'master' branch is hardcoded in fdroidserver/deploy.py
|
||||||
if 'CI_PROJECT_PATH' in os.environ and 'CI_PROJECT_URL' in os.environ:
|
if 'CI_PROJECT_PATH' in os.environ and 'CI_PROJECT_URL' in os.environ:
|
||||||
# we are in GitLab CI
|
# we are in GitLab CI
|
||||||
repo_git_base = os.getenv('CI_PROJECT_PATH') + NIGHTLY
|
repo_git_base = os.getenv('CI_PROJECT_PATH') + NIGHTLY
|
||||||
clone_url = os.getenv('CI_PROJECT_URL') + NIGHTLY
|
clone_url = os.getenv('CI_PROJECT_URL') + NIGHTLY
|
||||||
repo_base = clone_url + '/raw/master/fdroid'
|
repo_base = get_repo_base_url(clone_url, repo_git_base, force_type='gitlab.com')
|
||||||
servergitmirror = 'git@' + urlparse(clone_url).netloc + ':' + repo_git_base
|
servergitmirror = 'git@' + urlparse(clone_url).netloc + ':' + repo_git_base
|
||||||
deploy_key_url = clone_url + '/-/settings/repository#js-deploy-keys-settings'
|
deploy_key_url = clone_url + '/-/settings/repository#js-deploy-keys-settings'
|
||||||
git_user_name = os.getenv('GITLAB_USER_NAME')
|
git_user_name = os.getenv('GITLAB_USER_NAME')
|
||||||
@ -213,8 +225,7 @@ def main():
|
|||||||
# we are in Travis CI
|
# we are in Travis CI
|
||||||
repo_git_base = os.getenv('TRAVIS_REPO_SLUG') + NIGHTLY
|
repo_git_base = os.getenv('TRAVIS_REPO_SLUG') + NIGHTLY
|
||||||
clone_url = 'https://github.com/' + repo_git_base
|
clone_url = 'https://github.com/' + repo_git_base
|
||||||
_branch = os.getenv('TRAVIS_BRANCH')
|
repo_base = get_repo_base_url(clone_url, repo_git_base, force_type='github.com')
|
||||||
repo_base = 'https://raw.githubusercontent.com/' + repo_git_base + '/' + _branch + '/fdroid'
|
|
||||||
servergitmirror = 'git@github.com:' + repo_git_base
|
servergitmirror = 'git@github.com:' + repo_git_base
|
||||||
deploy_key_url = ('https://github.com/' + repo_git_base + '/settings/keys'
|
deploy_key_url = ('https://github.com/' + repo_git_base + '/settings/keys'
|
||||||
+ '\nhttps://developer.github.com/v3/guides/managing-deploy-keys/#deploy-keys')
|
+ '\nhttps://developer.github.com/v3/guides/managing-deploy-keys/#deploy-keys')
|
||||||
@ -229,7 +240,7 @@ def main():
|
|||||||
repo_git_base = (os.getenv('CIRCLE_PROJECT_USERNAME')
|
repo_git_base = (os.getenv('CIRCLE_PROJECT_USERNAME')
|
||||||
+ '/' + os.getenv('CIRCLE_PROJECT_REPONAME') + NIGHTLY)
|
+ '/' + os.getenv('CIRCLE_PROJECT_REPONAME') + NIGHTLY)
|
||||||
clone_url = os.getenv('CIRCLE_REPOSITORY_URL') + NIGHTLY
|
clone_url = os.getenv('CIRCLE_REPOSITORY_URL') + NIGHTLY
|
||||||
repo_base = clone_url + '/raw/master/fdroid'
|
repo_base = get_repo_base_url(clone_url, repo_git_base, force_type='github.com')
|
||||||
servergitmirror = 'git@' + urlparse(clone_url).netloc + ':' + repo_git_base
|
servergitmirror = 'git@' + urlparse(clone_url).netloc + ':' + repo_git_base
|
||||||
deploy_key_url = ('https://github.com/' + repo_git_base + '/settings/keys'
|
deploy_key_url = ('https://github.com/' + repo_git_base + '/settings/keys'
|
||||||
+ '\nhttps://developer.github.com/v3/guides/managing-deploy-keys/#deploy-keys')
|
+ '\nhttps://developer.github.com/v3/guides/managing-deploy-keys/#deploy-keys')
|
||||||
@ -239,7 +250,7 @@ def main():
|
|||||||
# we are in Github actions
|
# we are in Github actions
|
||||||
repo_git_base = (os.getenv('GITHUB_REPOSITORY') + NIGHTLY)
|
repo_git_base = (os.getenv('GITHUB_REPOSITORY') + NIGHTLY)
|
||||||
clone_url = (os.getenv('GITHUB_SERVER_URL') + '/' + repo_git_base)
|
clone_url = (os.getenv('GITHUB_SERVER_URL') + '/' + repo_git_base)
|
||||||
repo_base = clone_url + '/raw/master/fdroid'
|
repo_base = get_repo_base_url(clone_url, repo_git_base, force_type='github.com')
|
||||||
servergitmirror = 'git@' + urlparse(clone_url).netloc + ':' + repo_git_base
|
servergitmirror = 'git@' + urlparse(clone_url).netloc + ':' + repo_git_base
|
||||||
deploy_key_url = ('https://github.com/' + repo_git_base + '/settings/keys'
|
deploy_key_url = ('https://github.com/' + repo_git_base + '/settings/keys'
|
||||||
+ '\nhttps://developer.github.com/v3/guides/managing-deploy-keys/#deploy-keys')
|
+ '\nhttps://developer.github.com/v3/guides/managing-deploy-keys/#deploy-keys')
|
||||||
|
56
tests/nightly.TestCase
Executable file
56
tests/nightly.TestCase
Executable file
@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import inspect
|
||||||
|
import optparse
|
||||||
|
import os
|
||||||
|
import requests
|
||||||
|
import sys
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
localmodule = os.path.realpath(
|
||||||
|
os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..')
|
||||||
|
)
|
||||||
|
print('localmodule: ' + localmodule)
|
||||||
|
if localmodule not in sys.path:
|
||||||
|
sys.path.insert(0, localmodule)
|
||||||
|
|
||||||
|
from fdroidserver import common, nightly
|
||||||
|
|
||||||
|
|
||||||
|
class NightlyTest(unittest.TestCase):
|
||||||
|
def test_get_repo_base_url(self):
|
||||||
|
for clone_url, repo_git_base, result in [
|
||||||
|
(
|
||||||
|
'https://github.com/onionshare/onionshare-android-nightly',
|
||||||
|
'onionshare/onionshare-android-nightly',
|
||||||
|
'https://raw.githubusercontent.com/onionshare/onionshare-android-nightly/master/fdroid',
|
||||||
|
),
|
||||||
|
(
|
||||||
|
'https://gitlab.com/fdroid/fdroidclient-nightly',
|
||||||
|
'fdroid/fdroidclient-nightly',
|
||||||
|
'https://gitlab.com/fdroid/fdroidclient-nightly/-/raw/master/fdroid',
|
||||||
|
),
|
||||||
|
]:
|
||||||
|
url = nightly.get_repo_base_url(clone_url, repo_git_base)
|
||||||
|
self.assertEqual(result, url)
|
||||||
|
r = requests.head(os.path.join(url, 'repo/index-v1.jar'))
|
||||||
|
# gitlab.com often returns 403 Forbidden from their cloudflare restrictions
|
||||||
|
self.assertTrue(r.status_code in (200, 403), 'should not be a redirect')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
os.chdir(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
parser = optparse.OptionParser()
|
||||||
|
parser.add_option(
|
||||||
|
"-v",
|
||||||
|
"--verbose",
|
||||||
|
action="store_true",
|
||||||
|
default=False,
|
||||||
|
help="Spew out even more information than normal",
|
||||||
|
)
|
||||||
|
(common.options, args) = parser.parse_args(['--verbose'])
|
||||||
|
|
||||||
|
newSuite = unittest.TestSuite()
|
||||||
|
newSuite.addTest(unittest.makeSuite(NightlyTest))
|
||||||
|
unittest.main(failfast=False)
|
Loading…
Reference in New Issue
Block a user