Skip to content

Commit db0725c

Browse files
jnthntatumcopybara-github
authored andcommitted
Add basic workflow for windows/bazel test (#2039)
Add basic workflow for running conformance tests on windows. Only run on post merge or manually for now. Closes #2039 PiperOrigin-RevId: 925547950
1 parent dfea16a commit db0725c

9 files changed

Lines changed: 130 additions & 4 deletions

File tree

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ build:linux --copt=-Wno-deprecated-declarations
1010
# you will typically need to spell out the compiler for local dev
1111
# BAZEL_VC=<install directory>
1212
# BAZEL_VC_FULL_VERSION=14.44.3520
13+
# Some dependencies rely on bash so you will likely need msys2
14+
# BAZEL_SH=C:\msys64\usr\bin\bash.exe
1315
build:msvc --cxxopt="-std:c++20" --cxxopt="-utf-8" --host_cxxopt="-std:c++20"
1416
build:msvc --define=protobuf_allow_msvc=true
1517
build:msvc --test_tag_filters=-benchmark,-notap,-no_test_msvc
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Windows Bazel Test
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
jobs:
8+
test:
9+
name: Run Bazel Tests
10+
runs-on: windows-latest
11+
steps:
12+
- name: Checkout Repository
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Bazel and Bazelisk
16+
uses: bazel-contrib/setup-bazel@0.19.0
17+
with:
18+
bazelisk-cache: true
19+
disk-cache: ${{ github.workflow }}
20+
repository-cache: true
21+
22+
- name: Run Tests
23+
# msys2 'bash' on Windows will try to 'fix' the label prefix to
24+
# work as a directory.
25+
# //... won't work.
26+
shell: bash
27+
run: |
28+
bazelisk test --config=msvc conformance:all
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Windows Bazel Test (Post-Merge)
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
trigger-test:
10+
# This prevents the workflow from running automatically when someone
11+
# pushes to their fork.
12+
if: github.repository == 'google/cel-cpp'
13+
uses: ./.github/workflows/windows_bazel_test.yml

conformance/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ cc_library(
9999
deps = [
100100
":service",
101101
":utils",
102+
"//internal:runfiles",
102103
"//internal:testing_no_main",
103104
"@com_google_absl//absl/flags:flag",
104105
"@com_google_absl//absl/log:absl_check",

conformance/run.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def _conformance_test_args(modern, optimize, recursive, select_opt, skip_check,
7777
def _conformance_test(name, data, modern, optimize, recursive, select_opt, skip_check, skip_tests, tags, dashboard):
7878
cc_test(
7979
name = _conformance_test_name(name, optimize, recursive),
80-
args = _conformance_test_args(modern, optimize, recursive, select_opt, skip_check, dashboard) + ["$(location " + test + ")" for test in data],
80+
args = _conformance_test_args(modern, optimize, recursive, select_opt, skip_check, dashboard) + ["$(rlocationpath {})".format(test) for test in data],
8181
env = select(
8282
{
8383
"@platforms//os:windows": {"CEL_SKIP_TESTS": ",".join(skip_tests + _TESTS_TO_SKIP_WINDOWS)},

conformance/run.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "absl/types/span.h"
4949
#include "conformance/service.h"
5050
#include "conformance/utils.h"
51+
#include "internal/runfiles.h"
5152
#include "internal/testing.h"
5253
#include "cel/expr/conformance/test/simple.pb.h"
5354
#include "google/protobuf/io/zero_copy_stream_impl.h"
@@ -68,8 +69,6 @@ ABSL_FLAG(bool, select_optimization, false, "Enable select optimization.");
6869

6970
namespace {
7071

71-
using ::testing::IsEmpty;
72-
7372
using cel::expr::conformance::test::SimpleTest;
7473
using cel::expr::conformance::test::SimpleTestFile;
7574
using google::api::expr::conformance::v1alpha1::CheckRequest;
@@ -78,6 +77,7 @@ using google::api::expr::conformance::v1alpha1::EvalRequest;
7877
using google::api::expr::conformance::v1alpha1::EvalResponse;
7978
using google::api::expr::conformance::v1alpha1::ParseRequest;
8079
using google::api::expr::conformance::v1alpha1::ParseResponse;
80+
using ::testing::IsEmpty;
8181

8282
google::rpc::Code ToGrpcCode(absl::StatusCode code) {
8383
return static_cast<google::rpc::Code>(code);
@@ -282,8 +282,9 @@ int main(int argc, char** argv) {
282282
}
283283
}
284284
for (int argi = 1; argi < argc; argi++) {
285+
std::string path = cel::internal::ResolveRunfilesPath(argv[argi]);
285286
ABSL_CHECK_OK(RegisterTestsFromFile(service, tests_to_skip,
286-
absl::string_view(argv[argi])));
287+
absl::string_view(path)));
287288
}
288289
}
289290
int exit_code = RUN_ALL_TESTS();

internal/BUILD

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ cc_library(
8686
],
8787
)
8888

89+
cc_library(
90+
name = "runfiles",
91+
srcs = ["runfiles.cc"],
92+
hdrs = ["runfiles.h"],
93+
deps = [
94+
"@com_google_absl//absl/log:absl_check",
95+
"@com_google_absl//absl/strings",
96+
"@rules_cc//cc/runfiles",
97+
],
98+
)
99+
89100
cc_library(
90101
name = "status_builder",
91102
hdrs = ["status_builder.h"],

internal/runfiles.cc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright 2026 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "internal/runfiles.h"
16+
17+
#include <string>
18+
19+
#include "rules_cc/cc/runfiles/runfiles.h"
20+
21+
#include "absl/log/absl_check.h"
22+
#include "absl/strings/str_cat.h"
23+
#include "absl/strings/string_view.h"
24+
25+
namespace cel::internal {
26+
27+
std::string ResolveRunfilesPath(absl::string_view path) {
28+
using ::rules_cc::cc::runfiles::Runfiles;
29+
static Runfiles* runfiles = []() {
30+
std::string error;
31+
auto runfiles =
32+
Runfiles::CreateForTest(BAZEL_CURRENT_REPOSITORY, &error);
33+
ABSL_QCHECK(runfiles != nullptr)
34+
<< absl::StrCat("failed to init runfiles", error);
35+
return runfiles;
36+
}();
37+
return runfiles->Rlocation(std::string(path));
38+
}
39+
40+
} // namespace cel::internal

internal/runfiles.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2026 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef THIRD_PARTY_CEL_CPP_INTERNAL_RUNFILES_H_
16+
#define THIRD_PARTY_CEL_CPP_INTERNAL_RUNFILES_H_
17+
18+
#include <string>
19+
20+
#include "absl/strings/string_view.h"
21+
22+
namespace cel::internal {
23+
24+
// Resolves a path relative to the runfiles directory.
25+
// Intended for resolving test cases from cel-spec and cel-policy.
26+
std::string ResolveRunfilesPath(absl::string_view path);
27+
28+
} // namespace cel::internal
29+
30+
#endif // THIRD_PARTY_CEL_CPP_INTERNAL_RUNFILES_H_

0 commit comments

Comments
 (0)