| # Copyright 2021 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| """Recipe for building and testing a Dart project with Make. |
| |
| NOTE: This recipe is specific to an internal project and is not yet suitable for |
| general usage. |
| """ |
| |
| from recipe_engine.recipe_api import Property |
| |
| DEPS = [ |
| "fuchsia/cas_util", |
| "fuchsia/checkout", |
| "fuchsia/macos_sdk", |
| "fuchsia/status_check", |
| "recipe_engine/buildbucket", |
| "recipe_engine/context", |
| "recipe_engine/path", |
| "recipe_engine/properties", |
| "recipe_engine/step", |
| ] |
| |
| PROPERTIES = { |
| "project": Property(kind=str, help="Remote manifest project."), |
| "manifest": Property(kind=str, help="Jiri manifest to use."), |
| "remote": Property(kind=str, help="Remote manifest repository."), |
| "build_dir": Property(kind=str, help="Relative path in repository to build."), |
| } |
| |
| # A directory into which e2e tests may write test artifacts (e.g., screenshots) |
| # which may be archived for later download/inspection. |
| TEST_OUTDIR = "TEST_OUTDIR" |
| |
| |
| def RunSteps(api, project, manifest, remote, build_dir): |
| checkout_dir = api.checkout.with_options( |
| build_input=api.buildbucket.build.input, |
| manifest=manifest, |
| project=project, |
| remote=remote, |
| ) |
| |
| with api.macos_sdk(), api.context( |
| cwd=checkout_dir.join(build_dir), env={"CI_BUILD": "true"} |
| ): |
| api.step("fetch dependencies", ["make", "packages"]) |
| api.step("check formatting", ["make", "fmt"]) |
| api.step("analyze dart source", ["make", "analyze"]) |
| api.step("unit tests", ["make", "test"]) |
| |
| test_outdir = api.path.mkdtemp("test-outdir") |
| with api.context(env={TEST_OUTDIR: test_outdir}): |
| e2e_test_results = api.step("e2e tests", ["make", "e2e"], ok_ret="any") |
| failure = False |
| if e2e_test_results.retcode != 0: |
| failure = True |
| e2e_test_results.presentation.status = api.step.FAILURE |
| api.cas_util.upload(test_outdir, step_name="archive test artifacts") |
| if failure: |
| raise api.step.StepFailure("e2e tests failed") |
| |
| api.step("check repo remains clean", ["utilities/check_repo_is_clean.sh"]) |
| |
| |
| def GenTests(api): |
| props = api.properties( |
| project="project", |
| manifest="manifest", |
| remote="https://fuchsia.googlesource.com/remote", |
| build_dir="path/to/build/dir", |
| ) |
| yield api.status_check.test("basic") + props |
| yield api.status_check.test("e2e_test_failure", status="failure") + api.step_data( |
| "e2e tests", retcode=1 |
| ) + props |