Skip to content

Commit 671c658

Browse files
committed
test: add pinning test
1 parent 3be6471 commit 671c658

36 files changed

+144
-130
lines changed

.github/workflows/ci.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@ jobs:
6363
- .
6464
- e2e/wasm
6565
- e2e/smoke
66-
- e2e/pull
66+
- e2e/assertion
6767

6868
bzlmodEnabled: [true, false]
6969
exclude:
7070
# macos is expensive (billed at 10X) so don't test these
7171
- os: macos-13
7272
folder: e2e/wasm
7373
- os: macos-13
74-
folder: e2e/pull
74+
folder: e2e/assertion
7575
- os: macos-13
7676
bazelversion: 6.4.0
77-
# e2e/pull is bzlmod only but it has test for both cases.
78-
- folder: e2e/pull
77+
# e2e/assertion is bzlmod only but it has test for both cases.
78+
- folder: e2e/assertion
7979
bzlmodEnabled: false
8080
# TODO: fix
8181
- folder: e2e/wasm
File renamed without changes.
File renamed without changes.

e2e/assertion/BUILD.bazel

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
load("@aspect_bazel_lib//lib:bats.bzl", "bats_test")
2+
3+
[
4+
bats_test(
5+
name = "test_oci_pull_auth_%s" % name,
6+
size = "large",
7+
srcs = [
8+
"oci_pull_auth_tests.bats",
9+
],
10+
args = [
11+
"--verbose-run",
12+
"--timing",
13+
"--trace",
14+
],
15+
data = glob(["credential-helper/**"]) + [
16+
"wksp",
17+
"//registry:auth",
18+
],
19+
env = {
20+
"WKSP": "$(location :wksp)",
21+
"REGISTRY": "$(rootpath //registry:auth)",
22+
"BAZEL_FLAGS": flags,
23+
},
24+
tags = [
25+
"exclusive",
26+
"local",
27+
"no-remote",
28+
"no-remote-exec",
29+
],
30+
)
31+
for (name, flags) in [
32+
("bzlmod", "--noenable_bzlmod"),
33+
("nobzlmod", "--enable_bzlmod"),
34+
]
35+
]
36+
37+
[
38+
bats_test(
39+
name = "test_oci_pull_%s" % name,
40+
size = "large",
41+
srcs = [
42+
"oci_pull_tests.bats",
43+
],
44+
args = [
45+
"--verbose-run",
46+
"--timing",
47+
"--trace",
48+
],
49+
data = [":wksp"],
50+
env = {
51+
"WKSP": "$(location :wksp)",
52+
"BAZEL_FLAGS": flags,
53+
},
54+
tags = [
55+
"exclusive",
56+
"local",
57+
"no-remote",
58+
"no-remote-exec",
59+
],
60+
)
61+
for (name, flags) in [
62+
("bzlmod", "--noenable_bzlmod"),
63+
("nobzlmod", "--enable_bzlmod"),
64+
]
65+
]
File renamed without changes.
File renamed without changes.

e2e/platforms/test.bats e2e/assertion/oci_pull_tests.bats

+13
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,16 @@ setup() {
4646
run bazel build @distroless_base_single_arch_wrong_amd64_platforms_attr//... --platforms=//platforms:linux_arm64 $BAZEL_FLAGS
4747
assert_failure
4848
}
49+
50+
51+
@test "when oci_pull with a tag, it should print a warning" {
52+
# Even if the target
53+
run bazel build @distroless_base_with_tag//... --platforms=//platforms:linux_x86_64 $BAZEL_FLAGS
54+
assert_output --partial 'WARNING: Fetching from distroless/cc-debian12@latest without an integrity hash, result will not be cached'
55+
assert_output --partial 'For reproducible builds, a digest is recommended.'
56+
assert_output --partial "Either set 'reproducible = False' to silence this warning"
57+
assert_output --partial "or run the following command to change"
58+
assert_output --partial "to use a digest:"
59+
assert_output --partial "'remove tag' 'remove platforms'"
60+
assert_output --partial 'add platforms "linux/amd64" "linux/arm64/v8" "linux/arm/v7" "linux/s390x" "linux/ppc64le"'
61+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
common --symlink_prefix=/
1+
22
common --repository_cache=
File renamed without changes.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
11
"Bazel dependencies"
22

3-
bazel_dep(name = "rules_oci", version = "0.0.0", dev_dependency = True)
4-
bazel_dep(name = "platforms", version = "0.0.7")
3+
bazel_dep(name = "rules_oci", version = "0.0.0")
4+
bazel_dep(name = "platforms", version = "0.0.8")
55

66
local_path_override(
77
module_name = "rules_oci",
88
path = "../../..",
99
)
1010

1111
oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
12-
12+
oci.pull(
13+
name = "empty_image",
14+
digest = "sha256:e40e202a677ddddeaaf4603df278a6da42130d750622f1b1130bdafe6876a6e0",
15+
image = "http://localhost:1447/empty_image",
16+
)
17+
use_repo(oci, "empty_image")
18+
oci.pull(
19+
name = "distroless_base_with_tag",
20+
image = "gcr.io/distroless/cc-debian12",
21+
platforms = [
22+
"linux/amd64",
23+
],
24+
tag = "latest",
25+
)
1326
oci.pull(
1427
name = "distroless_base_single_arch_no_platforms_attr",
1528
digest = "sha256:71b79745bb79377e88d936fd362bf505ad9f278f6a613233f0be2f10b96b1b21",
1629
image = "gcr.io/distroless/base",
1730
)
18-
1931
oci.pull(
2032
name = "distroless_base_single_arch_correct_arm64_platforms_attr",
2133
digest = "sha256:71b79745bb79377e88d936fd362bf505ad9f278f6a613233f0be2f10b96b1b21",
@@ -24,7 +36,6 @@ oci.pull(
2436
"linux/arm64",
2537
],
2638
)
27-
2839
oci.pull(
2940
name = "distroless_base_single_arch_wrong_amd64_platforms_attr",
3041
digest = "sha256:71b79745bb79377e88d936fd362bf505ad9f278f6a613233f0be2f10b96b1b21",
@@ -33,9 +44,13 @@ oci.pull(
3344
"linux/amd64",
3445
],
3546
)
36-
37-
use_repo(oci,
38-
"distroless_base_single_arch_no_platforms_attr",
47+
use_repo(
48+
oci,
3949
"distroless_base_single_arch_correct_arm64_platforms_attr",
50+
"distroless_base_single_arch_correct_arm64_platforms_attr_linux_arm64",
51+
"distroless_base_single_arch_no_platforms_attr",
4052
"distroless_base_single_arch_wrong_amd64_platforms_attr",
53+
"distroless_base_single_arch_wrong_amd64_platforms_attr_linux_amd64",
54+
"distroless_base_with_tag",
55+
"distroless_base_with_tag_linux_amd64",
4156
)

e2e/platforms/wksp/WORKSPACE e2e/assertion/wksp/WORKSPACE

+15
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ oci_register_toolchains(name = "oci")
1313

1414
load("@rules_oci//oci:pull.bzl", "oci_pull")
1515

16+
oci_pull(
17+
name = "empty_image",
18+
digest = "sha256:e40e202a677ddddeaaf4603df278a6da42130d750622f1b1130bdafe6876a6e0",
19+
image = "http://localhost:1447/empty_image",
20+
)
21+
1622
oci_pull(
1723
name = "distroless_base_single_arch_no_platforms_attr",
1824
digest = "sha256:71b79745bb79377e88d936fd362bf505ad9f278f6a613233f0be2f10b96b1b21",
@@ -36,3 +42,12 @@ oci_pull(
3642
"linux/amd64",
3743
],
3844
)
45+
46+
oci_pull(
47+
name = "distroless_base_with_tag",
48+
image = "gcr.io/distroless/cc-debian12",
49+
platforms = [
50+
"linux/amd64",
51+
],
52+
tag = "latest",
53+
)
File renamed without changes.

e2e/platforms/BUILD.bazel

-31
This file was deleted.

e2e/platforms/MODULE.bazel

-3
This file was deleted.

e2e/platforms/WORKSPACE.bazel

Whitespace-only changes.

e2e/platforms/wksp/BUILD.bazel

Whitespace-only changes.

e2e/pull/.bazelignore

-1
This file was deleted.

e2e/pull/.bazelrc

Whitespace-only changes.

e2e/pull/BUILD.bazel

-32
This file was deleted.

e2e/pull/WORKSPACE.bazel

Whitespace-only changes.

e2e/pull/wksp/.bazelrc

-2
This file was deleted.

e2e/pull/wksp/.bazelversion

-1
This file was deleted.

e2e/pull/wksp/MODULE.bazel

-17
This file was deleted.

e2e/pull/wksp/WORKSPACE

-20
This file was deleted.

e2e/wasm/MODULE.bazel

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
bazel_dep(name = "rules_oci", version = "0.0.0")
2+
bazel_dep(name = "aspect_bazel_lib", version = "2.7.2")
3+
bazel_dep(name = "bazel_skylib", version = "1.5.0")
4+
bazel_dep(name = "platforms", version = "0.0.8")
5+
bazel_dep(name = "rules_rust", version = "0.45.1")
6+
bazel_dep(name = "rules_pkg", version = "0.10.1")
7+
bazel_dep(name = "hermetic_cc_toolchain", version = "3.1.0")
8+
9+
local_path_override(
10+
module_name = "rules_oci",
11+
path = "../..",
12+
)
File renamed without changes.

0 commit comments

Comments
 (0)