-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Github actions and some initial build files.
PiperOrigin-RevId: 687389500
- Loading branch information
Showing
10 changed files
with
295 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Use C++ 20. | ||
build --cxxopt=-std=c++20 | ||
build --host_cxxopt=-std=c++20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: build | ||
|
||
# Controls when the workflow will run | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the "main" branch | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
schedule: | ||
# Run daily at midnight to ensure we catch regressions. | ||
- cron: "0 0 * * *" | ||
# Manual | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Mount bazel cache | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: "~/.cache/bazel" | ||
key: bazel-${{ hashFiles('MODULE.bazel', 'WORKSPACE.bazel', '.bazelrc') }}-${{ github.ref_name }} | ||
restore-keys: | | ||
bazel-${{hashFiles('MODULE.bazel', 'WORKSPACE.bazel', '.bazelrc') }}-${{ github.ref_name }} | ||
bazel-${{hashFiles('MODULE.bazel', 'WORKSPACE.bazel', '.bazelrc') }} | ||
bazel- | ||
- name: Build | ||
run: ./bazel build --test_output=errors //... | ||
- name: Test | ||
run: ./bazel test --test_output=errors //... | ||
|
||
- name: Compress cache | ||
run: rm -rf $(./bazel info repository_cache) | ||
|
||
- name: Save bazel cache | ||
uses: actions/cache/save@v4 | ||
# Only create a new cache entry if we're on the main branch or the build takes >5mins. | ||
if: github.ref_name == "main" || env.duration > 300 | ||
with: | ||
path: "~/.cache/bazel" | ||
key: bazel-${{ hashFiles('MODULE.bazel', 'WORKSPACE.bazel', '.bazelrc') }}-${{ github.ref_name }}-${{ github.run_id }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright 2024 The NetKAT authors | ||
# | ||
# 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 | ||
# | ||
# https://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. | ||
|
||
# https://bazel.build/external/overview#bzlmod | ||
|
||
module( | ||
name = "google-netkat", | ||
version = "0.0.1", | ||
bazel_compatibility = [">=7.3.2"], | ||
compatibility_level = 1, | ||
) | ||
|
||
bazel_dep(name = "rules_cc", version = "0.0.13") | ||
bazel_dep(name = "rules_license", version = "1.0.0") | ||
bazel_dep(name = "protobuf", version = "28.2", repo_name = "com_google_protobuf") | ||
bazel_dep(name = "abseil-cpp", version = "20240116.2", repo_name = "com_google_absl") | ||
bazel_dep(name = "googletest", version = "1.15.2", repo_name = "com_google_googletest") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
|
||
package( | ||
default_applicable_licenses = ["//:license"], | ||
default_visibility = [":__subpackages__"], | ||
) | ||
|
||
proto_library( | ||
name = "netkat_proto", | ||
srcs = ["netkat.proto"], | ||
) | ||
|
||
cc_proto_library( | ||
name = "netkat_cc_proto", | ||
deps = [":netkat_proto"], | ||
) | ||
|
||
cc_test( | ||
name = "netkat_test", | ||
srcs = ["netkat_test.cc"], | ||
deps = [ | ||
":netkat_cc_proto", | ||
"@com_google_absl//absl/log", | ||
"@com_google_googletest//:gtest_main", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright 2024 The NetKAT authors | ||
// | ||
// 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 | ||
// | ||
// https://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. | ||
// ----------------------------------------------------------------------------- | ||
|
||
// Proto representation of NetKAT programs (predicates and policies). | ||
// | ||
// This representation is NOT intended as a user-facing API. Instead, it serves | ||
// as an intermdiate representation (IR) that is produced by user-facing | ||
// NetKAT APIs (NetKAT frontend(s)) and consumed by NetKAT backends. | ||
// | ||
// This reprensentation is expected to lack the convenience and type safety of | ||
// the user-facing API. | ||
// | ||
// Why have an IR? | ||
// * Designing an ergonomic user-facing API is hard, and requires resolving many | ||
// design questions without an obvious "best" answer. | ||
// * By having an IR, we can immediately work on the backend without waiting for | ||
// the user-facing API to be finalized. More generally, it decouples the | ||
// frontend design from the backend design. | ||
// * Given that there is likely not a single best user-facing API, we may want | ||
// to explore multiple ones (but share the IR and backend). | ||
// * It may make sense to have a specialized frontend API tailroed to Google's | ||
// internal needs, but it will likely not be open-sourceable. | ||
// | ||
// Why use protobufs for the IR? | ||
// * It provides many useful features out of the box: | ||
// serialization/deserialization, pretty-printing, a text format, fuzzing | ||
// (e.g. using https://github.com/google/fuzztest), diffing. | ||
// * It makes it easy to implement frontends and backends in different | ||
// programming languages. | ||
// * It makes it easy to run backends as (gRPC) services. | ||
|
||
syntax = "proto3"; | ||
|
||
package netkat; | ||
|
||
// A NetKAT predicate (internal intermdiate representation). | ||
message PredicateProto { | ||
oneof predicate { | ||
Bool bool_constant = 1; | ||
Match match = 3; | ||
And and_operation = 4; | ||
Or or_operation = 5; | ||
Not not_operation = 6; | ||
} | ||
|
||
// A boolean constant (true or false). | ||
message Bool { | ||
bool value = 1; | ||
} | ||
|
||
// Checks if a field has a specific value. | ||
// | ||
// NOTE: This message is expected to change in the future! E.g., the type of | ||
// `value` will change to support things like 128-bit IPv6 addresses. | ||
message Match { | ||
string field = 1; | ||
int32 value = 2; | ||
} | ||
|
||
// Boolean conjunction (&&) of two predicates. | ||
message And { | ||
PredicateProto left = 1; | ||
PredicateProto right = 2; | ||
} | ||
|
||
// Boolean disjunction (||) of two predicates. | ||
message Or { | ||
PredicateProto left = 1; | ||
PredicateProto right = 2; | ||
} | ||
|
||
// Boolean negation (!) of a predicate. | ||
message Not { | ||
PredicateProto negand = 1; | ||
} | ||
} |
Oops, something went wrong.