Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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 .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.3.1
14 changes: 10 additions & 4 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ concurrency:
# More info: https://stackoverflow.com/a/70972844/1261287
group: ${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

jobs:
build:
name: PR unit tests
Expand All @@ -20,21 +20,21 @@ jobs:
os: [ubuntu-latest, macos-12]
fail-fast: false
runs-on: ${{ matrix.os }}

steps:
- name: start docker
if: ${{ matrix.os == 'macos-12' }}
run: |
brew install docker
colima start
echo "DOCKER_HOST=unix:///Users/runner/.colima/default/docker.sock" >> $GITHUB_ENV

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ^1.22
id: go

- uses: imjasonh/[email protected]

- name: Check out code into the Go module directory
Expand All @@ -45,3 +45,9 @@ jobs:
- name: Run tests
run: |
make test

# Ensure that Bazel build is maintained
- name: Bazel
run: |
bazel build //...
bazel test //...
5 changes: 4 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@gazelle//:def.bzl", "gazelle")

# 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"],
deps = ["//bazel:container_structure_test"],
)

gazelle(name = "gazelle")
38 changes: 32 additions & 6 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
"Bazel module definition, see https://bazel.build/external/overview#bzlmod"

module(
name = "container_structure_test",
compatibility_level = 1,
# Replaced dynamically when published
version = "0.0.0",
compatibility_level = 1,
)

# To run jq
bazel_dep(name = "aspect_bazel_lib", version = "1.28.0")
bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "platforms", version = "0.0.9")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "platforms", version = "0.0.11")

ext = use_extension("//:repositories.bzl", "extension")
use_repo(
Expand All @@ -18,13 +19,38 @@ use_repo(
# For testing only
"structure_test_st_darwin_amd64",
"structure_test_st_darwin_arm64",
"structure_test_st_linux_amd64",
"structure_test_st_linux_arm64",
"structure_test_st_linux_s390x",
"structure_test_st_linux_amd64",
"structure_test_st_windows_amd64",
)

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", dev_dependency = True)
bazel_dep(name = "stardoc", version = "0.7.1", dev_dependency = True, repo_name = "io_bazel_stardoc")

bazel_dep(
name = "rules_go",
version = "0.50.1",
)

bazel_dep(name = "gazelle", version = "0.42.0", dev_dependency = True)

go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")

# All *direct* Go dependencies of the module have to be listed explicitly.
use_repo(
go_deps,
"com_github_fsouza_go_dockerclient",
"com_github_google_go_cmp",
"com_github_google_go_containerregistry",
"com_github_joho_godotenv",
"com_github_moby_sys_sequential",
"com_github_opencontainers_image_spec",
"com_github_pkg_errors",
"com_github_sirupsen_logrus",
"com_github_spf13_cobra",
"in_gopkg_yaml_v2",
"org_golang_x_crypto",
)
3,745 changes: 2,451 additions & 1,294 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions cmd/container-structure-test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
load("@rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
name = "container-structure-test_lib",
srcs = ["container-structure-test.go"],
importpath = "github.com/GoogleContainerTools/container-structure-test/cmd/container-structure-test",
visibility = ["//visibility:private"],
deps = [
"//cmd/container-structure-test/app",
"@com_github_sirupsen_logrus//:go_default_library",
],
)

go_binary(
name = "container-structure-test",
embed = [":container-structure-test_lib"],
visibility = ["//visibility:public"],
)
9 changes: 9 additions & 0 deletions cmd/container-structure-test/app/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "app",
srcs = ["container-structure-test.go"],
importpath = "github.com/GoogleContainerTools/container-structure-test/cmd/container-structure-test/app",
visibility = ["//visibility:public"],
deps = ["//cmd/container-structure-test/app/cmd"],
)
31 changes: 31 additions & 0 deletions cmd/container-structure-test/app/cmd/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "cmd",
srcs = [
"cmd.go",
"test.go",
"version.go",
],
importpath = "github.com/GoogleContainerTools/container-structure-test/cmd/container-structure-test/app/cmd",
visibility = ["//visibility:public"],
deps = [
"//cmd/container-structure-test/app/cmd/test",
"//cmd/container-structure-test/app/flags",
"//pkg/color",
"//pkg/config",
"//pkg/drivers",
"//pkg/output",
"//pkg/types/unversioned",
"//pkg/utils",
"//pkg/version",
"@com_github_fsouza_go_dockerclient//:go_default_library",
"@com_github_google_go_containerregistry//pkg/name:go_default_library",
"@com_github_google_go_containerregistry//pkg/v1/daemon:go_default_library",
"@com_github_google_go_containerregistry//pkg/v1/layout:go_default_library",
"@com_github_opencontainers_image_spec//specs-go/v1:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@com_github_spf13_cobra//:go_default_library",
],
)
17 changes: 17 additions & 0 deletions cmd/container-structure-test/app/cmd/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "test",
srcs = ["util.go"],
importpath = "github.com/GoogleContainerTools/container-structure-test/cmd/container-structure-test/app/cmd/test",
visibility = ["//visibility:public"],
deps = [
"//pkg/config",
"//pkg/drivers",
"//pkg/output",
"//pkg/types",
"//pkg/types/unversioned",
"@com_github_pkg_errors//:go_default_library",
"@in_gopkg_yaml_v2//:go_default_library",
],
)
9 changes: 9 additions & 0 deletions cmd/container-structure-test/app/flags/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "flags",
srcs = ["template.go"],
importpath = "github.com/GoogleContainerTools/container-structure-test/cmd/container-structure-test/app/flags",
visibility = ["//visibility:public"],
deps = ["@com_github_pkg_errors//:go_default_library"],
)
25 changes: 25 additions & 0 deletions internal/pkgutil/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "pkgutil",
srcs = [
"fs_utils.go",
"image_utils.go",
"tar_utils.go",
"transport_builder.go",
],
importpath = "github.com/GoogleContainerTools/container-structure-test/internal/pkgutil",
visibility = ["//:__subpackages__"],
deps = [
"@com_github_google_go_containerregistry//pkg/authn:go_default_library",
"@com_github_google_go_containerregistry//pkg/name:go_default_library",
"@com_github_google_go_containerregistry//pkg/v1:go_default_library",
"@com_github_google_go_containerregistry//pkg/v1/daemon:go_default_library",
"@com_github_google_go_containerregistry//pkg/v1/mutate:go_default_library",
"@com_github_google_go_containerregistry//pkg/v1/remote:go_default_library",
"@com_github_google_go_containerregistry//pkg/v1/tarball:go_default_library",
"@com_github_moby_sys_sequential//:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
],
)
16 changes: 16 additions & 0 deletions pkg/color/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "color",
srcs = ["formatter.go"],
importpath = "github.com/GoogleContainerTools/container-structure-test/pkg/color",
visibility = ["//visibility:public"],
deps = ["@org_golang_x_crypto//ssh/terminal:go_default_library"],
)

go_test(
name = "color_test",
srcs = ["formatter_test.go"],
embed = [":color"],
deps = ["//testutil"],
)
9 changes: 9 additions & 0 deletions pkg/config/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "config",
srcs = ["options.go"],
importpath = "github.com/GoogleContainerTools/container-structure-test/pkg/config",
visibility = ["//visibility:public"],
deps = ["//pkg/types/unversioned"],
)
24 changes: 24 additions & 0 deletions pkg/drivers/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "drivers",
srcs = [
"docker_driver.go",
"driver.go",
"host_driver.go",
"tar_driver.go",
],
importpath = "github.com/GoogleContainerTools/container-structure-test/pkg/drivers",
visibility = ["//visibility:public"],
deps = [
"//internal/pkgutil",
"//pkg/types/unversioned",
"//pkg/utils",
"@com_github_fsouza_go_dockerclient//:go_default_library",
"@com_github_google_go_containerregistry//pkg/v1:go_default_library",
"@com_github_google_go_containerregistry//pkg/v1/mutate:go_default_library",
"@com_github_joho_godotenv//:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
],
)
20 changes: 20 additions & 0 deletions pkg/output/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
load("@rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "output",
srcs = ["output.go"],
importpath = "github.com/GoogleContainerTools/container-structure-test/pkg/output",
visibility = ["//visibility:public"],
deps = [
"//pkg/color",
"//pkg/types/unversioned",
"@com_github_pkg_errors//:go_default_library",
],
)

go_test(
name = "output_test",
srcs = ["output_test.go"],
embed = [":output"],
deps = ["//pkg/types/unversioned"],
)
13 changes: 13 additions & 0 deletions pkg/types/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "types",
srcs = ["types.go"],
importpath = "github.com/GoogleContainerTools/container-structure-test/pkg/types",
visibility = ["//visibility:public"],
deps = [
"//pkg/drivers",
"//pkg/types/v1",
"//pkg/types/v2:types",
],
)
8 changes: 8 additions & 0 deletions pkg/types/unversioned/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "unversioned",
srcs = ["types.go"],
importpath = "github.com/GoogleContainerTools/container-structure-test/pkg/types/unversioned",
visibility = ["//visibility:public"],
)
21 changes: 21 additions & 0 deletions pkg/types/v1/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "v1",
srcs = [
"command.go",
"file_content.go",
"file_existence.go",
"licenses.go",
"structure.go",
],
importpath = "github.com/GoogleContainerTools/container-structure-test/pkg/types/v1",
visibility = ["//visibility:public"],
deps = [
"//pkg/drivers",
"//pkg/types/unversioned",
"//pkg/utils",
"@com_github_pkg_errors//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
],
)
22 changes: 22 additions & 0 deletions pkg/types/v2/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "types",
srcs = [
"command.go",
"file_content.go",
"file_existence.go",
"licenses.go",
"metadata.go",
"structure.go",
],
importpath = "github.com/GoogleContainerTools/container-structure-test/pkg/types/v2",
visibility = ["//visibility:public"],
deps = [
"//pkg/drivers",
"//pkg/types/unversioned",
"//pkg/utils",
"@com_github_pkg_errors//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
],
)
9 changes: 9 additions & 0 deletions pkg/utils/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "utils",
srcs = ["utils.go"],
importpath = "github.com/GoogleContainerTools/container-structure-test/pkg/utils",
visibility = ["//visibility:public"],
deps = ["@com_github_sirupsen_logrus//:go_default_library"],
)
8 changes: 8 additions & 0 deletions pkg/version/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "version",
srcs = ["version.go"],
importpath = "github.com/GoogleContainerTools/container-structure-test/pkg/version",
visibility = ["//visibility:public"],
)
Loading