Skip to content

Commit b30fcaf

Browse files
authored
chore: add e2e test for crane as registry (#109)
1 parent bf81df6 commit b30fcaf

File tree

9 files changed

+82
-2
lines changed

9 files changed

+82
-2
lines changed

.bcr/presubmit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
bcr_test_module:
2-
module_path: "e2e/smoke"
2+
module_path: "e2e/crane_as_registry"
33
matrix:
44
platform: ["debian10", "macos", "ubuntu2004", "windows"]
55
tasks:

.github/workflows/ci.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ jobs:
2323
fail-fast: false
2424
matrix:
2525
os: [ubuntu-latest, macos-latest]
26-
folder: [".", "e2e/custom_registry", "e2e/wasm", "e2e/smoke"]
26+
folder:
27+
- .
28+
- e2e/custom_registry
29+
- e2e/wasm
30+
- e2e/smoke
31+
- e2e/crane_as_registry
32+
2733
bzlmodEnabled: [true, false]
2834
exclude:
2935
- folder: e2e/custom_registry

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ rules_oci does not contain language-specific rules, but we do document how to ac
4444
There are more examples of usage in the [examples](https://github.com/bazel-contrib/rules_oci/tree/main/examples) folder.
4545
Note that the examples rely on the setup code in the `/WORKSPACE` file in the root of this repo.
4646

47+
### Choosing between zot or crane as the local registry
48+
49+
rules_oci supports two different registry implementation for the temporary storage within actions spawned by bazel. By default we recommend using `zot` as it stores blobs on disk and is memory efficient but doesn't support `Docker` images. On the other hand, crane is memory hungry as it stores blobs in memory leading to high memory usage but crane supports both `OCI` and `Docker` images which is quite useful for using `Docker` images pulled from the registries such as `Docker Hub`.
50+
4751
# Public API
4852

4953
## Construct image layers

e2e/crane_as_registry/.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test --test_env=DOCKER_HOST

e2e/crane_as_registry/BUILD.bazel

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_tarball", "structure_test")
2+
3+
oci_image(
4+
name = "image",
5+
architecture = select({
6+
"@platforms//cpu:arm64": "arm64",
7+
"@platforms//cpu:x86_64": "amd64",
8+
}),
9+
cmd = [
10+
"--arg1",
11+
"--arg2",
12+
],
13+
entrypoint = ["/custom_bin"],
14+
env = {
15+
"ENV": "/test",
16+
},
17+
os = "linux",
18+
)
19+
20+
oci_tarball(
21+
name = "tar",
22+
image = ":image",
23+
repotags = [],
24+
)
25+
26+
structure_test(
27+
name = "test",
28+
config = ["test.yaml"],
29+
driver = "tar",
30+
image = ":tar",
31+
)

e2e/crane_as_registry/MODULE.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"Bazel dependencies"
2+
bazel_dep(name = "rules_oci", dev_dependency = True, version = "0.0.0")
3+
bazel_dep(name = "platforms", version = "0.0.5")
4+
5+
local_path_override(
6+
module_name = "rules_oci",
7+
path = "../..",
8+
)

e2e/crane_as_registry/WORKSPACE.bazel

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
workspace(name = "crane_as_registry")
2+
3+
local_repository(
4+
name = "rules_oci",
5+
path = "../../",
6+
)
7+
8+
load("@rules_oci//oci:dependencies.bzl", "rules_oci_dependencies")
9+
10+
rules_oci_dependencies()
11+
12+
load("@rules_oci//oci:repositories.bzl", "LATEST_CRANE_VERSION", "oci_register_toolchains")
13+
14+
oci_register_toolchains(
15+
name = "oci",
16+
crane_version = LATEST_CRANE_VERSION,
17+
)
18+
19+
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
20+
21+
rules_pkg_dependencies()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This file replaces WORKSPACE.bazel when --enable_bzlmod is set

e2e/crane_as_registry/test.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
schemaVersion: "2.0.0"
2+
3+
metadataTest:
4+
envVars:
5+
- key: "ENV"
6+
value: "/test"
7+
entrypoint: ["/custom_bin"]
8+
cmd: ["--arg1", "--arg2"]

0 commit comments

Comments
 (0)