Skip to content

Commit 0527483

Browse files
committed
add formatting tests for go, markdown and yaml
1 parent c30ab35 commit 0527483

File tree

14 files changed

+685
-103
lines changed

14 files changed

+685
-103
lines changed

.bazelignore

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

.github/workflows/main.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
name: CI
2-
32
on:
43
push:
54
branches: [main]
65
pull_request:
76
workflow_dispatch:
8-
97
jobs:
108
ci:
119
runs-on: ubuntu-latest
1210
steps:
1311
- uses: actions/checkout@v2
1412
- uses: bazelbuild/setup-bazelisk@v1
15-
1613
# Setup Credential Helper to authenticate to Github Container Registry
1714
- run: echo '{"credHelpers":{"ghcr.io":"ghcr"}}' > ~/.docker/config.json
1815
- run: echo "${HOME}/.local/bin" >> $GITHUB_PATH
1916
- run: mkdir -p ~/.local/bin
2017
- run: echo -e "#!/usr/bin/env bash\n echo '{\"ServerURL\":\"ghcr.io\",\"Username\":\"Bearer\",\"Secret\":\"${{ secrets.GITHUB_TOKEN }}\"}'" > ~/.local/bin/docker-credential-ghcr
2118
- run: chmod +x ~/.local/bin/docker-credential-ghcr
22-
2319
# Setup local toolchain
2420
- run: bazel build --config=ci //go/cmd/ocitool:ocitool && cp bazel-bin/go/cmd/ocitool/ocitool_/ocitool bin/ocitool-linux-amd64
25-
2621
# Run all tests
2722
- run: bazel test --config=ci //...

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ bazel-rules_oci
44
bazel-testlogs
55

66
bin/ocitool-*
7+
8+
node_modules

.prettierignore

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

.yamlfmt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exclude: ["pnpm-lock.yaml"]

BUILD.bazel

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
11
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
2-
load("@buildifier_prebuilt//:rules.bzl", "buildifier", "buildifier_test")
32
load("@gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
3+
load("@npm//:defs.bzl", "npm_link_all_packages")
44
load("//oci:toolchain.bzl", "oci_local_toolchain")
55

66
# gazelle:prefix github.com/DataDog/rules_oci
77
# gazelle:go_naming_convention go_default_library
88
# gazelle:lang go
99

10-
oci_local_toolchain(
11-
name = "oci_local_toolchain",
12-
)
13-
14-
buildifier(
15-
name = "buildifier",
16-
exclude_patterns = ["./.git/*"],
17-
lint_mode = "warn",
18-
mode = "fix",
10+
npm_link_all_packages(
11+
name = "node_modules",
1912
)
2013

21-
buildifier_test(
22-
name = "buildifier_test",
23-
exclude_patterns = ["./.git/*"],
24-
lint_mode = "warn",
25-
no_sandbox = True,
26-
workspace = "//:WORKSPACE",
14+
oci_local_toolchain(
15+
name = "oci_local_toolchain",
2716
)
2817

2918
gazelle(
@@ -54,3 +43,13 @@ write_source_files(
5443
"bin/ocitool-linux-arm64": "//go/cmd/ocitool",
5544
},
5645
)
46+
47+
alias(
48+
name = "format",
49+
actual = "//tools/format",
50+
)
51+
52+
exports_files(
53+
["WORKSPACE"],
54+
visibility = ["//visibility:public"],
55+
)

MODULE.bazel

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,25 @@ module(
33
repo_name = "com_github_datadog_rules_oci",
44
)
55

6+
bazel_dep(name = "aspect_rules_js", version = "2.1.2")
67
bazel_dep(name = "aspect_bazel_lib", version = "2.7.3")
8+
bazel_dep(name = "aspect_rules_lint", version = "1.0.8")
79
bazel_dep(name = "bazel_skylib", version = "1.6.1")
810
bazel_dep(name = "gazelle", version = "0.38.0")
911
bazel_dep(name = "rules_go", version = "0.47.1")
12+
bazel_dep(name = "rules_nodejs", version = "6.3.2")
1013
bazel_dep(name = "rules_pkg", version = "0.10.1")
1114
bazel_dep(name = "stardoc", version = "0.6.2")
1215

1316
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.6.1", dev_dependency = True)
1417
bazel_dep(name = "buildifier_prebuilt", version = "7.3.1", dev_dependency = True)
1518

1619
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
17-
go_sdk.download(version = "1.22.5")
18-
go_sdk.host()
20+
go_sdk.download(
21+
name = "go_sdk",
22+
version = "1.22.5",
23+
)
24+
use_repo(go_sdk, "go_sdk")
1925

2026
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
2127
go_deps.from_file(go_mod = "//:go.mod")
@@ -68,3 +74,20 @@ oci_pull(
6874
register_toolchains(
6975
"@com_github_datadog_rules_oci//:oci_local_toolchain",
7076
)
77+
78+
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True)
79+
node.toolchain(node_version = "16.14.2")
80+
81+
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
82+
npm.npm_translate_lock(
83+
name = "npm",
84+
pnpm_lock = "//:pnpm-lock.yaml",
85+
verify_node_modules_ignored = "//:.bazelignore",
86+
)
87+
use_repo(npm, "npm")
88+
89+
pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm")
90+
91+
# Allows developers to use the matching pnpm version, for example:
92+
# bazel run -- @pnpm --dir $PWD install
93+
use_repo(pnpm, "pnpm")

MODULE.bazel.lock

Lines changed: 563 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ DEPEND ON FOR PRODUCTION USE-CASES.
66
A Bazel rule-set for extending, creating and publishing OCI artifacts, including image
77
manifests, image indexes (multi-arch images) and custom artifacts
88
([ORAS](https://github.com/oras-project)), with a focus on:
9-
* **Speed**, only pulling artifacts that are needed at build-time (no more long image pull times)
10-
* **Extensibility**, creating custom artifacts to leverage standard OCI distribution
9+
10+
- **Speed**, only pulling artifacts that are needed at build-time (no more long image pull times)
11+
- **Extensibility**, creating custom artifacts to leverage standard OCI distribution
1112
APIs
12-
* **Multi-arch images**, compiling and building multi-arch images with a single Bazel invocation
13+
- **Multi-arch images**, compiling and building multi-arch images with a single Bazel invocation
1314

1415
In addition to Bazel rules, we offer many helpers for interacting with OCI
1516
artifacts under the `go/pkg` directory and a CLI tool for creating new OCI
@@ -67,27 +68,29 @@ in the image, but this trade-off is worth the speed of not downloaded many GBs o
6768
base images.
6869

6970
### Roadmap
70-
* [ ] Flesh out code for non-shallow pulls and cases where the layers are coming
71+
72+
- [ ] Flesh out code for non-shallow pulls and cases where the layers are coming
7173
from a different registry.
72-
* [ ] Full Starlark DSL for creating custom artifacts, it's currently looks
73-
a bit wonky
74-
* [ ] Support for the ORAS Artifact Spec
75-
* [ ] Support for custom artifact crawlers to pull artifacts that have children
76-
not represented by the OCI Image Spec. Ex pulling a full CNAB bundle and all
77-
dependencies.
78-
* [ ] Benchmark against `rules_docker` and raw `docker build`.
74+
- [ ] Full Starlark DSL for creating custom artifacts, it's currently looks
75+
a bit wonky
76+
- [ ] Support for the ORAS Artifact Spec
77+
- [ ] Support for custom artifact crawlers to pull artifacts that have children
78+
not represented by the OCI Image Spec. Ex pulling a full CNAB bundle and all
79+
dependencies.
80+
- [ ] Benchmark against `rules_docker` and raw `docker build`.
7981

8082
### FAQ
8183

8284
**Comparison to `rules_docker`**
83-
* `rules_docker` is built on `go-containerregistry`, which is focused on Docker,
85+
86+
- `rules_docker` is built on `go-containerregistry`, which is focused on Docker,
8487
`rules_oci` uses `containerd` whose implementation complies more to the OCI spec
8588
and more easily supports custom artifacts
86-
* `rules_oci` focused on supporting the OCI Image spec, rather than the Docker
89+
- `rules_oci` focused on supporting the OCI Image spec, rather than the Docker
8790
spec
88-
* `rules_oci` doesn't have language specific rules, instead a higher-level
91+
- `rules_oci` doesn't have language specific rules, instead a higher-level
8992
package can build on `rules_oci` to create rules like `go_image`
90-
* `rules_docker` doesn't have support for multi-arch images [#1599](https://github.com/bazelbuild/rules_docker/issues/1599)
93+
- `rules_docker` doesn't have support for multi-arch images [#1599](https://github.com/bazelbuild/rules_docker/issues/1599)
9194

9295
### Developing
9396

go/cmd/ocitool/createlayer_cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212

1313
"github.com/DataDog/rules_oci/go/internal/flagutil"
1414
"github.com/DataDog/rules_oci/go/internal/tarutil"
15-
"github.com/DataDog/rules_oci/go/pkg/ociutil"
1615
"github.com/DataDog/rules_oci/go/pkg/layer"
16+
"github.com/DataDog/rules_oci/go/pkg/ociutil"
1717
"github.com/opencontainers/go-digest"
1818
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
1919
"github.com/urfave/cli/v2"

0 commit comments

Comments
 (0)