Skip to content

Commit b7e6e5a

Browse files
authored
Merge branch 'master' into cot-log
2 parents 391c1ef + 6c36984 commit b7e6e5a

File tree

6 files changed

+77
-6
lines changed

6 files changed

+77
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [22.1.0] - 2019-03-19
6+
### Added
7+
- `event.repository.full_name` and `event.pull_request.base.repo.full_name` on `cot_verify` (for GitHub repos)
8+
59
## [22.0.1] - 2019-03-13
610
### Fixed
711
- Allow snapcraft beta scope on mozilla-release

scriptworker/cot/verify.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@
3030
from scriptworker.context import Context
3131
from scriptworker.ed25519 import ed25519_public_key_from_string, verify_ed25519_signature
3232
from scriptworker.exceptions import CoTError, BaseDownloadError, ScriptWorkerEd25519Error, ScriptWorkerGPGException
33-
from scriptworker.github import GitHubRepository
33+
from scriptworker.github import (
34+
GitHubRepository,
35+
extract_github_repo_owner_and_name,
36+
extract_github_repo_full_name,
37+
)
3438
from scriptworker.gpg import get_body, GPG
3539
from scriptworker.log import contextual_log_handler
3640
from scriptworker.task import (
37-
extract_github_repo_owner_and_name,
3841
get_action_callback_name,
3942
get_and_check_project,
4043
get_and_check_tasks_for,
@@ -1140,6 +1143,7 @@ async def _get_additional_github_releases_jsone_context(decision_link):
11401143
# This can't be done at the moment because some mobile projects still rely on the
11411144
# bad value
11421145
'clone_url': repo_url,
1146+
'full_name': extract_github_repo_full_name(repo_url),
11431147
'html_url': repo_url,
11441148
},
11451149
'release': {
@@ -1177,6 +1181,7 @@ def _get_additional_git_cron_jsone_context(decision_link):
11771181
# This can't be done at the moment because some mobile projects still rely on the
11781182
# bad value
11791183
'clone_url': repo,
1184+
'full_name': extract_github_repo_full_name(repo),
11801185
'html_url': repo,
11811186
},
11821187
'release': {
@@ -1220,6 +1225,11 @@ async def _get_additional_github_pull_request_jsone_context(decision_link):
12201225
'html_url': pull_request_data['head']['repo']['html_url'],
12211226
},
12221227
'pull_request': {
1228+
'base': {
1229+
'repo': {
1230+
'full_name': pull_request_data['base']['repo']['full_name'],
1231+
},
1232+
},
12231233
'head': {
12241234
'ref': pull_request_data['head']['ref'],
12251235
'sha': pull_request_data['head']['sha'],
@@ -1230,7 +1240,7 @@ async def _get_additional_github_pull_request_jsone_context(decision_link):
12301240
# This becomes a problem if a staging release was kicked off and the PR got
12311241
# updated in the meantime.
12321242
'pushed_at': get_push_date_time(task, source_env_prefix),
1233-
}
1243+
},
12341244
},
12351245
'title': pull_request_data['title'],
12361246
'number': pull_request_number,
@@ -1263,6 +1273,7 @@ async def _get_additional_github_push_jsone_context(decision_link):
12631273
return {
12641274
'event': {
12651275
'repository': {
1276+
'full_name': extract_github_repo_full_name(repo_url),
12661277
'html_url': repo_url,
12671278
'pushed_at': get_push_date_time(task, source_env_prefix),
12681279
},

scriptworker/github.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,24 @@ def extract_github_repo_owner_and_name(url):
160160
return repo_owner, _strip_trailing_dot_git(repo_name)
161161

162162

163+
def extract_github_repo_full_name(url):
164+
"""Given an URL, return the full name of it.
165+
166+
The full name is ``RepoOwner/RepoName``.
167+
168+
Args:
169+
url (str): The URL to the GitHub repository
170+
171+
Raises:
172+
ValueError: on url that aren't from github
173+
174+
Returns:
175+
str: the full name.
176+
177+
"""
178+
return '/'.join(extract_github_repo_owner_and_name(url))
179+
180+
163181
def extract_github_repo_and_revision_from_source_url(url):
164182
"""Given an URL, return the repo name and who owns it.
165183

scriptworker/test/test_cot_verify.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,7 @@ async def test_populate_jsone_context_github_release(mocker, mobile_chain, mobil
13341334
'event': {
13351335
'repository': {
13361336
'clone_url': 'https://github.com/mozilla-mobile/focus-android',
1337+
'full_name': 'mozilla-mobile/focus-android',
13371338
'html_url': 'https://github.com/mozilla-mobile/focus-android',
13381339
},
13391340
'release': {
@@ -1371,6 +1372,7 @@ async def test_populate_jsone_context_git_cron(mobile_chain, mobile_cron_link, h
13711372
'event': {
13721373
'repository': {
13731374
'clone_url': 'https://github.com/mozilla-mobile/focus-android',
1375+
'full_name': 'mozilla-mobile/focus-android',
13741376
'html_url': 'https://github.com/mozilla-mobile/focus-android',
13751377
},
13761378
'release': {
@@ -1413,6 +1415,7 @@ async def test_populate_jsone_context_github_push(mocker, mobile_chain, mobile_g
14131415
assert context == {
14141416
'event': {
14151417
'repository': {
1418+
'full_name': 'mozilla-mobile/focus-android',
14161419
'html_url': 'https://github.com/mozilla-mobile/focus-android',
14171420
'pushed_at': '1549022400',
14181421
},
@@ -1450,6 +1453,11 @@ async def test_populate_jsone_context_github_pull_request(mocker, mobile_chain_p
14501453
}
14511454

14521455
github_repo_mock.get_pull_request.return_value = {
1456+
'base': {
1457+
'repo': {
1458+
'full_name': 'mozilla-mobile/focus-android',
1459+
},
1460+
},
14531461
'head': {
14541462
'ref': 'some-branch',
14551463
'repo': {
@@ -1489,6 +1497,11 @@ async def test_populate_jsone_context_github_pull_request(mocker, mobile_chain_p
14891497
'html_url': 'https://github.com/JohanLorenzo/focus-android',
14901498
},
14911499
'pull_request': {
1500+
'base': {
1501+
'repo': {
1502+
'full_name': 'mozilla-mobile/focus-android',
1503+
},
1504+
},
14921505
'head': {
14931506
'ref': 'some-branch',
14941507
'sha': 'somerevision',
@@ -1515,6 +1528,7 @@ async def test_populate_jsone_context_github_pull_request(mocker, mobile_chain_p
15151528
'tasks_for': 'github-pull-request',
15161529
}
15171530

1531+
15181532
@pytest.mark.asyncio
15191533
async def test_populate_jsone_context_fail(mobile_chain, mobile_github_release_link):
15201534
with pytest.raises(CoTError):

scriptworker/test/test_github.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,30 @@ def test_extract_github_repo_owner_and_name(repo_url, expected_user, expected_re
211211
assert github.extract_github_repo_owner_and_name(repo_url) == (expected_user, expected_repo_name)
212212

213213

214+
@pytest.mark.parametrize('repo_url, expected, raises', ((
215+
'https://github.com/mozilla-mobile/android-components',
216+
'mozilla-mobile/android-components', False
217+
), (
218+
'https://github.com/mozilla-mobile/android-components.git',
219+
'mozilla-mobile/android-components', False
220+
), (
221+
'https://github.com/JohanLorenzo/android-components',
222+
'JohanLorenzo/android-components', False
223+
), (
224+
'https://github.com/JohanLorenzo/android-components/raw/0123456789abcdef0123456789abcdef01234567/.taskcluster.yml',
225+
'JohanLorenzo/android-components', False
226+
), (
227+
'https://hg.mozilla.org/mozilla-central',
228+
None, True
229+
)))
230+
def test_extract_github_repo_full_name(repo_url, expected, raises):
231+
if raises:
232+
with pytest.raises(ValueError):
233+
github.extract_github_repo_full_name(repo_url)
234+
else:
235+
assert github.extract_github_repo_full_name(repo_url) == expected
236+
237+
214238
@pytest.mark.parametrize('repo_url, expected_user, expected_repo_name, raises', ((
215239
'https://github.com/JohanLorenzo/android-components/raw/0123456789abcdef0123456789abcdef01234567/.taskcluster.yml',
216240
'https://github.com/JohanLorenzo/android-components', '0123456789abcdef0123456789abcdef01234567', False,

version.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"version": [
33
22,
4-
0,
5-
1
4+
1,
5+
0
66
],
7-
"version_string": "22.0.1"
7+
"version_string": "22.1.0"
88
}

0 commit comments

Comments
 (0)