Skip to content

Commit

Permalink
feat: support credStore (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn authored Apr 12, 2023
1 parent c59025b commit 49e0c5b
Show file tree
Hide file tree
Showing 14 changed files with 870 additions and 29 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,29 @@ jobs:
# Bazelisk will download bazel to here, ensure it is cached between runs.
XDG_CACHE_HOME: ~/.cache/bazel-repo
run: bazel --bazelrc=$GITHUB_WORKSPACE/.github/workflows/ci.bazelrc --bazelrc=.bazelrc test ${{ steps.set_bzlmod_flag.outputs.bzlmod_flag }} //...
test-auth:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup bats
uses: mig4/setup-bats@v1
with:
bats-version: "1.8.2"

- name: Setup bats helpers
uses: brokenpip3/setup-bats-libs@0.0.3
with:
support-path: /usr/lib/bats/bats-support
support-version: "0.3.0"
assert-path: /usr/lib/bats/bats-assert
assert-version: "2.1.0"

- name: bats -r .
working-directory: e2e/auth
run: bats -r .

- name: bats -r . --enable_bzlmod
working-directory: e2e/auth
run: |
echo "build --enable_bzlmod" >> .bazelrc.user
bats -r .
1 change: 1 addition & 0 deletions e2e/auth/.bazelrc
50 changes: 50 additions & 0 deletions e2e/auth/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_push")

# gazelle:prefix example.com/auth
gazelle(
name = "gazelle-update-repos",
args = [
"-from_file=go.mod",
"-to_macro=deps.bzl%go_dependencies",
"-prune",
],
command = "update-repos",
)

gazelle(
name = "gazelle",
command = "fix",
)

go_library(
name = "auth_lib",
srcs = ["main.go"],
importpath = "example.com/auth",
visibility = ["//visibility:private"],
deps = [
"@com_github_fsnotify_fsnotify//:fsnotify",
"@com_github_google_go_containerregistry//pkg/registry",
"@com_github_r3labs_diff_v3//:diff",
],
)

go_binary(
name = "auth",
embed = [":auth_lib"],
visibility = ["//visibility:public"],
)

oci_image(
name = "empty",
architecture = "arm64",
os = "linux",
)

oci_push(
name = "push",
image = ":empty",
repository = "localhost/empty_image",
repotags = ["latest"],
)
19 changes: 19 additions & 0 deletions e2e/auth/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"Bazel dependencies"
bazel_dep(name = "rules_oci", dev_dependency = True, version = "0.0.0")
bazel_dep(name = "platforms", version = "0.0.5")

local_path_override(
module_name = "rules_oci",
path = "../..",
)


oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")

oci.pull(
name = "empty_image",
digest = "sha256:2d4595bbc0fabeb1489b1071f56c26f44a2f495afaa9386ad7d24e7b3d8dfd3e",
image = "http://localhost:1447/empty_image"
)

use_repo(oci, "empty_image")
63 changes: 63 additions & 0 deletions e2e/auth/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
workspace(name = "auth")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

local_repository(
name = "rules_oci",
path = "../../",
)

load("@rules_oci//oci:dependencies.bzl", "rules_oci_dependencies")

# Fetch our "runtime" dependencies which users need as well
rules_oci_dependencies()

load("@rules_oci//oci:repositories.bzl", "LATEST_CRANE_VERSION", "oci_register_toolchains")

oci_register_toolchains(
name = "oci",
crane_version = LATEST_CRANE_VERSION,
)

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

oci_pull(
name = "empty_image",
digest = "sha256:2d4595bbc0fabeb1489b1071f56c26f44a2f495afaa9386ad7d24e7b3d8dfd3e",
image = "http://localhost:1447/empty_image",
)

############################################
# Gazelle and Go

http_archive(
name = "io_bazel_rules_go",
sha256 = "56d8c5a5c91e1af73eca71a6fab2ced959b67c86d12ba37feedb0a2dfea441a6",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.37.0/rules_go-v0.37.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.37.0/rules_go-v0.37.0.zip",
],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.19")

http_archive(
name = "bazel_gazelle",
sha256 = "ecba0f04f96b4960a5b250c8e8eeec42281035970aa8852dda73098274d14a1d",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
],
)

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("//:deps.bzl", "go_dependencies")

# gazelle:repository_macro deps.bzl%go_dependencies
go_dependencies()

gazelle_dependencies()
33 changes: 33 additions & 0 deletions e2e/auth/WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "io_bazel_rules_go",
sha256 = "56d8c5a5c91e1af73eca71a6fab2ced959b67c86d12ba37feedb0a2dfea441a6",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.37.0/rules_go-v0.37.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.37.0/rules_go-v0.37.0.zip",
],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.19")

http_archive(
name = "bazel_gazelle",
sha256 = "ecba0f04f96b4960a5b250c8e8eeec42281035970aa8852dda73098274d14a1d",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
],
)

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("//:deps.bzl", "go_dependencies")

# gazelle:repository_macro deps.bzl%go_dependencies
go_dependencies()

gazelle_dependencies()
Loading

0 comments on commit 49e0c5b

Please sign in to comment.