Skip to content

Commit

Permalink
Update release checks to not distinguish between main and non-main re…
Browse files Browse the repository at this point in the history
…po (#22)
  • Loading branch information
rchl authored Sep 22, 2020
1 parent 96e566b commit c83f1a9
Showing 1 changed file with 17 additions and 39 deletions.
56 changes: 17 additions & 39 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,55 +408,33 @@ def _test_dependency(self, include, data):
'url': str
}

def _test_release(self, package_name, data, dependency, main_repo=True):
def _test_release(self, package_name, data, dependency):
# Test for required keys (and fail early)
if main_repo:
if dependency:
condition = (
'base' in data
and ('tags' in data or 'branch' in data)
or ('sha256' in data
and ('url' not in data
or data['url'].startswith('http://')))
)
self.assertTrue(condition,
'A release must have a "base" and a "tags" or "branch" key '
'if it is in the main repository. For custom '
'releases, a custom repository.json file must be '
'hosted elsewhere. The only exception to this rule '
'is for packages that can not be served over HTTPS '
'since they help bootstrap proper secure HTTP '
'support for Sublime Text.')
else:
self.assertTrue(('tags' in data or 'branch' in data),
'A release must have a "tags" key or "branch" key '
'if it is in the main repository. For custom '
'releases, a custom repository.json file must be '
'hosted elsewhere.')
for key in ('url', 'version', 'date'):
self.assertNotIn(key, data,
'The version, date and url keys should not be '
'used in the main repository since a pull '
'request would be necessary for every release')

elif 'tags' not in data and 'branch' not in data:
if dependency:
if dependency:
if 'url' in data:
if data['url'].startswith('http://'):
self.assertTrue('sha256' in data,
'A release must provide "sha256" key if served over HTTP')
for key in ('url', 'version'):
self.assertIn(key, data,
'A release must provide "url" and "version" '
'keys if it does not specify "tags" or "branch"')
else:
for key in ('url', 'version', 'date'):
self.assertIn(key, data,
'A release must provide "url", "version" and '
'"date" keys if it does not specify "tags" or'
'"branch"')
self.assertTrue('base' in data and ('tags' in data or 'branch' in data),
'A release must have a "base" and a "tags" or "branch" key.')

else:
if 'tags' in data or 'branch' in data:
for key in ('url', 'version', 'date'):
self.assertNotIn(key, data,
'The key "%s" is redundant when "tags" or '
'"branch" is specified' % key)
else:
if not dependency:
for key in ('url', 'version', 'date'):
self.assertIn(key, data,
'A release must provide "url", "version" and '
'"date" keys if it does not specify "tags" or'
'"branch"')

self.assertIn('sublime_text', data,
'A sublime text version selector is required')
Expand Down Expand Up @@ -665,7 +643,7 @@ def _include_tests(cls, path, stream):
for release in package['releases']:
(yield cls._test_release,
("%s (%s)" % (package_name, path),
release, False, False))
release, False))
if 'includes' in data:
for include in data['includes']:
i_url = urljoin(path, include)
Expand Down

0 comments on commit c83f1a9

Please sign in to comment.