blob: 5c46313cfa9c883bddc527e22be24bb171997b79 [file] [log] [blame] [view]
Joanna Wang7c481032024-04-16 13:43:191# GCS objects for chromium dependencies
2
3[TOC]
4
5## Summary
6
7You may add GCS objects as dependencies to the chromium checkout via the `deps`
8field in the DEPS file. This use-case was previously covered by `hooks` which
9makes source and dependency management hard to track. Teams that continue to use
10hooks to download from GCS will cause builds to break in certain workflows.
11
12GCS objects can be tar archives, which will automatically be extracted, or
13single non-archive files. Whether an object is a tar archive is determined by
14[tarfile.is_tarfile](https://docs.python.org/3/library/tarfile.html#tarfile.is_tarfile).
15
16Interrupted downloads or extractions and outdated versions will be detected with
17`gclient sync` and trigger re-downlading.
18
19The downloaded content will be validated against the SHA256 content hash and
20byte size.
21
22GCS bucket permissions should allow for either allUsers or all googlers to view
23the objects within the bucket.
24
25## Adding, uploading, and updating GCS dependencies
26
27### Upload a new object to GCS
28
29There is a helper script
30([upload_to_google_storage_first_class.py](https://source.chromium.org/chromium/chromium/tools/depot_tools/+/main:upload_to_google_storage_first_class.py))
31to upload new objects to google storage and return the GCS deps entry that
32should be copied into DEPS.
33
34### Add/update a GCS entry in DEPS
35
36A GCS entry may be added to the `deps` dict with the following form
37([upload_to_google_storage_first_class.py](https://source.chromium.org/chromium/chromium/tools/depot_tools/+/main:upload_to_google_storage_first_class.py)
38will also spit out an entry that matches this form):
39
40```
41deps = {
42 # ...
43
44 # This is the installation directory.
Joanna Wangce04b052024-04-16 16:35:0145 'src/third_party/blink/renderer/core/css/perftest_data': {
46 'bucket': 'chromium-style-perftest',
47 'objects': [
48 {
49 'object_name': '031d5599c8a21118754e30dbea141be66104f556',
50 'sha256sum': '031d5599c8a21118754e30dbea141be66104f556',
51 'size_bytes': 3203922,
52 'generation': 1664794206824773,
53 # `output_file` is the name of the file that the downloade object should be
54 # saved as. It is optional and only relevant for objects that are NOT tar
55 # archives. Tar archives get extracted and saved under the same
56 # file/directory names they were archived as.
57 'output_file': 'sports.json',
58 },
59 {
60 'object_name': '8aac3db2a8c9e44babec81e539a3d60aeab4985c',
61 'sha256sum': '8aac3db2a8c9e44babec81e539a3d60aeab4985c',
62 'size_bytes': 5902660,
63 'generation': 1664794209886788,
64 'output_file': 'video.json',
65 },
66 ],
67 'dep_type' = 'gcs',
68 },
Joanna Wang7c481032024-04-16 13:43:1969}
70```
71
72The source of truth for this format is found
73[here](https://source.chromium.org/chromium/chromium/tools/depot_tools/+/main:gclient_eval.py;l=135-150?q=gclient_&ss=chromium%2Fchromium%2Ftools%2Fdepot_tools).
74
75#### `size_bytes` and `generation`
76
77If you are not using `upload_to_google_storage_first_class.py` to upload your
78objects you can get this information from the command line with:
79
80```
81gcloud storage objects describe gs://<bucket>/<object>
82```
83
84They can also be found in pantheon when viewing the object's "Object details".
85`Size` is found under the `Live Object` tab and `generation` is found under the
86`Version History` tab.
87
88#### `sha256sum`
89
90`sha256sum` should be the SHA256 content hash of the GCS object (unextracted).
Joanna Wangce04b052024-04-16 16:35:0191`upload_to_google_storage_first_class.py` will compute this for you, but if you
92are not using that helper script you will have to compute it on your own. You
93can test that the hash is correct by running `gclient sync` on your WIP change
94that adds the new GCS entry.