Skip to content

Commit

Permalink
bazel: Add @envoy_repo (#5)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <ryan@synca.io>
  • Loading branch information
phlax authored Aug 15, 2024
1 parent 5780108 commit 45a1cf3
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 8 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/envoy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Envoy

permissions:
contents: read

on:
pull_request:
push:
branches:
- main

concurrency:
group: >-
${{ github.event.inputs.head_ref || github.run_id }}
jobs:
envoy:
runs-on: ubuntu-24.04
if: github.repository_owner == 'envoyproxy'
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- run: |
bazel build --config=ci //:envoy_versions
cat bazel-bin/envoy_versions.json | jq '.'
24 changes: 24 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@aspect_bazel_lib//lib:jq.bzl", "jq")

# gazelle:prefix github.com/aptly-dev/aptly
gazelle(name = "gazelle")
Expand All @@ -21,3 +22,26 @@ gazelle(
command = "update-repos",
data = [":go.mod"],
)

jq(
name = "envoy_versions",
srcs = ["@envoy_repo//:project"],
out = "envoy_versions.json",
filter = """
.releases as $releases
| {
latest_releases: [
.stable_versions[]
| . as $minor
| {
version: $minor,
releases: (
$releases
| map(select(startswith("v" + $minor + ".")))
)
}
]
}
""",
visibility = ["//visibility:public"],
)
10 changes: 7 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ load("//:setup.bzl", "setup")
setup()

load("//:toolchains.bzl", "toolchains")
toolchains()
toolchains(VERSIONS)

load("//:setup_extra.bzl", "setup_extra")
setup_extra()

load("//:deps_extra.bzl", "dependencies_extra")
dependencies_extra()

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
# gazelle:repo bazel_gazelle
# gazelle:repository_macro deps-go.bzl%go_dependencies
gazelle_dependencies(go_repository_default_config = "//:WORKSPACE")
2 changes: 2 additions & 0 deletions deps.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")
Expand All @@ -10,3 +11,4 @@ def dependencies():
aptly_dependencies()
go_dependencies()
go_rules_dependencies()
aspect_bazel_lib_dependencies()
6 changes: 6 additions & 0 deletions deps_extra.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
load("@base_pip3//:requirements.bzl", pip_dependencies = "install_deps")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

def dependencies_extra():
pip_dependencies()
gazelle_dependencies(go_repository_default_config = "//:WORKSPACE")
6 changes: 6 additions & 0 deletions setup_extra.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
load("@envoy//bazel:python_dependencies.bzl", "envoy_python_dependencies")
load("@envoy//bazel:repo.bzl", "envoy_repo")

def setup_extra():
envoy_python_dependencies()
envoy_repo()
14 changes: 9 additions & 5 deletions toolchains.bzl
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
load("@aspect_bazel_lib//lib:repositories.bzl", "register_jq_toolchains", "register_yq_toolchains")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains")
load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains")
load("@rules_python//python:repositories.bzl", "python_register_toolchains")

def toolchains():
def _python_minor_version(python_version):
return "_".join(python_version.split(".")[:2])

def toolchains(versions):
python_register_toolchains(
name = "python3_12",
# Available versions are listed in @rules_python//python:versions.bzl.
# We recommend using the same version your team is already standardized on.
python_version = "3.12",
name = "python%s" % _python_minor_version(versions["python"]),
python_version = versions["python"],
)
rules_proto_toolchains()
go_register_toolchains(version = "1.22.4")
register_jq_toolchains(version = versions["jq"])
register_yq_toolchains(version = versions["yq"])
2 changes: 2 additions & 0 deletions versions.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

VERSIONS = {
"jq": "1.7",
"yq": "4.24.4",
"python": "3.12",
"aspect_bazel_lib": {
"type": "github_archive",
Expand Down

0 comments on commit 45a1cf3

Please sign in to comment.