Joanna Wang | 7c48103 | 2024-04-16 13:43:19 | [diff] [blame] | 1 | # GCS objects for chromium dependencies |
| 2 | |
| 3 | [TOC] |
| 4 | |
| 5 | ## Summary |
| 6 | |
| 7 | You may add GCS objects as dependencies to the chromium checkout via the `deps` |
| 8 | field in the DEPS file. This use-case was previously covered by `hooks` which |
| 9 | makes source and dependency management hard to track. Teams that continue to use |
| 10 | hooks to download from GCS will cause builds to break in certain workflows. |
| 11 | |
| 12 | GCS objects can be tar archives, which will automatically be extracted, or |
| 13 | single 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 | |
| 16 | Interrupted downloads or extractions and outdated versions will be detected with |
| 17 | `gclient sync` and trigger re-downlading. |
| 18 | |
| 19 | The downloaded content will be validated against the SHA256 content hash and |
| 20 | byte size. |
| 21 | |
| 22 | GCS bucket permissions should allow for either allUsers or all googlers to view |
| 23 | the objects within the bucket. |
| 24 | |
| 25 | ## Adding, uploading, and updating GCS dependencies |
| 26 | |
| 27 | ### Upload a new object to GCS |
| 28 | |
| 29 | There 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)) |
| 31 | to upload new objects to google storage and return the GCS deps entry that |
| 32 | should be copied into DEPS. |
| 33 | |
| 34 | ### Add/update a GCS entry in DEPS |
| 35 | |
| 36 | A 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) |
| 38 | will also spit out an entry that matches this form): |
| 39 | |
| 40 | ``` |
| 41 | deps = { |
| 42 | # ... |
| 43 | |
| 44 | # This is the installation directory. |
Joanna Wang | ce04b05 | 2024-04-16 16:35:01 | [diff] [blame] | 45 | '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 Wang | 7c48103 | 2024-04-16 13:43:19 | [diff] [blame] | 69 | } |
| 70 | ``` |
| 71 | |
| 72 | The 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 | |
| 77 | If you are not using `upload_to_google_storage_first_class.py` to upload your |
| 78 | objects you can get this information from the command line with: |
| 79 | |
| 80 | ``` |
| 81 | gcloud storage objects describe gs://<bucket>/<object> |
| 82 | ``` |
| 83 | |
| 84 | They 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 Wang | ce04b05 | 2024-04-16 16:35:01 | [diff] [blame] | 91 | `upload_to_google_storage_first_class.py` will compute this for you, but if you |
| 92 | are not using that helper script you will have to compute it on your own. You |
| 93 | can test that the hash is correct by running `gclient sync` on your WIP change |
| 94 | that adds the new GCS entry. |