crosvm/infra/recipes/build_docs.py
Dennis Kempin 70e4b96fa2 infra: Fully commit to python3
We never used python2 in our recipes, but now that Luci is migrated,
we can truly run in python3 only.
See: http://go/luci/migrations/recipe_py3#phase-5-fully-committing-to-python-3

This should fix issues with the recipe bundler.

BUG=b:269149141
TEST=health-check

Change-Id: Iaf8a63b3ca9114acd0e5f0fbc13696367a1ab116
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4245443
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-02-13 22:06:44 +00:00

67 lines
2 KiB
Python

# Copyright 2022 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from recipe_engine.post_process import Filter
DEPS = [
"crosvm",
"recipe_engine/file",
"recipe_engine/buildbucket",
"recipe_engine/context",
"recipe_engine/step",
"depot_tools/gsutil",
]
BOOK_URL = "gs://crosvm-dot-dev/book"
DOCS_URL = "gs://crosvm-dot-dev/doc"
def RunSteps(api):
"""
Builds crosvm mdbook and api docs, then uploads them to GCS.
This recipe requires ambient luci authentication. To test locally run:
$ luci-auth context ./infra/recipes.py run build_docs
"""
with api.crosvm.container_build_context():
api.crosvm.step_in_container(
"Build mdbook", ["mdbook", "build", "docs/book/", "--dest-dir", "../target"]
)
api.crosvm.step_in_container(
"Run cargo docs",
["./tools/cargo-doc", "--target-dir", "docs/target"],
)
# Container generated files are root-owned, we need to make sure they will be readable by
# gsutil (which has to run outside the container to run with proper authentication).
api.crosvm.step_in_container(
"Make docs readable by gsutil",
["chmod", "-R", "o+r", "docs/target"],
)
api.gsutil(
["rsync", "-r", "-d", "./docs/target/html", BOOK_URL],
name="Upload book",
multithreaded=True,
)
# TODO(b/239255064): Generate the redirect HTML so we can use cleanly mirror here too.
api.gsutil(
["rsync", "-r", "./docs/target/doc", DOCS_URL],
name="Upload docs",
multithreaded=True,
)
def GenTests(api):
filter_steps = Filter(
"Build mdbook", "Run cargo docs", "gsutil Upload book", "gsutil Upload docs"
)
yield (
api.test(
"build_docs",
api.buildbucket.ci_build(project="crosvm/crosvm"),
)
+ api.post_process(filter_steps)
)