From e1d41938cfec923067ea878b0c2435f9c7f47957 Mon Sep 17 00:00:00 2001 From: Ezekiel Warren Date: Fri, 8 Sep 2023 11:20:48 -0700 Subject: [PATCH] feat: add bazel tests (#1) --- .bazelignore | 1 + .github/workflows/bazel.yml | 17 +++++++++++++++++ BUILD.bazel | 8 ++++++++ MODULE.bazel | 2 +- test/.bazelrc | 1 + test/.gitignore | 6 ++++++ test/BUILD.bazel | 10 ++++++++++ test/MODULE.bazel | 10 ++++++++++ test/WORKSPACE.bazel | 1 + 9 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 .bazelignore create mode 100644 .github/workflows/bazel.yml create mode 100644 test/.bazelrc create mode 100644 test/.gitignore create mode 100644 test/BUILD.bazel create mode 100644 test/MODULE.bazel create mode 100644 test/WORKSPACE.bazel diff --git a/.bazelignore b/.bazelignore new file mode 100644 index 000000000..32bcdf1ac --- /dev/null +++ b/.bazelignore @@ -0,0 +1 @@ +/test \ No newline at end of file diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml new file mode 100644 index 000000000..a12a0eaab --- /dev/null +++ b/.github/workflows/bazel.yml @@ -0,0 +1,17 @@ +name: bazel + +on: [pull_request] + +jobs: + test: + strategy: + matrix: + os: + - ubuntu-latest + - windows-latest + - macos-latest + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - run: bazelisk test ... + working-directory: test \ No newline at end of file diff --git a/BUILD.bazel b/BUILD.bazel index 6b684ce41..f3c5e3b89 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -4,10 +4,18 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "boost.filesystem", + srcs = glob([ + "src/**/*.hpp", + "src/**/*.cpp", + ]), hdrs = glob([ "include/**/*.hpp", "include/**/*.h", ]), + defines = [ + "BOOST_ALL_NO_LIB", + "BOOST_FILESYSTEM_NO_CXX20_ATOMIC_REF", + ], includes = ["include"], deps = [ "@boost.assert", diff --git a/MODULE.bazel b/MODULE.bazel index 6f911a76d..d34e41db3 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -10,7 +10,7 @@ bazel_dep(name = "boost.atomic", version = "1.83.0.bzl.1") bazel_dep(name = "boost.config", version = "1.83.0.bzl.6") bazel_dep(name = "boost.container_hash", version = "1.83.0.bzl.1") bazel_dep(name = "boost.core", version = "1.83.0.bzl.1") -bazel_dep(name = "boost.detail", version = "1.83.0.bzl.1") +bazel_dep(name = "boost.detail", version = "1.83.0.bzl.2") bazel_dep(name = "boost.io", version = "1.83.0.bzl.1") bazel_dep(name = "boost.iterator", version = "1.83.0.bzl.1") bazel_dep(name = "boost.predef", version = "1.83.0.bzl.1") diff --git a/test/.bazelrc b/test/.bazelrc new file mode 100644 index 000000000..c0224835f --- /dev/null +++ b/test/.bazelrc @@ -0,0 +1 @@ +import %workspace%/../.bazelrc \ No newline at end of file diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 000000000..563f04849 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1,6 @@ +# Bazel +/bazel-* +/external +/.cache +/compile_commands.json +user.bazelrc diff --git a/test/BUILD.bazel b/test/BUILD.bazel new file mode 100644 index 000000000..c1d774813 --- /dev/null +++ b/test/BUILD.bazel @@ -0,0 +1,10 @@ +load("@rules_cc//cc:defs.bzl", "cc_test") + +cc_test( + name = "copy_test", + srcs = ["copy_test.cpp"], + deps = [ + "@boost.test", + "@boost.filesystem", + ], +) diff --git a/test/MODULE.bazel b/test/MODULE.bazel new file mode 100644 index 000000000..78344e5a4 --- /dev/null +++ b/test/MODULE.bazel @@ -0,0 +1,10 @@ +module(name = "boost.filesystem.test") + +bazel_dep(name = "rules_cc", version = "0.0.8") +bazel_dep(name = "boost.test", version = "1.83.0.bzl.1") +bazel_dep(name = "boost.filesystem") + +local_path_override( + module_name = "boost.filesystem", + path = "..", +) diff --git a/test/WORKSPACE.bazel b/test/WORKSPACE.bazel new file mode 100644 index 000000000..be0754f66 --- /dev/null +++ b/test/WORKSPACE.bazel @@ -0,0 +1 @@ +# SEE: MODULE.bazel