Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

website/build: Derive version correctly #10

Merged
merged 1 commit into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ build --color=yes

build --jobs=HOST_CPUS-1
build --action_env=SPHINX_JOBS
build --workspace_status_command="bash bazel/get_workspace_status"

build --action_env=ENVOY_BLOB_SHA
build --action_env=ENVOY_DOCS_RELEASE_LEVEL
build --action_env=ENVOY_DOCS_VERSION_STRING
62 changes: 62 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,68 @@ load("@envoy//bazel:dependency_imports.bzl", "envoy_dependency_imports")

envoy_dependency_imports()

# The pgv imports require gazelle to be available early on.
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

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

# TODO(yannic): Remove once https://github.com/bazelbuild/rules_foreign_cc/pull/938
# is merged and released.
http_archive(
name = "rules_foreign_cc",
sha256 = "bbc605fd36048923939845d6843464197df6e6ffd188db704423952825e4760a",
strip_prefix = "rules_foreign_cc-a473d42bada74afac4e32b767964c1785232e07b",
urls = [
"https://storage.googleapis.com/engflow-tools-public/rules_foreign_cc-a473d42bada74afac4e32b767964c1785232e07b.tar.gz",
"https://github.com/EngFlow/rules_foreign_cc/archive/a473d42bada74afac4e32b767964c1785232e07b.tar.gz",
],
)

load("@envoy_mobile//bazel:envoy_mobile_repositories.bzl", "envoy_mobile_repositories")

envoy_mobile_repositories()

load("@envoy_mobile//bazel:envoy_mobile_dependencies.bzl", "envoy_mobile_dependencies")

envoy_mobile_dependencies()

load("@envoy_mobile//bazel:envoy_mobile_toolchains.bzl", "envoy_mobile_toolchains")

envoy_mobile_toolchains()

load("@envoy_mobile//bazel:android_configure.bzl", "android_configure")

android_configure(
name = "local_config_android",
build_tools_version = "30.0.2",
ndk_api_level = 21,
sdk_api_level = 30,
)

load("@local_config_android//:android_configure.bzl", "android_workspace")

android_workspace()

load("@com_github_buildbuddy_io_rules_xcodeproj//xcodeproj:repositories.bzl", "xcodeproj_rules_dependencies")

xcodeproj_rules_dependencies()

load(
"@build_bazel_rules_apple//apple:apple.bzl",
"provisioning_profile_repository",
)

provisioning_profile_repository(
name = "local_provisioning_profiles",
)

load(":toolchains.bzl", "load_toolchains")
load_toolchains()

Expand Down
4 changes: 3 additions & 1 deletion archive.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ def load_github_archives():
kwargs = dict(name = k, **v)
http_archive(
**{
k: v.format(**kwargs)
k: (
v.format(**kwargs) if not k.startswith("patch") else v
)
for k, v in kwargs.items()
if k not in ["repo", "type", "version"]
}
Expand Down
167 changes: 167 additions & 0 deletions bazel/envoy-mobile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
diff --git a/BUILD b/BUILD
index e9f3f96752..f7621d1d51 100644
--- a/BUILD
+++ b/BUILD
@@ -7,11 +7,16 @@ load(
"xcode_schemes",
"xcodeproj",
)
+load("@envoy//tools/base:envoy_python.bzl", "envoy_py_namespace")
load("@io_bazel_rules_kotlin//kotlin/internal:toolchains.bzl", "define_kt_toolchain")
load("//bazel:framework_imports_extractor.bzl", "framework_imports_extractor")

licenses(["notice"]) # Apache 2

+envoy_py_namespace()
+
+exports_files(["VERSION"])
+
alias(
name = "ios_xcframework",
actual = "//library/swift:Envoy",
diff --git a/docs/BUILD b/docs/BUILD
index fcddec5075..161ceef592 100644
--- a/docs/BUILD
+++ b/docs/BUILD
@@ -1,6 +1,6 @@
load("@base_pip3//:requirements.bzl", "requirement")
load("@envoy//bazel:envoy_build_system.bzl", "envoy_package")
-load("@envoy//tools/base:envoy_python.bzl", "envoy_entry_point")
+load("@envoy//tools/base:envoy_python.bzl", "envoy_entry_point", "envoy_py_namespace")
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files")
load("@rules_pkg//pkg:pkg.bzl", "pkg_tar")

@@ -8,8 +8,14 @@ licenses(["notice"]) # Apache 2

envoy_package()

+envoy_py_namespace()
+
envoy_entry_point(
name = "sphinx",
+ init_data = [
+ "//:py-init",
+ ":py-init",
+ ],
pkg = "sphinx",
script = "sphinx-build",
deps = [
@@ -58,10 +64,42 @@ pkg_tar(
)

genrule(
- name = "docs",
- outs = ["docs.tar.gz"],
+ name = "html_release",
+ outs = ["html_release.tar.gz"],
+ cmd = """
+ . $(location @envoy//bazel:volatile_env) \
+ && VERSION_NUMBER="$$(cat $(location //:VERSION))" \
+ && BUILD_SHA="$${BUILD_SHA:-$${ENVOY_BUILD_SCM_REVISION}}" \
+ && export ENVOY_DOCS_VERSION_STRING="$${VERSION_NUMBER}"-"$${BUILD_SHA:0:6}" \
+ && export ENVOY_DOCS_RELEASE_LEVEL=pre-release \
+ && mkdir -p build \
+ && tar xf $(location :rst) -C build \
+ && $(location :sphinx) \
+ -W \
+ --keep-going \
+ -b html \
+ build \
+ output \
+ && tar czf $@ -C output .
+ """,
+ tools = [
+ ":rst",
+ ":sphinx",
+ "//:VERSION",
+ "@envoy//bazel:volatile_env",
+ ],
+ stamp = 1,
+)
+
+genrule(
+ name = "html",
+ outs = ["html.tar.gz"],
cmd = """
mkdir -p build \
+ && VERSION_NUMBER="$$(cat $(location //:VERSION))" \
+ && BUILD_SHA="$${BUILD_SHA:-UNKNOWN}" \
+ && export ENVOY_DOCS_VERSION_STRING="$${VERSION_NUMBER}"-"$${BUILD_SHA:0:6}" \
+ && export ENVOY_DOCS_RELEASE_LEVEL=pre-release \
&& tar xf $(location :rst) -C build \
&& $(location :sphinx) \
-W \
@@ -74,5 +112,11 @@ genrule(
tools = [
":rst",
":sphinx",
+ "//:VERSION",
],
)
+
+alias(
+ name = "docs",
+ actual = ":html_release",
+)
diff --git a/docs/build.sh b/docs/build.sh
index a45286c397..65a9fe8b0f 100755
--- a/docs/build.sh
+++ b/docs/build.sh
@@ -19,16 +19,9 @@ then
# Check the version_history.rst contains current release version.
grep --fixed-strings "$VERSION_NUMBER" docs/root/intro/version_history.rst \
|| (echo "Git tag not found in version_history.rst" && exit 1)
-
- # Now that we now there is a match, we can use the tag.
- export ENVOY_DOCS_VERSION_STRING="tag-$GITHUB_REF_NAME"
- export ENVOY_DOCS_RELEASE_LEVEL=tagged
- export ENVOY_BLOB_SHA="$GITHUB_REF_NAME"
+ DOCS_TARGET=//docs
else
- BUILD_SHA=$(git rev-parse HEAD)
- export ENVOY_DOCS_VERSION_STRING="${VERSION_NUMBER}"-"${BUILD_SHA:0:6}"
- export ENVOY_DOCS_RELEASE_LEVEL=pre-release
- export ENVOY_BLOB_SHA="$BUILD_SHA"
+ DOCS_TARGET=//docs:html
fi

[[ -z "${DOCS_OUTPUT_DIR}" ]] && DOCS_OUTPUT_DIR=generated/docs
@@ -37,10 +30,6 @@ rm -rf "${DOCS_OUTPUT_DIR}"
mkdir -p "${DOCS_OUTPUT_DIR}"
DOCS_OUTPUT_DIR="$(realpath "$DOCS_OUTPUT_DIR")"

-./bazelw build \
- --action_env=ENVOY_BLOB_SHA \
- --action_env=ENVOY_DOCS_RELEASE_LEVEL \
- --action_env=ENVOY_DOCS_VERSION_STRING \
- //docs
+./bazelw build "$DOCS_TARGET"

tar xf bazel-bin/docs/docs.tar.gz -C "$DOCS_OUTPUT_DIR" .
diff --git a/docs/conf.py b/docs/conf.py
index d1b09cf5a7..be3faeb68b 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -52,7 +52,11 @@ if not os.environ.get('ENVOY_DOCS_RELEASE_LEVEL'):
raise Exception("ENVOY_DOCS_RELEASE_LEVEL env var must be defined")

release_level = os.environ['ENVOY_DOCS_RELEASE_LEVEL']
-blob_sha = os.environ['ENVOY_BLOB_SHA']
+blob_sha = os.environ.get(
+ "ENVOY_BLOB_SHA",
+ os.environ.get(
+ "ENVOY_MOBILE_BUILD_SCM_REVISION",
+ os.environ["BUILD_SCM_REVISION"]))

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@@ -103,8 +107,7 @@ copyright = u'{} {}'.format(datetime.now().year, author)
# |version| and |release|, also used in various other places throughout the
# built documents.

-if not os.environ.get('ENVOY_DOCS_VERSION_STRING'):
- raise Exception("ENVOY_DOCS_VERSION_STRING env var must be defined")
+

# The short X.Y version.
version = os.environ['ENVOY_DOCS_VERSION_STRING']
Loading