Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: recipe_modules/cipd/example.py

Issue 2243773002: Add cipd recipe module to depot_tools (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: fixes for pylint Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « recipe_modules/cipd/api.py ('k') | recipe_modules/cipd/example.expected/basic.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 DEPS = [
6 'recipe_engine/path',
7 'recipe_engine/platform',
8 'recipe_engine/properties',
9 'recipe_engine/step',
10 'cipd',
11 ]
12
13 def RunSteps(api):
14 # First, you need a cipd client.
15 api.cipd.install_client('install cipd')
16 api.cipd.install_client('install cipd', version='deadbeaf')
17 assert api.cipd.get_executable()
18
19 # Need to set service account credentials.
20 api.cipd.set_service_account_credentials(
21 api.cipd.default_bot_service_account_credentials)
22
23 package_name = 'public/package/%s' % api.cipd.platform_suffix()
24 package_instance_id = '7f751b2237df2fdf3c1405be00590fefffbaea2d'
25 packages = {package_name: package_instance_id}
26
27 cipd_root = api.path['slave_build'].join('packages')
28 # Some packages don't require credentials to be installed or queried.
29 api.cipd.ensure(cipd_root, packages)
30 step = api.cipd.search(package_name, tag='git_revision:40-chars-long-hash')
31 api.cipd.describe(package_name,
32 version=step.json.output['result'][0]['instance_id'])
33
34 # Others do, so provide creds first.
35 api.cipd.set_service_account_credentials('fake-credentials.json')
36 private_package_name = 'private/package/%s' % api.cipd.platform_suffix()
37 packages[private_package_name] = 'latest'
38 api.cipd.ensure(cipd_root, packages)
39 step = api.cipd.search(private_package_name, tag='key:value')
40 api.cipd.describe(private_package_name,
41 version=step.json.output['result'][0]['instance_id'],
42 test_data_tags=['custom:tagged', 'key:value'],
43 test_data_refs=['latest'])
44
45 # The rest of commands expect credentials to be set.
46
47 # Build & register new package version.
48 api.cipd.build('fake-input-dir', 'fake-package-path', 'infra/fake-package')
49 api.cipd.build('fake-input-dir', 'fake-package-path', 'infra/fake-package',
50 install_mode='copy')
51 api.cipd.register('infra/fake-package', 'fake-package-path',
52 refs=['fake-ref-1', 'fake-ref-2'],
53 tags={'fake_tag_1': 'fake_value_1',
54 'fake_tag_2': 'fake_value_2'})
55
56 # Create (build & register).
57 api.cipd.create(api.path['slave_build'].join('fake-package.yaml'),
58 refs=['fake-ref-1', 'fake-ref-2'],
59 tags={'fake_tag_1': 'fake_value_1',
60 'fake_tag_2': 'fake_value_2'})
61
62 # Set tag or ref of an already existing package.
63 api.cipd.set_tag('fake-package',
64 version='long/weird/ref/which/doesn/not/fit/into/40chars',
65 tags={'dead': 'beaf', 'more': 'value'})
66 api.cipd.set_ref('fake-package', version='latest', refs=['any', 'some'])
67 # Search by the new tag.
68 api.cipd.search('fake-package/%s' % api.cipd.platform_suffix(),
69 tag='dead:beaf')
70
71
72 def GenTests(api):
73 yield (
74 # This is very common dev workstation, but not all devs are on it.
75 api.test('basic') +
76 api.platform('linux', 64)
77 )
78
79 yield (
80 api.test('mac64') +
81 api.platform('mac', 64)
82 )
83
84 yield (
85 api.test('win64') +
86 api.platform('win', 64)
87 )
88
89 yield (
90 api.test('install-failed') +
91 api.step_data('install cipd', retcode=1)
92 )
93
94 yield (
95 api.test('describe-failed') +
96 api.platform('linux', 64) +
97 api.override_step_data(
98 'cipd describe public/package/linux-amd64',
99 api.cipd.example_error(
100 'package "public/package/linux-amd64-ubuntu14_04" not registered',
101 )
102 )
103 )
104
105 yield (
106 api.test('describe-many-instances') +
107 api.platform('linux', 64) +
108 api.override_step_data(
109 'cipd search fake-package/linux-amd64 dead:beaf',
110 api.cipd.example_search(
111 'public/package/linux-amd64-ubuntu14_04',
112 instances=3
113 )
114 )
115 )
OLDNEW
« no previous file with comments | « recipe_modules/cipd/api.py ('k') | recipe_modules/cipd/example.expected/basic.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698