{"action":"created","comment":{"url":"https://api.github.com/repos/snapcore/snapcraft/pulls/comments/182049787","pull_request_review_id":112781432,"id":182049787,"diff_hunk":"@@ -71,6 +72,106 @@ def _validate_epoch(instance):\n     return True\n \n \n+@jsonschema.FormatChecker.cls_checks('architectures')\n+def _validate_architectures(instance):\n+    standalone_build_ons = collections.Counter()\n+    build_ons = collections.Counter()\n+    run_ons = collections.Counter()\n+\n+    saw_strings = False\n+    saw_dicts = False\n+\n+    for mapping in instance:\n+        # This could either be a dict or a string. In the latter case, the\n+        # schema will take care of it. We just need to further validate the\n+        # dict.\n+        if isinstance(mapping, str):\n+            saw_strings = True\n+        elif isinstance(mapping, dict):\n+            saw_dicts = True\n+            build_on = _get_architectures_list(mapping, 'build-on')\n+            build_ons.update(build_on)\n+\n+            # Add to the list of run-ons. However, if no run-on is specified,\n+            # we know it's implicitly the value of build-on, so use that\n+            # for validation instead.\n+            run_on = _get_architectures_list(mapping, 'run-on')\n+            if run_on:\n+                run_ons.update(run_on)\n+            else:\n+                standalone_build_ons.update(build_on)\n+\n+    # Architectures can either be a list of strings, or a list of objects.\n+    # Mixing the two forms is unsupported.\n+    if saw_strings and saw_dicts:\n+        raise jsonschema.exceptions.ValidationError(\n+            'every item must either be a string or an object',\n+            path=['architectures'], instance=mapping)\n+\n+    # At this point, individual build-ons and run-ons have been validated,\n+    # we just need to validate them across each other.\n+\n+    # First of all, if we have a `run-on: [all]` (or a standalone\n+    # `build-on: [all]`) then we should only have one item in the instance,\n+    # otherwise we know we'll have multiple snaps claiming they run on the same\n+    # architectures (i.e. all and something else).\n+    number_of_snaps = len(instance)\n+    if 'all' in run_ons and number_of_snaps > 1:\n+        raise jsonschema.exceptions.ValidationError(\n+            \"one of the items has 'all' in 'run-on', which only makes \"\n+            \"sense if it's the only item, and there are {}\".format(\n+                number_of_snaps),\n+            path=['architectures'], instance=instance)\n+    if 'all' in build_ons and number_of_snaps > 1:\n+        raise jsonschema.exceptions.ValidationError(\n+            \"one of the items has 'all' in 'build-on', which only makes \"\n+            \"sense if it's the only item, and there are {}\".format(\n+                number_of_snaps),\n+            path=['architectures'], instance=instance)\n+\n+    # We want to ensure that multiple `run-on`s (or standalone `build-on`s)\n+    # don't incude the same arch, or they'll clash with each other when\n+    # releasing.\n+    all_ons = run_ons + standalone_build_ons","path":"snapcraft/internal/project_loader/_config.py","position":81,"original_position":81,"commit_id":"e717bddd643bbc7b663a0dbe416709fd7f55ad8e","original_commit_id":"e717bddd643bbc7b663a0dbe416709fd7f55ad8e","user":{"login":"sergiusens","id":1146853,"avatar_url":"https://avatars2.githubusercontent.com/u/1146853?v=4","gravatar_id":"","url":"https://api.github.com/users/sergiusens","html_url":"https://github.com/sergiusens","followers_url":"https://api.github.com/users/sergiusens/followers","following_url":"https://api.github.com/users/sergiusens/following{/other_user}","gists_url":"https://api.github.com/users/sergiusens/gists{/gist_id}","starred_url":"https://api.github.com/users/sergiusens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergiusens/subscriptions","organizations_url":"https://api.github.com/users/sergiusens/orgs","repos_url":"https://api.github.com/users/sergiusens/repos","events_url":"https://api.github.com/users/sergiusens/events{/privacy}","received_events_url":"https://api.github.com/users/sergiusens/received_events","type":"User","site_admin":false},"body":"this is really `all_run_ons` given that you are checking where to run. I think it would be easier to parse the intent with that name. Or maybe `where_to_run` or something involving a run :-)","created_at":"2018-04-17T12:13:19Z","updated_at":"2018-04-17T12:13:19Z","html_url":"https://github.com/snapcore/snapcraft/pull/2080#discussion_r182049787","pull_request_url":"https://api.github.com/repos/snapcore/snapcraft/pulls/2080","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/snapcore/snapcraft/pulls/comments/182049787"},"html":{"href":"https://github.com/snapcore/snapcraft/pull/2080#discussion_r182049787"},"pull_request":{"href":"https://api.github.com/repos/snapcore/snapcraft/pulls/2080"}}},"pull_request":{"url":"https://api.github.com/repos/snapcore/snapcraft/pulls/2080","id":182018659,"html_url":"https://github.com/snapcore/snapcraft/pull/2080","diff_url":"https://github.com/snapcore/snapcraft/pull/2080.diff","patch_url":"https://github.com/snapcore/snapcraft/pull/2080.patch","issue_url":"https://api.github.com/repos/snapcore/snapcraft/issues/2080","number":2080,"state":"open","locked":false,"title":"project_loader: support architectures for CI","user":{"login":"kyrofa","id":946674,"avatar_url":"https://avatars0.githubusercontent.com/u/946674?v=4","gravatar_id":"","url":"https://api.github.com/users/kyrofa","html_url":"https://github.com/kyrofa","followers_url":"https://api.github.com/users/kyrofa/followers","following_url":"https://api.github.com/users/kyrofa/following{/other_user}","gists_url":"https://api.github.com/users/kyrofa/gists{/gist_id}","starred_url":"https://api.github.com/users/kyrofa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyrofa/subscriptions","organizations_url":"https://api.github.com/users/kyrofa/orgs","repos_url":"https://api.github.com/users/kyrofa/repos","events_url":"https://api.github.com/users/kyrofa/events{/privacy}","received_events_url":"https://api.github.com/users/kyrofa/received_events","type":"User","site_admin":false},"body":"- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?\r\n- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?\r\n- [x] If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on [bug reports](https://bugs.launchpad.net/snapcraft)?\r\n- [x] If this is a new feature. Have you discussed the design on the [forum](https://forum.snapcraft.io)?\r\n- [x] Have you successfully run `./runtests.sh static`?\r\n- [x] Have you successfully run `./runtests.sh unit`?\r\n\r\n-----\r\n\r\nThis PR resolves #1685 by changing the `architectures` keyword according to the new CI-friendly proposal [here](https://forum.snapcraft.io/t/4675). This adds support for new syntax to that keyword:\r\n\r\n    architectures:\r\n      - build-on: [<build arch 1>, <build arch 2>]\r\n        run-on: [<run arch 1>, <run arch 2>]\r\n\r\nPlease see the proposal for more details.","created_at":"2018-04-17T00:00:03Z","updated_at":"2018-04-17T12:13:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"188cf17f014ba1d0e19c7406f22203a7a20de73f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/snapcore/snapcraft/pulls/2080/commits","review_comments_url":"https://api.github.com/repos/snapcore/snapcraft/pulls/2080/comments","review_comment_url":"https://api.github.com/repos/snapcore/snapcraft/pulls/comments{/number}","comments_url":"https://api.github.com/repos/snapcore/snapcraft/issues/2080/comments","statuses_url":"https://api.github.com/repos/snapcore/snapcraft/statuses/e717bddd643bbc7b663a0dbe416709fd7f55ad8e","head":{"label":"kyrofa:feature/1685/architectures","ref":"feature/1685/architectures","sha":"e717bddd643bbc7b663a0dbe416709fd7f55ad8e","user":{"login":"kyrofa","id":946674,"avatar_url":"https://avatars0.githubusercontent.com/u/946674?v=4","gravatar_id":"","url":"https://api.github.com/users/kyrofa","html_url":"https://github.com/kyrofa","followers_url":"https://api.github.com/users/kyrofa/followers","following_url":"https://api.github.com/users/kyrofa/following{/other_user}","gists_url":"https://api.github.com/users/kyrofa/gists{/gist_id}","starred_url":"https://api.github.com/users/kyrofa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyrofa/subscriptions","organizations_url":"https://api.github.com/users/kyrofa/orgs","repos_url":"https://api.github.com/users/kyrofa/repos","events_url":"https://api.github.com/users/kyrofa/events{/privacy}","received_events_url":"https://api.github.com/users/kyrofa/received_events","type":"User","site_admin":false},"repo":{"id":46729716,"name":"snapcraft","full_name":"kyrofa/snapcraft","owner":{"login":"kyrofa","id":946674,"avatar_url":"https://avatars0.githubusercontent.com/u/946674?v=4","gravatar_id":"","url":"https://api.github.com/users/kyrofa","html_url":"https://github.com/kyrofa","followers_url":"https://api.github.com/users/kyrofa/followers","following_url":"https://api.github.com/users/kyrofa/following{/other_user}","gists_url":"https://api.github.com/users/kyrofa/gists{/gist_id}","starred_url":"https://api.github.com/users/kyrofa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyrofa/subscriptions","organizations_url":"https://api.github.com/users/kyrofa/orgs","repos_url":"https://api.github.com/users/kyrofa/repos","events_url":"https://api.github.com/users/kyrofa/events{/privacy}","received_events_url":"https://api.github.com/users/kyrofa/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kyrofa/snapcraft","description":"Snapcraft is a delightful packaging tool","fork":true,"url":"https://api.github.com/repos/kyrofa/snapcraft","forks_url":"https://api.github.com/repos/kyrofa/snapcraft/forks","keys_url":"https://api.github.com/repos/kyrofa/snapcraft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kyrofa/snapcraft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kyrofa/snapcraft/teams","hooks_url":"https://api.github.com/repos/kyrofa/snapcraft/hooks","issue_events_url":"https://api.github.com/repos/kyrofa/snapcraft/issues/events{/number}","events_url":"https://api.github.com/repos/kyrofa/snapcraft/events","assignees_url":"https://api.github.com/repos/kyrofa/snapcraft/assignees{/user}","branches_url":"https://api.github.com/repos/kyrofa/snapcraft/branches{/branch}","tags_url":"https://api.github.com/repos/kyrofa/snapcraft/tags","blobs_url":"https://api.github.com/repos/kyrofa/snapcraft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kyrofa/snapcraft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kyrofa/snapcraft/git/refs{/sha}","trees_url":"https://api.github.com/repos/kyrofa/snapcraft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kyrofa/snapcraft/statuses/{sha}","languages_url":"https://api.github.com/repos/kyrofa/snapcraft/languages","stargazers_url":"https://api.github.com/repos/kyrofa/snapcraft/stargazers","contributors_url":"https://api.github.com/repos/kyrofa/snapcraft/contributors","subscribers_url":"https://api.github.com/repos/kyrofa/snapcraft/subscribers","subscription_url":"https://api.github.com/repos/kyrofa/snapcraft/subscription","commits_url":"https://api.github.com/repos/kyrofa/snapcraft/commits{/sha}","git_commits_url":"https://api.github.com/repos/kyrofa/snapcraft/git/commits{/sha}","comments_url":"https://api.github.com/repos/kyrofa/snapcraft/comments{/number}","issue_comment_url":"https://api.github.com/repos/kyrofa/snapcraft/issues/comments{/number}","contents_url":"https://api.github.com/repos/kyrofa/snapcraft/contents/{+path}","compare_url":"https://api.github.com/repos/kyrofa/snapcraft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kyrofa/snapcraft/merges","archive_url":"https://api.github.com/repos/kyrofa/snapcraft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kyrofa/snapcraft/downloads","issues_url":"https://api.github.com/repos/kyrofa/snapcraft/issues{/number}","pulls_url":"https://api.github.com/repos/kyrofa/snapcraft/pulls{/number}","milestones_url":"https://api.github.com/repos/kyrofa/snapcraft/milestones{/number}","notifications_url":"https://api.github.com/repos/kyrofa/snapcraft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kyrofa/snapcraft/labels{/name}","releases_url":"https://api.github.com/repos/kyrofa/snapcraft/releases{/id}","deployments_url":"https://api.github.com/repos/kyrofa/snapcraft/deployments","created_at":"2015-11-23T15:35:14Z","updated_at":"2016-06-28T16:15:38Z","pushed_at":"2018-04-17T05:25:06Z","git_url":"git://github.com/kyrofa/snapcraft.git","ssh_url":"git@github.com:kyrofa/snapcraft.git","clone_url":"https://github.com/kyrofa/snapcraft.git","svn_url":"https://github.com/kyrofa/snapcraft","homepage":null,"size":9890,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"snapcore:master","ref":"master","sha":"972cca6e2b5f8ff3d331111b672fc1583b2589a5","user":{"login":"snapcore","id":19532717,"avatar_url":"https://avatars1.githubusercontent.com/u/19532717?v=4","gravatar_id":"","url":"https://api.github.com/users/snapcore","html_url":"https://github.com/snapcore","followers_url":"https://api.github.com/users/snapcore/followers","following_url":"https://api.github.com/users/snapcore/following{/other_user}","gists_url":"https://api.github.com/users/snapcore/gists{/gist_id}","starred_url":"https://api.github.com/users/snapcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snapcore/subscriptions","organizations_url":"https://api.github.com/users/snapcore/orgs","repos_url":"https://api.github.com/users/snapcore/repos","events_url":"https://api.github.com/users/snapcore/events{/privacy}","received_events_url":"https://api.github.com/users/snapcore/received_events","type":"Organization","site_admin":false},"repo":{"id":45199136,"name":"snapcraft","full_name":"snapcore/snapcraft","owner":{"login":"snapcore","id":19532717,"avatar_url":"https://avatars1.githubusercontent.com/u/19532717?v=4","gravatar_id":"","url":"https://api.github.com/users/snapcore","html_url":"https://github.com/snapcore","followers_url":"https://api.github.com/users/snapcore/followers","following_url":"https://api.github.com/users/snapcore/following{/other_user}","gists_url":"https://api.github.com/users/snapcore/gists{/gist_id}","starred_url":"https://api.github.com/users/snapcore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snapcore/subscriptions","organizations_url":"https://api.github.com/users/snapcore/orgs","repos_url":"https://api.github.com/users/snapcore/repos","events_url":"https://api.github.com/users/snapcore/events{/privacy}","received_events_url":"https://api.github.com/users/snapcore/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/snapcore/snapcraft","description":"Package, distribute, and update any app for Linux and IoT.","fork":false,"url":"https://api.github.com/repos/snapcore/snapcraft","forks_url":"https://api.github.com/repos/snapcore/snapcraft/forks","keys_url":"https://api.github.com/repos/snapcore/snapcraft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/snapcore/snapcraft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/snapcore/snapcraft/teams","hooks_url":"https://api.github.com/repos/snapcore/snapcraft/hooks","issue_events_url":"https://api.github.com/repos/snapcore/snapcraft/issues/events{/number}","events_url":"https://api.github.com/repos/snapcore/snapcraft/events","assignees_url":"https://api.github.com/repos/snapcore/snapcraft/assignees{/user}","branches_url":"https://api.github.com/repos/snapcore/snapcraft/branches{/branch}","tags_url":"https://api.github.com/repos/snapcore/snapcraft/tags","blobs_url":"https://api.github.com/repos/snapcore/snapcraft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/snapcore/snapcraft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/snapcore/snapcraft/git/refs{/sha}","trees_url":"https://api.github.com/repos/snapcore/snapcraft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/snapcore/snapcraft/statuses/{sha}","languages_url":"https://api.github.com/repos/snapcore/snapcraft/languages","stargazers_url":"https://api.github.com/repos/snapcore/snapcraft/stargazers","contributors_url":"https://api.github.com/repos/snapcore/snapcraft/contributors","subscribers_url":"https://api.github.com/repos/snapcore/snapcraft/subscribers","subscription_url":"https://api.github.com/repos/snapcore/snapcraft/subscription","commits_url":"https://api.github.com/repos/snapcore/snapcraft/commits{/sha}","git_commits_url":"https://api.github.com/repos/snapcore/snapcraft/git/commits{/sha}","comments_url":"https://api.github.com/repos/snapcore/snapcraft/comments{/number}","issue_comment_url":"https://api.github.com/repos/snapcore/snapcraft/issues/comments{/number}","contents_url":"https://api.github.com/repos/snapcore/snapcraft/contents/{+path}","compare_url":"https://api.github.com/repos/snapcore/snapcraft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/snapcore/snapcraft/merges","archive_url":"https://api.github.com/repos/snapcore/snapcraft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/snapcore/snapcraft/downloads","issues_url":"https://api.github.com/repos/snapcore/snapcraft/issues{/number}","pulls_url":"https://api.github.com/repos/snapcore/snapcraft/pulls{/number}","milestones_url":"https://api.github.com/repos/snapcore/snapcraft/milestones{/number}","notifications_url":"https://api.github.com/repos/snapcore/snapcraft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/snapcore/snapcraft/labels{/name}","releases_url":"https://api.github.com/repos/snapcore/snapcraft/releases{/id}","deployments_url":"https://api.github.com/repos/snapcore/snapcraft/deployments","created_at":"2015-10-29T17:23:15Z","updated_at":"2018-04-16T14:29:01Z","pushed_at":"2018-04-17T05:33:29Z","git_url":"git://github.com/snapcore/snapcraft.git","ssh_url":"git@github.com:snapcore/snapcraft.git","clone_url":"https://github.com/snapcore/snapcraft.git","svn_url":"https://github.com/snapcore/snapcraft","homepage":"","size":9398,"stargazers_count":574,"watchers_count":574,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":246,"mirror_url":null,"archived":false,"open_issues_count":69,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0"},"forks":246,"open_issues":69,"watchers":574,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/snapcore/snapcraft/pulls/2080"},"html":{"href":"https://github.com/snapcore/snapcraft/pull/2080"},"issue":{"href":"https://api.github.com/repos/snapcore/snapcraft/issues/2080"},"comments":{"href":"https://api.github.com/repos/snapcore/snapcraft/issues/2080/comments"},"review_comments":{"href":"https://api.github.com/repos/snapcore/snapcraft/pulls/2080/comments"},"review_comment":{"href":"https://api.github.com/repos/snapcore/snapcraft/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/snapcore/snapcraft/pulls/2080/commits"},"statuses":{"href":"https://api.github.com/repos/snapcore/snapcraft/statuses/e717bddd643bbc7b663a0dbe416709fd7f55ad8e"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"sergiusens"}}