diff options
| author | Leitwolf11 | 2026-11-15 23:08:05 +0300 |
|---|---|---|
| committer | Leitwolf11 | 2026-11-15 23:08:05 +0300 |
| commit | 67c3ef401b34716f7214374ff0d6c24b3c50a149 (patch) | |
| tree | c4c97fb09f6e1364d8b44f74fca32f18065588b0 | |
| parent | 2fbb5585e35078cb2490c8ae988860aa6dc0399d (diff) | |
| download | catch3-67c3ef401b34716f7214374ff0d6c24b3c50a149.tar.gz | |
Prepare the Bazel Central Registry entry as progmasoft_catch3
- MODULE.bazel names the module progmasoft_catch3, the name it has in
the registry, with bazel_compatibility >=8.0.0; //tools:version finds
the version under the new name.
- .bcr/ holds the templates publish-to-bcr fills: metadata, source (the
GitHub archive of the catch3-* tag) and the presubmit, which runs the
test module on Debian, Ubuntu, macOS (x86-64 and arm64) and Windows
with Bazel 8.x and 9.x.
- tests/Progmasoft/BazelModule is a module that depends on Catch3 as a
user's does, through //:catch3_main and through //:catch3 with its
own main. The root ignores it; Bazel Builds tests it with Bazel 8.x
and 9.x on Ubuntu and Windows.
- Publish to BCR runs when a catch3-* release is published, or by hand
for a tag, and opens the registry pull request from the fork of the
maintainer, without attestations.
- The integration guide says how a module depends on progmasoft_catch3.
Claude-Session: https://claude.ai/code/session_01Ji7xZMYjc4zankoc7hGBE1
| -rw-r--r-- | .bazelignore | 5 | ||||
| -rw-r--r-- | .bcr/metadata.template.json | 14 | ||||
| -rw-r--r-- | .bcr/presubmit.yml | 17 | ||||
| -rw-r--r-- | .bcr/source.template.json | 5 | ||||
| -rw-r--r-- | .github/workflows/bazel-builds.yml | 29 | ||||
| -rw-r--r-- | .github/workflows/publish-to-bcr.yml | 35 | ||||
| -rw-r--r-- | MODULE.bazel | 2 | ||||
| -rw-r--r-- | docs/progmasoft-catch3.md | 18 | ||||
| -rw-r--r-- | tests/Progmasoft/BazelModule/.bazelrc | 12 | ||||
| -rw-r--r-- | tests/Progmasoft/BazelModule/BUILD.bazel | 16 | ||||
| -rw-r--r-- | tests/Progmasoft/BazelModule/MODULE.bazel | 14 | ||||
| -rw-r--r-- | tests/Progmasoft/BazelModule/OwnMain.tests.cpp | 18 | ||||
| -rw-r--r-- | tests/Progmasoft/BazelModule/WithMain.tests.cpp | 13 | ||||
| l--------- | tests/Progmasoft/BazelModule/bazel-BazelModule | 1 | ||||
| l--------- | tests/Progmasoft/BazelModule/bazel-bin | 1 | ||||
| l--------- | tests/Progmasoft/BazelModule/bazel-out | 1 | ||||
| l--------- | tests/Progmasoft/BazelModule/bazel-testlogs | 1 | ||||
| -rw-r--r-- | tools/Versions.cpp | 4 |
18 files changed, 202 insertions, 4 deletions
diff --git a/.bazelignore b/.bazelignore new file mode 100644 index 00000000..ec2c63a6 --- /dev/null +++ b/.bazelignore @@ -0,0 +1,5 @@ +# Copyright (c) 2026 Progmasoft. +# SPDX-License-Identifier: LGPL-3.0-or-later + +# A module of its own, built by CI and by the Bazel Central Registry. +tests/Progmasoft/BazelModule diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json new file mode 100644 index 00000000..3f80ce9a --- /dev/null +++ b/.bcr/metadata.template.json @@ -0,0 +1,14 @@ +{ + "homepage": "https://github.com/Progmasoft/catch3", + "maintainers": [ + { + "name": "Leitwolf11", + "email": "[email protected]", + "github": "Leitwolf11", + "github_user_id": 238872178 + } + ], + "repository": ["github:Progmasoft/catch3"], + "versions": [], + "yanked_versions": {} +} diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml new file mode 100644 index 00000000..a29cc665 --- /dev/null +++ b/.bcr/presubmit.yml @@ -0,0 +1,17 @@ +# SPDX-FileCopyrightText: 2026 Progmasoft <[email protected]> +# SPDX-License-Identifier: LGPL-3.0-or-later + +# The Bazel Central Registry builds and runs the test module, which depends on +# progmasoft_catch3 as a user's module does, on each platform and Bazel line. +bcr_test_module: + module_path: tests/Progmasoft/BazelModule + matrix: + platform: [debian11, ubuntu2204, macos, macos_arm64, windows] + bazel: [8.x, 9.x] + tasks: + run_test_module: + name: Run the test module + platform: ${{ platform }} + bazel: ${{ bazel }} + test_targets: + - //... diff --git a/.bcr/source.template.json b/.bcr/source.template.json new file mode 100644 index 00000000..e68c53b4 --- /dev/null +++ b/.bcr/source.template.json @@ -0,0 +1,5 @@ +{ + "integrity": "", + "strip_prefix": "{REPO}-{TAG}", + "url": "https://github.com/{OWNER}/{REPO}/archive/refs/tags/{TAG}.tar.gz" +} diff --git a/.github/workflows/bazel-builds.yml b/.github/workflows/bazel-builds.yml index 8033e3d7..f0672a7a 100644 --- a/.github/workflows/bazel-builds.yml +++ b/.github/workflows/bazel-builds.yml @@ -42,3 +42,32 @@ jobs: run: bazel test tests/Progmasoft:property_tests env: CC: clang + + module: + name: Bazel ${{ matrix.bazel }} module on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-2025-vs2026, ubuntu-26.04] + # bazel_compatibility in MODULE.bazel is >=8.0.0; the Bazel Central + # Registry runs the same test module on both lines. + bazel: [8.x, 9.x] + + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 + with: + persist-credentials: false + + - uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86 # 0.19.0 + with: + bazelisk-cache: true + repository-cache: true + + - name: Test the module as a user's module depends on it + working-directory: tests/Progmasoft/BazelModule + run: bazel test //... + shell: bash + env: + USE_BAZEL_VERSION: ${{ matrix.bazel }} + BAZEL_SH: ${{ runner.os == 'Windows' && 'C:\Program Files\Git\bin\bash.exe' || '' }} diff --git a/.github/workflows/publish-to-bcr.yml b/.github/workflows/publish-to-bcr.yml new file mode 100644 index 00000000..beac20a0 --- /dev/null +++ b/.github/workflows/publish-to-bcr.yml @@ -0,0 +1,35 @@ +# SPDX-FileCopyrightText: 2026 Progmasoft <[email protected]> +# SPDX-License-Identifier: LGPL-3.0-or-later + +# Opens the pull request that adds a release to the Bazel Central Registry as +# progmasoft_catch3, from the templates in .bcr/. The registry builds the test +# module of .bcr/presubmit.yml before it accepts the version. +name: Publish to BCR + +on: + release: + types: [published] + workflow_dispatch: + inputs: + tag_name: + description: The release tag, such as catch3-0.5.0 + required: true + type: string + +permissions: {} + +jobs: + publish: + if: startsWith(github.event.release.tag_name || inputs.tag_name, 'catch3-') + uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@3b1b972e41764b9a7498cf9128ed4ed2258a3687 # v1.6.0 + with: + tag_name: ${{ github.event.release.tag_name || inputs.tag_name }} + tag_prefix: catch3- + registry_fork: Leitwolf11/bazel-central-registry + # BCR accepts source attestations only from bazel-contrib's release + # workflow; Catch3's releases are made without it. + attest: false + permissions: + contents: write # the reusable workflow may add files to the release + secrets: + publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }} diff --git a/MODULE.bazel b/MODULE.bazel index 6e0fb394..d64c1bb0 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,4 +1,4 @@ -module(name = "catch3", version = "0.4.0") +module(name = "progmasoft_catch3", version = "0.4.0", bazel_compatibility = [">=8.0.0"]) bazel_dep(name = "bazel_skylib", version = "1.9.0") bazel_dep(name = "rules_cc", version = "0.2.17") diff --git a/docs/progmasoft-catch3.md b/docs/progmasoft-catch3.md index ee222e6d..05948fd4 100644 --- a/docs/progmasoft-catch3.md +++ b/docs/progmasoft-catch3.md @@ -179,8 +179,22 @@ find_package(Catch3 0.3 CONFIG REQUIRED) target_link_libraries(MyTests PRIVATE Catch3::Catch3WithMain) ``` -The Bazel target is `//:catch3`; its tests are -`//tests/Progmasoft:property_tests`. Bazel is the primary +In the Bazel Central Registry, from 0.5.0 on, the module is +`progmasoft_catch3`, for Bazel 8 and later: + +```starlark +bazel_dep(name = "progmasoft_catch3", version = "0.5.0") +``` + +Its targets are `@progmasoft_catch3//:catch3` and +`@progmasoft_catch3//:catch3_main`, which brings `main`. Code that includes +the headers is C++17 or later, so a module that is not already set to it +passes `--cxxopt=-std=c++17` (`--cxxopt=/std:c++17` with MSVC, which defaults +to C++14). + +In this repository the Bazel target is `//:catch3`; its tests are +`//tests/Progmasoft:property_tests`, and `tests/Progmasoft/BazelModule` is a +module that depends on Catch3 as a user's does. Bazel is the primary build path; CMake, Meson, Xmake, and Premake are also maintained as alternate ways to build the same engine and property tests. Their root files are `CMakeLists.txt`, `meson.build`, `xmake.lua`, and `premake5.lua`. Xmake and diff --git a/tests/Progmasoft/BazelModule/.bazelrc b/tests/Progmasoft/BazelModule/.bazelrc new file mode 100644 index 00000000..b99caaba --- /dev/null +++ b/tests/Progmasoft/BazelModule/.bazelrc @@ -0,0 +1,12 @@ +# Copyright (c) 2026 Progmasoft. +# SPDX-License-Identifier: LGPL-3.0-or-later + +# Code that includes the headers of Catch3 is C++17 or later, as it must be in +# a user's module; MSVC defaults to C++14. +common --enable_platform_specific_config +build:linux --cxxopt=-std=c++17 +build:macos --cxxopt=-std=c++17 +build:windows --cxxopt=/std:c++17 + +# The lockfile is the user's; this module keeps none. +common --lockfile_mode=off diff --git a/tests/Progmasoft/BazelModule/BUILD.bazel b/tests/Progmasoft/BazelModule/BUILD.bazel new file mode 100644 index 00000000..c95b5ddf --- /dev/null +++ b/tests/Progmasoft/BazelModule/BUILD.bazel @@ -0,0 +1,16 @@ +# Copyright (c) 2026 Progmasoft. +# SPDX-License-Identifier: LGPL-3.0-or-later +load("@rules_cc//cc:defs.bzl", "cc_test") + +# Each public name of the module, as a user links it. +cc_test( + name = "with_main", + srcs = ["WithMain.tests.cpp"], + deps = ["@progmasoft_catch3//:catch3_main"], +) + +cc_test( + name = "own_main", + srcs = ["OwnMain.tests.cpp"], + deps = ["@progmasoft_catch3//:catch3"], +) diff --git a/tests/Progmasoft/BazelModule/MODULE.bazel b/tests/Progmasoft/BazelModule/MODULE.bazel new file mode 100644 index 00000000..fa0d4bdb --- /dev/null +++ b/tests/Progmasoft/BazelModule/MODULE.bazel @@ -0,0 +1,14 @@ +# Copyright (c) 2026 Progmasoft. +# SPDX-License-Identifier: LGPL-3.0-or-later + +# A module that uses progmasoft_catch3 as a user's does. CI builds it from this +# checkout; the Bazel Central Registry builds it from the published version. +module(name = "progmasoft_catch3_test_module") + +bazel_dep(name = "progmasoft_catch3") +local_path_override( + module_name = "progmasoft_catch3", + path = "../../..", +) + +bazel_dep(name = "rules_cc", version = "0.2.17") diff --git a/tests/Progmasoft/BazelModule/OwnMain.tests.cpp b/tests/Progmasoft/BazelModule/OwnMain.tests.cpp new file mode 100644 index 00000000..e544bf4d --- /dev/null +++ b/tests/Progmasoft/BazelModule/OwnMain.tests.cpp @@ -0,0 +1,18 @@ +// Copyright (c) 2026 Progmasoft. +// SPDX-License-Identifier: LGPL-3.0-or-later + +// Tests linked with @progmasoft_catch3//:catch3, with a main of their own. +#include <Progmasoft/Catch3/Session.hpp> +#include <Progmasoft/Catch3/TestMacros.hpp> + +TEST_CASE("A test runs under its own main", "[module]") +{ + REQUIRE(1 + 1 == 2); +} + +int +main(int argc, char **argv) +{ + Catch::Session session; + return session.run(argc, argv); +} diff --git a/tests/Progmasoft/BazelModule/WithMain.tests.cpp b/tests/Progmasoft/BazelModule/WithMain.tests.cpp new file mode 100644 index 00000000..b3843f9f --- /dev/null +++ b/tests/Progmasoft/BazelModule/WithMain.tests.cpp @@ -0,0 +1,13 @@ +// Copyright (c) 2026 Progmasoft. +// SPDX-License-Identifier: LGPL-3.0-or-later + +// Tests linked with @progmasoft_catch3//:catch3_main, which brings main. +#include <Progmasoft/Catch3/TestMacros.hpp> +#include <string> + +TEST_CASE("A test runs from the published module", "[module]") +{ + const std::string name = "progmasoft_catch3"; + REQUIRE(name.size() == 17); + CHECK(name.rfind("progmasoft_", 0) == 0); +} diff --git a/tests/Progmasoft/BazelModule/bazel-BazelModule b/tests/Progmasoft/BazelModule/bazel-BazelModule new file mode 120000 index 00000000..8b7ed736 --- /dev/null +++ b/tests/Progmasoft/BazelModule/bazel-BazelModule @@ -0,0 +1 @@ +/home/hasan/.cache/bazel/_bazel_hasan/b6ce1a3de09042ac9ccba46273ffbf3b/execroot/_main
\ No newline at end of file diff --git a/tests/Progmasoft/BazelModule/bazel-bin b/tests/Progmasoft/BazelModule/bazel-bin new file mode 120000 index 00000000..c9e95b4d --- /dev/null +++ b/tests/Progmasoft/BazelModule/bazel-bin @@ -0,0 +1 @@ +/home/hasan/.cache/bazel/_bazel_hasan/b6ce1a3de09042ac9ccba46273ffbf3b/execroot/_main/bazel-out/k8-fastbuild/bin
\ No newline at end of file diff --git a/tests/Progmasoft/BazelModule/bazel-out b/tests/Progmasoft/BazelModule/bazel-out new file mode 120000 index 00000000..c24863da --- /dev/null +++ b/tests/Progmasoft/BazelModule/bazel-out @@ -0,0 +1 @@ +/home/hasan/.cache/bazel/_bazel_hasan/b6ce1a3de09042ac9ccba46273ffbf3b/execroot/_main/bazel-out
\ No newline at end of file diff --git a/tests/Progmasoft/BazelModule/bazel-testlogs b/tests/Progmasoft/BazelModule/bazel-testlogs new file mode 120000 index 00000000..eb25c4bc --- /dev/null +++ b/tests/Progmasoft/BazelModule/bazel-testlogs @@ -0,0 +1 @@ +/home/hasan/.cache/bazel/_bazel_hasan/b6ce1a3de09042ac9ccba46273ffbf3b/execroot/_main/bazel-out/k8-fastbuild/testlogs
\ No newline at end of file diff --git a/tools/Versions.cpp b/tools/Versions.cpp index 217702cf..0d4c6682 100644 --- a/tools/Versions.cpp +++ b/tools/Versions.cpp @@ -89,7 +89,9 @@ namespace Progmasoft::Catch3::Tools { static constexpr std::array<VersionSite, 5> kSites{ { { "CMakeLists.txt", "\n VERSION ", "\n" }, - { "MODULE.bazel", "module(name = \"catch3\", version = \"", "\"" }, + { "MODULE.bazel", + "module(name = \"progmasoft_catch3\", version = \"", + "\"" }, { "meson.build", "\n version: '", "'" }, { "xmake.lua", "\nset_version(\"", "\"" }, { kVersionHeader, "kVersion = \"", "\"" }, |