From 33c9f48f39d95e769683b7410dc5ab20da497c5a Mon Sep 17 00:00:00 2001 From: Kaido Kert Date: Mon, 13 Jan 2025 11:14:34 -0800 Subject: [PATCH] Sample archiving recipe --- .gitignore | 1 + cobalt/infra/config/recipes.cfg | 28 ++++++++++++++++ cobalt/recipes/recipes/upload_archive.py | 41 ++++++++++++++++++++++++ test_run.sh | 4 +++ 4 files changed, 74 insertions(+) create mode 100644 cobalt/infra/config/recipes.cfg create mode 100644 cobalt/recipes/recipes/upload_archive.py create mode 100755 test_run.sh diff --git a/.gitignore b/.gitignore index d3745e6f8566..25361094fdb4 100644 --- a/.gitignore +++ b/.gitignore @@ -369,3 +369,4 @@ vs-chromium-project.txt # Intermediate Gradle outputs from builds starboard/android/apk/.gradle/ +cobalt/recipes/.recipe_deps/ diff --git a/cobalt/infra/config/recipes.cfg b/cobalt/infra/config/recipes.cfg new file mode 100644 index 000000000000..1d351a4da2d6 --- /dev/null +++ b/cobalt/infra/config/recipes.cfg @@ -0,0 +1,28 @@ +{ + "api_version": 2, + "deps": { + "recipe_engine": { + "branch": "refs/heads/main", + "revision": "aec6c66bcf1d44e78a0c1029b6a53965b97957d0", + "url": "https://chromium.googlesource.com/infra/luci/recipes-py" + }, + "build": { + "branch" : "refs/heads/main", + "revision" : "36a4165460701da3b9cf2a49ab37e794bde3f240", + "url" : "https://chromium.googlesource.com/chromium/tools/build.git" + }, + "depot_tools": { + "branch": "refs/heads/main", + "revision": "24d9ad69facfe9f73b542e434f47881a5caa1db4", + "url": "https://chromium.googlesource.com/chromium/tools/depot_tools.git" + }, + "infra": { + "branch": "refs/heads/main", + "revision": "0640c3e0d897b6f27ea09ff3a29bcdf2b6a7e6b0", + "url": "https://chromium.googlesource.com/infra/infra.git" + } + }, + "project_id": "cobalt", + "recipes_path": "recipes", + "py3_only": true +} diff --git a/cobalt/recipes/recipes/upload_archive.py b/cobalt/recipes/recipes/upload_archive.py new file mode 100644 index 000000000000..fe5f9872ac30 --- /dev/null +++ b/cobalt/recipes/recipes/upload_archive.py @@ -0,0 +1,41 @@ +"""Testing if we can use recipes +""" +from google.protobuf import json_format +from PB.recipe_modules.build.archive.properties import ArchiveData + +DEPS = [ + 'recipe_engine/step', 'recipe_engine/file', 'recipe_engine/json', + 'recipe_engine/path', 'recipe_engine/platform', 'recipe_engine/properties', + 'build/archive' +] + + +def RunSteps(api): + api.step('Print testing archive API', ['echo', 'just', 'a', 'test']) + archive_spec_path = 'infra/archive_config/android-archive-rel.json' + abs_archive = api.path.abspath(archive_spec_path) + checkout_dir = api.path.abs_to_path(api.path.abspath('.')) + source_dir = api.path.abs_to_path(api.path.abspath('.')) + build_dir = api.path.abs_to_path(api.path.abspath('out/Android')) + print('checkout_dir:', checkout_dir) + print('source_dir:', source_dir) + print('build_dir:', build_dir) + update_properties = {} + + archive_spec = api.file.read_json( + 'read archive spec (%s)' % api.path.basename(abs_archive), + abs_archive, + test_data={}) + source_side_config = json_format.ParseDict( + archive_spec, ArchiveData(), ignore_unknown_fields=True) + + api.archive.gcs_archive( + checkout_dir=checkout_dir, + source_dir=source_dir, + build_dir=build_dir, + update_properties=update_properties, + archive_data=source_side_config) + + +def GenTests(api): + return () diff --git a/test_run.sh b/test_run.sh new file mode 100755 index 000000000000..abbdc75dfee3 --- /dev/null +++ b/test_run.sh @@ -0,0 +1,4 @@ +./third_party/depot_tools/recipes/recipes.py \ + --package=cobalt/infra/config/recipes.cfg \ + --log-level WARNING \ + run upload_archive \ No newline at end of file