[cocoon/cipd] Upload only on prod builds
Require code review before changes can be uploaded
Change-Id: Ib550b4ddc251fd66bd8090a9b804aaf10232c4a0
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/34580
Reviewed-by: Xilai Zhang <xilaizhang@google.com>
Commit-Queue: Casey Hillers <chillers@google.com>
diff --git a/recipes/cocoon/cipd.expected/cipd_mac.json b/recipes/cocoon/cipd.expected/cipd_mac.json
deleted file mode 100644
index 8cad409..0000000
--- a/recipes/cocoon/cipd.expected/cipd_mac.json
+++ /dev/null
@@ -1,174 +0,0 @@
-[
- {
- "cmd": [],
- "name": "Checkout flutter/cocoon"
- },
- {
- "cmd": [
- "python3",
- "-u",
- "RECIPE_MODULE[depot_tools::git]/resources/git_setup.py",
- "--path",
- "[START_DIR]/cocoon",
- "--url",
- "https://flutter.googlesource.com/mirrors/cocoon"
- ],
- "name": "Checkout flutter/cocoon.git setup",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "fetch",
- "origin",
- "main",
- "--recurse-submodules",
- "--progress",
- "--tags"
- ],
- "cwd": "[START_DIR]/cocoon",
- "env": {
- "PATH": "RECIPE_REPO[depot_tools]:<PATH>"
- },
- "infra_step": true,
- "name": "Checkout flutter/cocoon.git fetch",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "checkout",
- "-f",
- "FETCH_HEAD"
- ],
- "cwd": "[START_DIR]/cocoon",
- "infra_step": true,
- "name": "Checkout flutter/cocoon.git checkout",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "rev-parse",
- "HEAD"
- ],
- "cwd": "[START_DIR]/cocoon",
- "infra_step": true,
- "name": "Checkout flutter/cocoon.read revision",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@",
- "@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@",
- "@@@SET_BUILD_PROPERTY@got_revision@\"deadbeef\"@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "clean",
- "-f",
- "-d",
- "-x"
- ],
- "cwd": "[START_DIR]/cocoon",
- "infra_step": true,
- "name": "Checkout flutter/cocoon.git clean",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "submodule",
- "sync"
- ],
- "cwd": "[START_DIR]/cocoon",
- "infra_step": true,
- "name": "Checkout flutter/cocoon.submodule sync",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "submodule",
- "update",
- "--init",
- "--recursive"
- ],
- "cwd": "[START_DIR]/cocoon",
- "infra_step": true,
- "name": "Checkout flutter/cocoon.submodule update",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "bash",
- "[START_DIR]/cocoon/codesign/tool/build.sh"
- ],
- "cwd": "[START_DIR]/cocoon/codesign",
- "name": "build package"
- },
- {
- "cmd": [
- "cipd",
- "pkg-build",
- "-in",
- "[START_DIR]/cocoon/codesign/build",
- "-name",
- "flutter/codesign/mac-amd64",
- "-out",
- "codesign.zip",
- "-hash-algo",
- "sha256",
- "-json-output",
- "/path/to/tmp/json"
- ],
- "cwd": "[START_DIR]/cocoon/codesign",
- "name": "build mac-amd64",
- "~followup_annotations": [
- "@@@STEP_LOG_LINE@json.output@{@@@",
- "@@@STEP_LOG_LINE@json.output@ \"result\": {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"instance_id\": \"40-chars-fake-of-the-package-instance_id\", @@@",
- "@@@STEP_LOG_LINE@json.output@ \"package\": \"flutter/codesign/mac-amd64\"@@@",
- "@@@STEP_LOG_LINE@json.output@ }@@@",
- "@@@STEP_LOG_LINE@json.output@}@@@",
- "@@@STEP_LOG_END@json.output@@@"
- ]
- },
- {
- "cmd": [
- "cipd",
- "pkg-register",
- "codesign.zip",
- "-ref",
- "latest",
- "-json-output",
- "/path/to/tmp/json"
- ],
- "cwd": "[START_DIR]/cocoon/codesign",
- "name": "register flutter/codesign/mac-amd64",
- "~followup_annotations": [
- "@@@STEP_LOG_LINE@json.output@{@@@",
- "@@@STEP_LOG_LINE@json.output@ \"result\": {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"instance_id\": \"40-chars-fake-of-the-package-instance_id\", @@@",
- "@@@STEP_LOG_LINE@json.output@ \"package\": \"flutter/codesign/mac-amd64\"@@@",
- "@@@STEP_LOG_LINE@json.output@ }@@@",
- "@@@STEP_LOG_LINE@json.output@}@@@",
- "@@@STEP_LOG_END@json.output@@@",
- "@@@STEP_LINK@flutter/codesign/mac-amd64@https://chrome-infra-packages.appspot.com/p/flutter/codesign/mac-amd64/+/40-chars-fake-of-the-package-instance_id@@@"
- ]
- },
- {
- "name": "$result"
- }
-]
\ No newline at end of file
diff --git a/recipes/cocoon/cipd.expected/cipd_mac_no_upload.json b/recipes/cocoon/cipd.expected/cipd_mac_no_upload.json
new file mode 100644
index 0000000..6cb1deb
--- /dev/null
+++ b/recipes/cocoon/cipd.expected/cipd_mac_no_upload.json
@@ -0,0 +1,259 @@
+[
+ {
+ "cmd": [],
+ "name": "Checkout flutter/cocoon"
+ },
+ {
+ "cmd": [
+ "python3",
+ "-u",
+ "RECIPE_MODULE[depot_tools::git]/resources/git_setup.py",
+ "--path",
+ "[START_DIR]/cocoon",
+ "--url",
+ "https://flutter.googlesource.com/mirrors/cocoon"
+ ],
+ "luci_context": {
+ "realm": {
+ "name": "project:try"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
+ "name": "Checkout flutter/cocoon.git setup",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@1@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "git",
+ "fetch",
+ "origin",
+ "main",
+ "--recurse-submodules",
+ "--progress",
+ "--tags"
+ ],
+ "cwd": "[START_DIR]/cocoon",
+ "env": {
+ "PATH": "RECIPE_REPO[depot_tools]:<PATH>"
+ },
+ "infra_step": true,
+ "luci_context": {
+ "realm": {
+ "name": "project:try"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
+ "name": "Checkout flutter/cocoon.git fetch",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@1@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "git",
+ "checkout",
+ "-f",
+ "FETCH_HEAD"
+ ],
+ "cwd": "[START_DIR]/cocoon",
+ "infra_step": true,
+ "luci_context": {
+ "realm": {
+ "name": "project:try"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
+ "name": "Checkout flutter/cocoon.git checkout",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@1@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "git",
+ "rev-parse",
+ "HEAD"
+ ],
+ "cwd": "[START_DIR]/cocoon",
+ "infra_step": true,
+ "luci_context": {
+ "realm": {
+ "name": "project:try"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
+ "name": "Checkout flutter/cocoon.read revision",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@1@@@",
+ "@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@",
+ "@@@SET_BUILD_PROPERTY@got_revision@\"deadbeef\"@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "git",
+ "clean",
+ "-f",
+ "-d",
+ "-x"
+ ],
+ "cwd": "[START_DIR]/cocoon",
+ "infra_step": true,
+ "luci_context": {
+ "realm": {
+ "name": "project:try"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
+ "name": "Checkout flutter/cocoon.git clean",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@1@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "git",
+ "submodule",
+ "sync"
+ ],
+ "cwd": "[START_DIR]/cocoon",
+ "infra_step": true,
+ "luci_context": {
+ "realm": {
+ "name": "project:try"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
+ "name": "Checkout flutter/cocoon.submodule sync",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@1@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "git",
+ "submodule",
+ "update",
+ "--init",
+ "--recursive"
+ ],
+ "cwd": "[START_DIR]/cocoon",
+ "infra_step": true,
+ "luci_context": {
+ "realm": {
+ "name": "project:try"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
+ "name": "Checkout flutter/cocoon.submodule update",
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@1@@@"
+ ]
+ },
+ {
+ "cmd": [
+ "bash",
+ "[START_DIR]/cocoon/codesign/tool/build.sh"
+ ],
+ "cwd": "[START_DIR]/cocoon/codesign",
+ "luci_context": {
+ "realm": {
+ "name": "project:try"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
+ "name": "build package"
+ },
+ {
+ "cmd": [
+ "cipd",
+ "pkg-build",
+ "-in",
+ "[START_DIR]/cocoon/codesign/build",
+ "-name",
+ "flutter/codesign/mac-amd64",
+ "-out",
+ "codesign.zip",
+ "-hash-algo",
+ "sha256",
+ "-json-output",
+ "/path/to/tmp/json"
+ ],
+ "cwd": "[START_DIR]/cocoon/codesign",
+ "luci_context": {
+ "realm": {
+ "name": "project:try"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
+ "name": "build mac-amd64",
+ "~followup_annotations": [
+ "@@@STEP_LOG_LINE@json.output@{@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"result\": {@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"instance_id\": \"40-chars-fake-of-the-package-instance_id\", @@@",
+ "@@@STEP_LOG_LINE@json.output@ \"package\": \"flutter/codesign/mac-amd64\"@@@",
+ "@@@STEP_LOG_LINE@json.output@ }@@@",
+ "@@@STEP_LOG_LINE@json.output@}@@@",
+ "@@@STEP_LOG_END@json.output@@@"
+ ]
+ },
+ {
+ "name": "$result"
+ }
+]
\ No newline at end of file
diff --git a/recipes/cocoon/cipd.expected/cipd_win.json b/recipes/cocoon/cipd.expected/cipd_win_upload.json
similarity index 60%
rename from recipes/cocoon/cipd.expected/cipd_win.json
rename to recipes/cocoon/cipd.expected/cipd_win_upload.json
index 9dc4876..bbe0741 100644
--- a/recipes/cocoon/cipd.expected/cipd_win.json
+++ b/recipes/cocoon/cipd.expected/cipd_win_upload.json
@@ -13,6 +13,18 @@
"--url",
"https://flutter.googlesource.com/mirrors/cocoon"
],
+ "luci_context": {
+ "realm": {
+ "name": "project:prod"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
"name": "Checkout flutter/cocoon.git setup",
"~followup_annotations": [
"@@@STEP_NEST_LEVEL@1@@@"
@@ -33,6 +45,18 @@
"PATH": "RECIPE_REPO[depot_tools];<PATH>"
},
"infra_step": true,
+ "luci_context": {
+ "realm": {
+ "name": "project:prod"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
"name": "Checkout flutter/cocoon.git fetch",
"~followup_annotations": [
"@@@STEP_NEST_LEVEL@1@@@"
@@ -47,6 +71,18 @@
],
"cwd": "[START_DIR]\\cocoon",
"infra_step": true,
+ "luci_context": {
+ "realm": {
+ "name": "project:prod"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
"name": "Checkout flutter/cocoon.git checkout",
"~followup_annotations": [
"@@@STEP_NEST_LEVEL@1@@@"
@@ -60,6 +96,18 @@
],
"cwd": "[START_DIR]\\cocoon",
"infra_step": true,
+ "luci_context": {
+ "realm": {
+ "name": "project:prod"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
"name": "Checkout flutter/cocoon.read revision",
"~followup_annotations": [
"@@@STEP_NEST_LEVEL@1@@@",
@@ -77,6 +125,18 @@
],
"cwd": "[START_DIR]\\cocoon",
"infra_step": true,
+ "luci_context": {
+ "realm": {
+ "name": "project:prod"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
"name": "Checkout flutter/cocoon.git clean",
"~followup_annotations": [
"@@@STEP_NEST_LEVEL@1@@@"
@@ -90,6 +150,18 @@
],
"cwd": "[START_DIR]\\cocoon",
"infra_step": true,
+ "luci_context": {
+ "realm": {
+ "name": "project:prod"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
"name": "Checkout flutter/cocoon.submodule sync",
"~followup_annotations": [
"@@@STEP_NEST_LEVEL@1@@@"
@@ -105,6 +177,18 @@
],
"cwd": "[START_DIR]\\cocoon",
"infra_step": true,
+ "luci_context": {
+ "realm": {
+ "name": "project:prod"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
"name": "Checkout flutter/cocoon.submodule update",
"~followup_annotations": [
"@@@STEP_NEST_LEVEL@1@@@"
@@ -115,6 +199,18 @@
"[START_DIR]\\cocoon\\device_doctor\\tool\\build.bat"
],
"cwd": "[START_DIR]\\cocoon\\device_doctor",
+ "luci_context": {
+ "realm": {
+ "name": "project:prod"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
"name": "build package"
},
{
@@ -133,6 +229,18 @@
"/path/to/tmp/json"
],
"cwd": "[START_DIR]\\cocoon\\device_doctor",
+ "luci_context": {
+ "realm": {
+ "name": "project:prod"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
"name": "build windows-amd64",
"~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@{@@@",
@@ -155,6 +263,18 @@
"/path/to/tmp/json"
],
"cwd": "[START_DIR]\\cocoon\\device_doctor",
+ "luci_context": {
+ "realm": {
+ "name": "project:prod"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
"name": "register flutter/device_doctor/windows-amd64",
"~followup_annotations": [
"@@@STEP_LOG_LINE@json.output@{@@@",
diff --git a/recipes/cocoon/cipd.py b/recipes/cocoon/cipd.py
index 7a25be5..593c624 100644
--- a/recipes/cocoon/cipd.py
+++ b/recipes/cocoon/cipd.py
@@ -8,6 +8,7 @@
DEPS = [
'flutter/repo_util',
'flutter/yaml',
+ 'recipe_engine/buildbucket',
'recipe_engine/cipd',
'recipe_engine/context',
'recipe_engine/json',
@@ -56,24 +57,33 @@
cipd_zip_path = project_name + '.zip'
api.cipd.build(project_path.join('build'), cipd_zip_path, cipd_full_name)
- api.cipd.register(cipd_full_name, cipd_zip_path, refs = ["latest"])
+ if api.buildbucket.build.builder.bucket == 'prod':
+ api.cipd.register(cipd_full_name, cipd_zip_path, refs = ["latest"])
def GenTests(api):
yield api.test(
- 'cipd_mac',
+ 'cipd_mac_no_upload',
api.properties(
script='codesign/tool/build.sh',
cipd_name='flutter/codesign/mac-amd64'
),
api.platform('mac', 64),
+ api.buildbucket.ci_build(
+ git_ref='refs/heads/main',
+ bucket='try',
+ ),
)
yield api.test(
- 'cipd_win',
+ 'cipd_win_upload',
api.properties(
script='device_doctor\\tool\\build.bat',
cipd_name='flutter/device_doctor/windows-amd64'
),
api.platform('win', 64),
+ api.buildbucket.ci_build(
+ git_ref='refs/heads/main',
+ bucket='prod',
+ ),
)