Fix device_doctor presubmit tests.
The recipe was always checking out main and not testing the changes in
presubmit.
Change-Id: I90d4cf0e6867c0dab2152e01997d654786b6d218
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/37082
Reviewed-by: Ricardo Amador <ricardoamador@google.com>
Reviewed-by: Casey Hillers <chillers@google.com>
Commit-Queue: Godofredo Contreras <godofredoc@google.com>
diff --git a/recipes/cocoon/cipd.py b/recipes/cocoon/cipd.py
index 593c624..8d61099 100644
--- a/recipes/cocoon/cipd.py
+++ b/recipes/cocoon/cipd.py
@@ -5,6 +5,8 @@
from platform import platform
from recipe_engine.recipe_api import Property
+from RECIPE_MODULES.flutter.repo_util.api import REPOS
+
DEPS = [
'flutter/repo_util',
'flutter/yaml',
@@ -26,9 +28,10 @@
cocoon_git_rev = api.repo_util.checkout(
'cocoon',
cocoon_dir,
- ref='refs/heads/main',
+ url=api.properties.get('git_url') or REPOS['cocoon'],
+ ref=api.properties.get('git_ref') or 'refs/heads/main',
)
-
+ should_upload = api.properties.get('git_ref') == 'refs/heads/main'
# Get properties from ci.yaml.
# Assume ci.yaml has the following properties
# - name: Mac codesign
@@ -57,7 +60,7 @@
cipd_zip_path = project_name + '.zip'
api.cipd.build(project_path.join('build'), cipd_zip_path, cipd_full_name)
- if api.buildbucket.build.builder.bucket == 'prod':
+ if api.buildbucket.build.builder.bucket == 'prod' and should_upload:
api.cipd.register(cipd_full_name, cipd_zip_path, refs = ["latest"])
@@ -79,7 +82,8 @@
'cipd_win_upload',
api.properties(
script='device_doctor\\tool\\build.bat',
- cipd_name='flutter/device_doctor/windows-amd64'
+ cipd_name='flutter/device_doctor/windows-amd64',
+ git_ref='refs/heads/main',
),
api.platform('win', 64),
api.buildbucket.ci_build(
diff --git a/recipes/cocoon/device_doctor.expected/linux.json b/recipes/cocoon/device_doctor.expected/linux.json
deleted file mode 100644
index 4601c80..0000000
--- a/recipes/cocoon/device_doctor.expected/linux.json
+++ /dev/null
@@ -1,170 +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://abc.com/repo"
- ],
- "name": "Checkout flutter/cocoon.git setup",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "fetch",
- "origin",
- "refs/pull/123/head",
- "--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/device_doctor/tool/build.sh"
- ],
- "cwd": "[START_DIR]/cocoon/device_doctor",
- "name": "build package"
- },
- {
- "cmd": [
- "cipd",
- "pkg-build",
- "-in",
- "[START_DIR]/cocoon/device_doctor/build",
- "-name",
- "flutter/device_doctor/${platform}",
- "-out",
- "device_doctor.zip",
- "-hash-algo",
- "sha256",
- "-json-output",
- "/path/to/tmp/json"
- ],
- "name": "build ${platform}",
- "~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/device_doctor/resolved-platform\"@@@",
- "@@@STEP_LOG_LINE@json.output@ }@@@",
- "@@@STEP_LOG_LINE@json.output@}@@@",
- "@@@STEP_LOG_END@json.output@@@"
- ]
- },
- {
- "cmd": [
- "cipd",
- "pkg-register",
- "device_doctor.zip",
- "-json-output",
- "/path/to/tmp/json"
- ],
- "name": "register flutter/device_doctor/${platform}",
- "~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/device_doctor/resolved-platform\"@@@",
- "@@@STEP_LOG_LINE@json.output@ }@@@",
- "@@@STEP_LOG_LINE@json.output@}@@@",
- "@@@STEP_LOG_END@json.output@@@",
- "@@@STEP_LINK@flutter/device_doctor/resolved-platform@https://chrome-infra-packages.appspot.com/p/flutter/device_doctor/resolved-platform/+/40-chars-fake-of-the-package-instance_id@@@"
- ]
- },
- {
- "name": "$result"
- }
-]
\ No newline at end of file
diff --git a/recipes/cocoon/device_doctor.expected/mac.json b/recipes/cocoon/device_doctor.expected/mac.json
deleted file mode 100644
index 4601c80..0000000
--- a/recipes/cocoon/device_doctor.expected/mac.json
+++ /dev/null
@@ -1,170 +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://abc.com/repo"
- ],
- "name": "Checkout flutter/cocoon.git setup",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "fetch",
- "origin",
- "refs/pull/123/head",
- "--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/device_doctor/tool/build.sh"
- ],
- "cwd": "[START_DIR]/cocoon/device_doctor",
- "name": "build package"
- },
- {
- "cmd": [
- "cipd",
- "pkg-build",
- "-in",
- "[START_DIR]/cocoon/device_doctor/build",
- "-name",
- "flutter/device_doctor/${platform}",
- "-out",
- "device_doctor.zip",
- "-hash-algo",
- "sha256",
- "-json-output",
- "/path/to/tmp/json"
- ],
- "name": "build ${platform}",
- "~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/device_doctor/resolved-platform\"@@@",
- "@@@STEP_LOG_LINE@json.output@ }@@@",
- "@@@STEP_LOG_LINE@json.output@}@@@",
- "@@@STEP_LOG_END@json.output@@@"
- ]
- },
- {
- "cmd": [
- "cipd",
- "pkg-register",
- "device_doctor.zip",
- "-json-output",
- "/path/to/tmp/json"
- ],
- "name": "register flutter/device_doctor/${platform}",
- "~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/device_doctor/resolved-platform\"@@@",
- "@@@STEP_LOG_LINE@json.output@ }@@@",
- "@@@STEP_LOG_LINE@json.output@}@@@",
- "@@@STEP_LOG_END@json.output@@@",
- "@@@STEP_LINK@flutter/device_doctor/resolved-platform@https://chrome-infra-packages.appspot.com/p/flutter/device_doctor/resolved-platform/+/40-chars-fake-of-the-package-instance_id@@@"
- ]
- },
- {
- "name": "$result"
- }
-]
\ No newline at end of file
diff --git a/recipes/cocoon/device_doctor.expected/win.json b/recipes/cocoon/device_doctor.expected/win.json
deleted file mode 100644
index ba067cb..0000000
--- a/recipes/cocoon/device_doctor.expected/win.json
+++ /dev/null
@@ -1,169 +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://abc.com/repo"
- ],
- "name": "Checkout flutter/cocoon.git setup",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "git",
- "fetch",
- "origin",
- "refs/pull/123/head",
- "--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": [
- "[START_DIR]\\cocoon\\device_doctor\\tool\\build.bat"
- ],
- "cwd": "[START_DIR]\\cocoon\\device_doctor",
- "name": "build package"
- },
- {
- "cmd": [
- "cipd.bat",
- "pkg-build",
- "-in",
- "[START_DIR]\\cocoon\\device_doctor\\build",
- "-name",
- "flutter/device_doctor/${platform}",
- "-out",
- "device_doctor.zip",
- "-hash-algo",
- "sha256",
- "-json-output",
- "/path/to/tmp/json"
- ],
- "name": "build ${platform}",
- "~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/device_doctor/resolved-platform\"@@@",
- "@@@STEP_LOG_LINE@json.output@ }@@@",
- "@@@STEP_LOG_LINE@json.output@}@@@",
- "@@@STEP_LOG_END@json.output@@@"
- ]
- },
- {
- "cmd": [
- "cipd.bat",
- "pkg-register",
- "device_doctor.zip",
- "-json-output",
- "/path/to/tmp/json"
- ],
- "name": "register flutter/device_doctor/${platform}",
- "~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/device_doctor/resolved-platform\"@@@",
- "@@@STEP_LOG_LINE@json.output@ }@@@",
- "@@@STEP_LOG_LINE@json.output@}@@@",
- "@@@STEP_LOG_END@json.output@@@",
- "@@@STEP_LINK@flutter/device_doctor/resolved-platform@https://chrome-infra-packages.appspot.com/p/flutter/device_doctor/resolved-platform/+/40-chars-fake-of-the-package-instance_id@@@"
- ]
- },
- {
- "name": "$result"
- }
-]
\ No newline at end of file
diff --git a/recipes/cocoon/device_doctor.py b/recipes/cocoon/device_doctor.py
deleted file mode 100644
index 66588db..0000000
--- a/recipes/cocoon/device_doctor.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2020 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-from recipe_engine.recipe_api import Property
-
-DEPS = [
- 'flutter/repo_util',
- 'recipe_engine/cipd',
- 'recipe_engine/context',
- 'recipe_engine/path',
- 'recipe_engine/platform',
- 'recipe_engine/properties',
- 'recipe_engine/step',
-]
-
-# This recipe builds the device_doctor CIPD package.
-def RunSteps(api):
- cocoon_dir = api.path['start_dir'].join('cocoon')
- cocoon_git_rev = api.repo_util.checkout(
- 'cocoon',
- cocoon_dir,
- api.properties.get('git_url'),
- api.properties.get('git_ref') or 'refs/heads/main',
- )
-
- # Builds and uploads a new version of the device_doctor CIPD package.
- device_doctor_path = cocoon_dir.join('device_doctor')
- with api.context(cwd=device_doctor_path):
- if api.platform.is_linux or api.platform.is_mac:
- build_file = device_doctor_path.join('tool', 'build.sh')
- api.step('build package', cmd=['bash', build_file])
- else:
- build_file = device_doctor_path.join('tool', 'build.bat')
- api.step('build package', cmd=[build_file])
-
- cipd_package_name = 'flutter/device_doctor/${platform}'
- cipd_zip_path = 'device_doctor.zip'
-
- api.cipd.build(
- device_doctor_path.join('build'), cipd_zip_path, cipd_package_name)
- api.cipd.register(cipd_package_name, cipd_zip_path)
-
-
-def GenTests(api):
- for platform in ('mac', 'linux', 'win'):
- yield api.test(
- platform,
- api.properties(
- git_ref='refs/pull/123/head', git_url='https://abc.com/repo'),
- api.platform(platform, 64)
- )