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

Project import generated by Copybara. #40

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 8 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: Bazel

on: [pull_request]

jobs:
bazel-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Mount bazel cache
uses: actions/cache@v3
- uses: actions/cache@v3
with:
path: "~/.cache/bazel"
key: bazel
path: |
~/.cache/bazelisk
~/.cache/bazel
key: bazel-${{ hashFiles('.bazelrc', '.bazelversion', 'WORKSPACE', 'requirements.txt') }}
restore-keys: bazel-
- run: bazelisk build //...
10 changes: 9 additions & 1 deletion api/nbi/v1alpha/resources/antenna_pattern.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ option go_package = "aalyria.com/spacetime/api/nbi/v1alpha/resources";
// Models an antenna radiation pattern. Multiple platform definitions can
// reference the same antenna pattern.
message AntennaPattern {
reserved 8, 11 to max;
reserved 8, 12 to max;

// A custom / user-defined antenna radiation pattern.
message CustomAntennaPattern {
Expand Down Expand Up @@ -117,6 +117,13 @@ message AntennaPattern {
optional double near_field_range_m = 3;
}

// Applies a different antenna radiation pattern for the transmitter
// and receiver.
message TransmitterAndReceiverAntennaPattern {
optional AntennaPattern transmitter_pattern = 1;
optional AntennaPattern receiver_pattern = 2;
}

oneof pattern_type {
CustomAntennaPattern custom_pattern = 1;
GaussianAntennaPattern gaussian_pattern = 2;
Expand All @@ -127,5 +134,6 @@ message AntennaPattern {
GaussianOpticalAntennaPattern gaussian_optical_pattern = 7;
PhasedArrayAntennaPattern phased_array_pattern = 10;
NearAndFarFieldAntennaPattern near_and_far_field_pattern = 9;
TransmitterAndReceiverAntennaPattern transmitter_and_receiver_pattern = 11;
}
}
6 changes: 6 additions & 0 deletions api/nbi/v1alpha/resources/network_link.proto
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ message WirelessLinkReport {

// The modeled data rate capacity, in layer 2 bits per second.
optional double data_rate_bps = 6;

// The transmitter antenna's gain in the link direction, in dB.
optional double transmitter_antenna_gain_in_link_direction_db = 7;

// The receiver antenna's gain in the link direction, in dB.
optional double receiver_antenna_gain_in_link_direction_db = 8;
}
repeated WirelessLinkMetrics sampled_metrics = 4;
}
Expand Down
18 changes: 18 additions & 0 deletions bazel/java_format_rules/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2023 Aalyria Technologies, Inc., and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

exports_files([
"def.bzl",
"runner.bash.template",
])
107 changes: 107 additions & 0 deletions bazel/java_format_rules/def.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Copyright 2023 Aalyria Technologies, Inc., and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Bazel rules for testing compliance with google-java-format."""

load("@bazel_skylib//lib:shell.bzl", "shell")

def _java_format_test_impl(ctx):
out_file = ctx.actions.declare_file(ctx.label.name + ".bash")
runfiles = [ctx.executable.google_java_format]
substitutions = {
"@@GOOGLE_JAVA_FORMAT@@": shell.quote(ctx.executable.google_java_format.short_path),
"@@SRCS@@": "",
}
if ctx.file.workspace != None:
runfiles.append(ctx.file.workspace)
substitutions["@@WORKSPACE@@"] = ctx.file.workspace.path
else:
for f in ctx.files.srcs:
runfiles.append(f)
substitutions["@@SRCS@@"] = " ".join([shell.quote(f.short_path) for f in ctx.files.srcs])

ctx.actions.expand_template(
template = ctx.file._runner,
output = out_file,
substitutions = substitutions,
is_executable = True,
)

shell_runfiles = ctx.runfiles(files = runfiles)
merged_runfiles = shell_runfiles.merge(ctx.attr.google_java_format[DefaultInfo].default_runfiles)

return DefaultInfo(
files = depset([out_file]),
runfiles = merged_runfiles,
executable = out_file,
)

java_format_test = rule(
implementation = _java_format_test_impl,
test = True,
attrs = {
"srcs": attr.label_list(
allow_files = [".java"],
doc = "A list of Java files to check for formatting",
),
"google_java_format": attr.label(
default = "//third_party/java/google_java_format",
cfg = "exec",
executable = True,
),
"workspace": attr.label(
allow_single_file = True,
doc = "Label of the WORKSPACE file",
),
"_runner": attr.label(
default = ":runner.bash.template",
allow_single_file = True,
),
},
)

# def _validation_aspect_impl(target, ctx):
# validation_output = ctx.actions.declare_file(ctx.rule.attr.name + ".validation")
# args = ctx.actions.args()
# args.add(validation_output)
# inputs = []
# if hasattr(ctx.rule.attr, "srcs"):
# for s in ctx.rule.attr.srcs:
# for f in s.files.to_list():
# if f.extension == "java" and not f.path.startswith("external"):
# inputs.append(f)
# args.add(f.path)

# if
# if not inputs:
# ctx.actions.write(output = validation_output, content="")
# else:
# ctx.actions.run_shell(
# inputs = inputs,
# outputs = [validation_output],
# arguments = [args],
# tools = [ctx.executable._google_java_format],
# progress_message = "Checking %d files for formatting" % len(inputs),
# command = 'set -x; outfile="$1"; shift; "%s" -n --set-exit-if-changed "$@" > "$outfile"' % ctx.executable._google_java_format.path,
# )

# validation_outputs_in_deps = []
# for d in ctx.rule.attr.deps:
# validation_outputs_in_deps.append(d[OutputGroupInfo]._validation)

# return [
# OutputGroupInfo(
# _validation = depset(
# [validation_output],
# transitive = validation_outputs_in_deps)),
# ]
79 changes: 79 additions & 0 deletions bazel/java_format_rules/runner.bash.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env bash

# Copyright 2023 Aalyria Technologies, Inc., and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -euo pipefail

WORKSPACE="@@WORKSPACE@@"
SRCS=(@@SRCS@@)
GOOGLE_JAVA_FORMAT=@@GOOGLE_JAVA_FORMAT@@
GOOGLE_JAVA_FORMAT="$(readlink "$GOOGLE_JAVA_FORMAT")"

main() {
if [[ ${#SRCS[@]} -gt 0 ]]
then
check_srcs
else
check_repo
fi
}

check_srcs() {
# the bulk of the time spent checking formatting is in the jvm startup time,
# but the full batch output is difficult to read and generate diffs off. To
# get a mix of speed and helpful error messages, we run the tool once against
# all the files with --dry-run set (which prints the list of files that are
# incorrectly formatted) then we loop over those if necessary to generate the
# human-friendly diffs
local unformatted_files=()
mapfile -t unformatted_files < <("$GOOGLE_JAVA_FORMAT" --dry-run "${SRCS[@]}")

for src in "${unformatted_files[@]}";
do
"$GOOGLE_JAVA_FORMAT" "$src" | diff -u3 "$src" - || true
done

[[ "${#unformatted_files[@]}" -eq 0 ]]
}

check_repo() {
# Use TEST_WORKSPACE to determine if the script is being ran under a test
if [[ ! -z "${TEST_WORKSPACE+x}" && -z "${BUILD_WORKSPACE_DIRECTORY+x}" ]]; then
FIND_FILE_TYPE="l"
# If WORKSPACE was provided, then the script is being run under a test in no_sandbox mode
# cd to the directory containing the WORKSPACE file
if [[ ! -z "${WORKSPACE+x}" ]]; then
FIND_FILE_TYPE="f"
WORKSPACE_PATH="$(dirname "$(realpath ${WORKSPACE})")"
if ! cd "$WORKSPACE_PATH" ; then
echo "Unable to change to workspace (WORKSPACE_PATH: ${WORKSPACE_PATH})"
fi
fi
else
# Change into the workspace directory if this is _not_ a test
if ! cd "$BUILD_WORKSPACE_DIRECTORY"; then
echo "Unable to change to workspace (BUILD_WORKSPACE_DIRECTORY: ${BUILD_WORKSPACE_DIRECTORY})"
exit 1
fi
fi

find . \
-type "${FIND_FILE_TYPE:-f}" \
\( -name '*.java' \
\) -print0 | xargs -0 "$GOOGLE_JAVA_FORMAT" --set-exit-if-changed --dry-run

}

main "$@"
7 changes: 7 additions & 0 deletions java/com/aalyria/spacetime/authentication/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("//bazel/java_format_rules:def.bzl", "java_format_test")

package(default_visibility = ["//visibility:public"])

java_format_test(
name = "java_format_test",
srcs = glob(["*.java"]),
)

java_library(
name = "Authentication",
srcs = [
Expand Down
7 changes: 7 additions & 0 deletions java/com/aalyria/spacetime/codesamples/nbi/client/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("//bazel/java_format_rules:def.bzl", "java_format_test")

java_format_test(
name = "java_format_test",
srcs = glob(["*.java"]),
)

java_binary(
name = "ListEntities",
srcs = [
Expand Down
7 changes: 7 additions & 0 deletions javatests/com/aalyria/spacetime/authentication/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("//bazel/java_format_rules:def.bzl", "java_format_test")

java_format_test(
name = "java_format_test",
srcs = glob(["*.java"]),
)

java_test(
name = "SpacetimeCallCredentialsTest",
srcs = [
Expand Down
14 changes: 14 additions & 0 deletions patches/BUILD
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
# Copyright 2023 Aalyria Technologies, Inc., and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

exports_files(["grpc.patch"])
17 changes: 17 additions & 0 deletions tools/gopackagesdriver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
#
# Copyright 2023 Aalyria Technologies, Inc., and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

exec bazel run -- @io_bazel_rules_go//go/tools/gopackagesdriver "${@}"