Skip to content

Commit aa025d1

Browse files
authored
chore: produce bazel docs (#364)
1 parent 18d9b2b commit aa025d1

File tree

6 files changed

+77
-3
lines changed

6 files changed

+77
-3
lines changed

.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
common --enable_bzlmod

BUILD.bazel

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
# Marker that this is the root of a Bazel package
1+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2+
3+
# For stardoc to reference the file directly
4+
exports_files(["defs.bzl"])
5+
6+
bzl_library(
7+
name = "defs",
8+
srcs = ["defs.bzl"],
9+
deps = ["//bazel:container_structure_test"],
10+
visibility = ["//visibility:public"],
11+
)

MODULE.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ ext = use_extension("//:repositories.bzl", "extension")
1515
use_repo(ext, "structure_test_toolchains")
1616

1717
register_toolchains("@structure_test_toolchains//:all")
18+
19+
# 0.5.4 is the first version with bzlmod support
20+
bazel_dep(name = "stardoc", version = "0.5.4", repo_name = "io_bazel_stardoc")

bazel/BUILD.bazel

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2+
3+
package(default_visibility = ["//visibility:public"])
4+
15
toolchain_type(
26
name = "structure_test_toolchain_type",
3-
visibility = ["//visibility:public"],
4-
)
7+
)
8+
9+
bzl_library(
10+
name = "container_structure_test",
11+
srcs = ["container_structure_test.bzl"],
12+
deps = [
13+
"@aspect_bazel_lib//lib:paths",
14+
"@aspect_bazel_lib//lib:windows_utils",
15+
],
16+
)

bazel/docs/BUILD.bazel

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This load statement must be in the docs/ package rather than anything users depend on
2+
# so that the dependency on stardoc doesn't leak to them.
3+
load("@aspect_bazel_lib//lib:docs.bzl", "stardoc_with_diff_test", "update_docs")
4+
5+
stardoc_with_diff_test(
6+
name = "defs",
7+
bzl_library_target = "//:defs",
8+
)
9+
10+
update_docs(name = "update")

bazel/docs/defs.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!-- Generated with Stardoc: http://skydoc.bazel.build -->
2+
3+
Exposes container-structure-test as a Bazel rule
4+
5+
<a id="container_structure_test"></a>
6+
7+
## container_structure_test
8+
9+
<pre>
10+
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>)
11+
</pre>
12+
13+
Tests a Docker- or OCI-format image.
14+
15+
By default, it relies on the container runtime already installed and running on the target.
16+
17+
By default, container-structure-test uses the socket available at `/var/run/docker.sock`.
18+
If the installation creates the socket in a different path, use
19+
`--test_env=DOCKER_HOST='unix://&lt;path_to_sock&gt;'`.
20+
21+
To avoid putting this into the commandline or to instruct bazel to read it from terminal environment,
22+
simply add `test --test_env=DOCKER_HOST` into the `.bazelrc` file.
23+
24+
Alternatively, use the `driver = "tar"` attribute to avoid the need for a container runtime, see
25+
https://github.com/GoogleContainerTools/container-structure-test#running-file-tests-without-docker
26+
27+
28+
**ATTRIBUTES**
29+
30+
31+
| Name | Description | Type | Mandatory | Default |
32+
| :------------- | :------------- | :------------- | :------------- | :------------- |
33+
| <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 | |
34+
| <a id="container_structure_test-configs"></a>configs | - | <a href="https://bazel.build/concepts/labels">List of labels</a> | required | |
35+
| <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> |
36+
| <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> |
37+
38+

0 commit comments

Comments
 (0)