Skip to content

Commit cc7b23b

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: 925427247
1 parent dfea16a commit cc7b23b

6 files changed

Lines changed: 61 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
@@ -115,6 +115,7 @@ cc_library(
115115
"@com_google_googleapis//google/rpc:code_cc_proto",
116116
"@com_google_protobuf//:protobuf",
117117
"@com_google_protobuf//src/google/protobuf/io",
118+
"@rules_cc//cc/runfiles",
118119
],
119120
alwayslink = True,
120121
)

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: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "google/api/expr/v1alpha1/value.pb.h"
3737
#include "cel/expr/value.pb.h"
3838
#include "google/rpc/code.pb.h"
39+
#include "rules_cc/cc/runfiles/runfiles.h"
3940
#include "absl/flags/flag.h"
4041
#include "absl/log/absl_check.h"
4142
#include "absl/status/status.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,19 @@ 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;
81+
82+
std::string ResolveRunfilesPath(absl::string_view path) {
83+
using ::rules_cc::cc::runfiles::Runfiles;
84+
static Runfiles* runfiles = []() {
85+
std::string error;
86+
auto runfiles = absl::WrapUnique(
87+
Runfiles::CreateForTest(BAZEL_CURRENT_REPOSITORY, &error));
88+
ABSL_QCHECK(runfiles != nullptr)
89+
<< absl::StrCat("failed to init runfiles", error);
90+
}();
91+
return runfiles->Rlocation(path);
92+
}
8193

8294
google::rpc::Code ToGrpcCode(absl::StatusCode code) {
8395
return static_cast<google::rpc::Code>(code);
@@ -282,8 +294,9 @@ int main(int argc, char** argv) {
282294
}
283295
}
284296
for (int argi = 1; argi < argc; argi++) {
297+
std::string path = ResolveRunfilesPath(argv[argi]);
285298
ABSL_CHECK_OK(RegisterTestsFromFile(service, tests_to_skip,
286-
absl::string_view(argv[argi])));
299+
absl::string_view(path)));
287300
}
288301
}
289302
int exit_code = RUN_ALL_TESTS();

0 commit comments

Comments
 (0)