Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: produce bazel docs #364

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
common --enable_bzlmod
12 changes: 11 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
# Marker that this is the root of a Bazel package
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

# For stardoc to reference the file directly
exports_files(["defs.bzl"])

bzl_library(
name = "defs",
srcs = ["defs.bzl"],
deps = ["//bazel:container_structure_test"],
visibility = ["//visibility:public"],
)
3 changes: 3 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ ext = use_extension("//:repositories.bzl", "extension")
use_repo(ext, "structure_test_toolchains")

register_toolchains("@structure_test_toolchains//:all")

# 0.5.4 is the first version with bzlmod support
bazel_dep(name = "stardoc", version = "0.5.4", repo_name = "io_bazel_stardoc")
16 changes: 14 additions & 2 deletions bazel/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

package(default_visibility = ["//visibility:public"])

toolchain_type(
name = "structure_test_toolchain_type",
visibility = ["//visibility:public"],
)
)

bzl_library(
name = "container_structure_test",
srcs = ["container_structure_test.bzl"],
deps = [
"@aspect_bazel_lib//lib:paths",
"@aspect_bazel_lib//lib:windows_utils",
],
)
10 changes: 10 additions & 0 deletions bazel/docs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This load statement must be in the docs/ package rather than anything users depend on
# so that the dependency on stardoc doesn't leak to them.
load("@aspect_bazel_lib//lib:docs.bzl", "stardoc_with_diff_test", "update_docs")

stardoc_with_diff_test(
name = "defs",
bzl_library_target = "//:defs",
)

update_docs(name = "update")
38 changes: 38 additions & 0 deletions bazel/docs/defs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!-- Generated with Stardoc: http://skydoc.bazel.build -->

Exposes container-structure-test as a Bazel rule

<a id="container_structure_test"></a>

## container_structure_test

<pre>
container_structure_test(<a href="#container_structure_test-name">name</a>, <a href="#container_structure_test-configs">configs</a>, <a href="#container_structure_test-driver">driver</a>, <a href="#container_structure_test-image">image</a>)
</pre>

Tests a Docker- or OCI-format image.

By default, it relies on the container runtime already installed and running on the target.

By default, container-structure-test uses the socket available at `/var/run/docker.sock`.
If the installation creates the socket in a different path, use
`--test_env=DOCKER_HOST='unix://&lt;path_to_sock&gt;'`.

To avoid putting this into the commandline or to instruct bazel to read it from terminal environment,
simply add `test --test_env=DOCKER_HOST` into the `.bazelrc` file.

Alternatively, use the `driver = "tar"` attribute to avoid the need for a container runtime, see
https://github.com/GoogleContainerTools/container-structure-test#running-file-tests-without-docker


**ATTRIBUTES**


| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="container_structure_test-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | |
| <a id="container_structure_test-configs"></a>configs | - | <a href="https://bazel.build/concepts/labels">List of labels</a> | required | |
| <a id="container_structure_test-driver"></a>driver | See https://github.com/GoogleContainerTools/container-structure-test#running-file-tests-without-docker | String | optional | <code>"docker"</code> |
| <a id="container_structure_test-image"></a>image | Label of an oci_image or oci_tarball target. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | <code>None</code> |


Loading