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

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

Issue 2240203002: Delete cipd recipe module in build; it's been moved to depot_tools (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: 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
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 'file',
7 'recipe_engine/path',
8 'recipe_engine/platform',
9 'recipe_engine/properties',
10 'recipe_engine/step',
11 'cipd',
12 ]
13
14 def RunSteps(api):
15 # First, you need a cipd client.
16 api.cipd.install_client('install cipd')
17 api.cipd.install_client('install cipd', version='deadbeaf')
18 assert api.cipd.get_executable()
19
20 # Need to set service account credentials.
21 api.cipd.set_service_account_credentials(
22 api.cipd.default_bot_service_account_credentials)
23
24 package_name = 'public/package/%s' % api.cipd.platform_suffix()
25 package_instance_id = '7f751b2237df2fdf3c1405be00590fefffbaea2d'
26 packages = {package_name: package_instance_id}
27
28 cipd_root = api.path['slave_build'].join('packages')
29 # Some packages don't require credentials to be installed or queried.
30 api.cipd.ensure(cipd_root, packages)
31 step = api.cipd.search(package_name, tag='git_revision:40-chars-long-hash')
32 api.cipd.describe(package_name,
33 version=step.json.output['result'][0]['instance_id'])
34
35 # Others do, so provide creds first.
36 api.cipd.set_service_account_credentials('fake-credentials.json')
37 private_package_name = 'private/package/%s' % api.cipd.platform_suffix()
38 packages[private_package_name] = 'latest'
39 api.cipd.ensure(cipd_root, packages)
40 step = api.cipd.search(private_package_name, tag='key:value')
41 api.cipd.describe(private_package_name,
42 version=step.json.output['result'][0]['instance_id'],
43 test_data_tags=['custom:tagged', 'key:value'],
44 test_data_refs=['latest'])
45
46 # The rest of commands expect credentials to be set.
47
48 # Build & register new package version.
49 api.cipd.build('fake-input-dir', 'fake-package-path', 'infra/fake-package')
50 api.cipd.build('fake-input-dir', 'fake-package-path', 'infra/fake-package',
51 install_mode='copy')
52 api.cipd.register('infra/fake-package', 'fake-package-path',
53 refs=['fake-ref-1', 'fake-ref-2'],
54 tags={'fake_tag_1': 'fake_value_1',
55 'fake_tag_2': 'fake_value_2'})
56
57 # Create (build & register).
58 api.cipd.create(api.path['slave_build'].join('fake-package.yaml'),
59 refs=['fake-ref-1', 'fake-ref-2'],
60 tags={'fake_tag_1': 'fake_value_1',
61 'fake_tag_2': 'fake_value_2'})
62
63 # Set tag or ref of an already existing package.
64 api.cipd.set_tag('fake-package',
65 version='long/weird/ref/which/doesn/not/fit/into/40chars',
66 tags={'dead': 'beaf', 'more': 'value'})
67 api.cipd.set_ref('fake-package', version='latest', refs=['any', 'some'])
68 # Search by the new tag.
69 api.cipd.search('fake-package/%s' % api.cipd.platform_suffix(),
70 tag='dead:beaf')
71
72
73 def GenTests(api):
74 yield (
75 # This is very common dev workstation, but not all devs are on it.
76 api.test('basic') +
77 api.platform('linux', 64)
78 )
79
80 yield (
81 api.test('mac64') +
82 api.platform('mac', 64)
83 )
84
85 yield (
86 api.test('win64') +
87 api.platform('win', 64)
88 )
89
90 yield (
91 api.test('install-failed') +
92 api.step_data('install cipd', retcode=1)
93 )
94
95 yield (
96 api.test('describe-failed') +
97 api.platform('linux', 64) +
98 api.override_step_data(
99 'cipd describe public/package/linux-amd64',
100 api.cipd.example_error(
101 'package "public/package/linux-amd64-ubuntu14_04" not registered',
102 )
103 )
104 )
105
106 yield (
107 api.test('describe-many-instances') +
108 api.platform('linux', 64) +
109 api.override_step_data(
110 'cipd search fake-package/linux-amd64 dead:beaf',
111 api.cipd.example_search(
112 'public/package/linux-amd64-ubuntu14_04',
113 instances=3
114 )
115 )
116 )
OLDNEW
« no previous file with comments | « scripts/slave/recipe_modules/cipd/api.py ('k') | scripts/slave/recipe_modules/cipd/example.expected/basic.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698