Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
395 changes: 380 additions & 15 deletions .github/workflows/release.yml

Large diffs are not rendered by default.

19 changes: 11 additions & 8 deletions bindings/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()

# Single-source the version from the workspace Cargo manifest unless the caller
# pins it through the OPENPIT_RUNTIME_VERSION cache variable.
# Single-source the package version from the workspace Cargo manifest unless the
# caller pins it explicitly. Runtime release tags may include a prerelease suffix
# that CMake's project(VERSION) grammar does not accept.
set(OPENPIT_CARGO_MANIFEST "${CMAKE_CURRENT_SOURCE_DIR}/../../crates/openpit/Cargo.toml")
if(DEFINED OPENPIT_RUNTIME_VERSION AND NOT OPENPIT_RUNTIME_VERSION STREQUAL "")
set(OPENPIT_VERSION "${OPENPIT_RUNTIME_VERSION}")
if(DEFINED OPENPIT_PACKAGE_VERSION AND NOT OPENPIT_PACKAGE_VERSION STREQUAL "")
set(OPENPIT_VERSION "${OPENPIT_PACKAGE_VERSION}")
elseif(EXISTS "${OPENPIT_CARGO_MANIFEST}")
file(READ "${OPENPIT_CARGO_MANIFEST}" _openpit_cargo_toml)
string(REGEX MATCH "(^|\n)version[ \t]*=[ \t]*\"([0-9][^\"]*)\""
Expand All @@ -35,7 +36,7 @@ elseif(EXISTS "${OPENPIT_CARGO_MANIFEST}")
endif()
if(NOT OPENPIT_VERSION)
message(FATAL_ERROR
"OpenPit: could not determine version; set OPENPIT_RUNTIME_VERSION")
"OpenPit: could not determine version; set OPENPIT_PACKAGE_VERSION")
endif()

project(OpenPit
Expand All @@ -48,9 +49,11 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# GitHub repository hosting the prebuilt runtime release assets.
set(OPENPIT_RUNTIME_REPO "openpitkit/pit"
CACHE STRING "GitHub owner/repo hosting OpenPit runtime releases")
# Make the version visible to the runtime resolver and the installed config.
set(OPENPIT_RUNTIME_VERSION "${OPENPIT_VERSION}"
CACHE STRING "OpenPit prebuilt runtime version")
# Make the release tag visible to the runtime resolver and the installed config.
if(NOT DEFINED OPENPIT_RUNTIME_VERSION OR OPENPIT_RUNTIME_VERSION STREQUAL "")
set(OPENPIT_RUNTIME_VERSION "${OPENPIT_VERSION}"
CACHE STRING "OpenPit prebuilt runtime version")
endif()

# Detect standalone vs add_subdirectory/FetchContent embedding. Both lead to the
# same OpenPit::openpit alias.
Expand Down
52 changes: 50 additions & 2 deletions bindings/cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ phase.

## Getting Started

Use the package generated by `cmake --install` and consume it from another
CMake project:
### [CMake](https://cmake.org/) `find_package`

Use the package generated by `cmake --install` from another CMake project:

<!-- Test mirror: e2e/clients/cpp/CMakeLists.txt -->
```cmake
find_package(OpenPit CONFIG REQUIRED)
target_link_libraries(your_target PRIVATE OpenPit::openpit)
Expand All @@ -50,6 +52,52 @@ Include `<openpit/openpit.hpp>` for the complete SDK surface, or include
`<openpit/fwd.hpp>` in precompiled headers when only forward declarations are
needed.

### [vcpkg](https://vcpkg.io/)

When the port version has merged into the public
[`microsoft/vcpkg`](https://github.com/microsoft/vcpkg) registry, add OpenPit
to the project manifest and pin the public registry baseline:

<!-- Test mirror: e2e/scripts/cpp-vcpkg.sh -->
```json
{
"name": "your-project",
"version-string": "0",
"builtin-baseline": "<vcpkg-registry-baseline>",
"dependencies": ["openpit"]
}
```

The managed
[`openpitkit/vcpkg-registry`](https://github.com/openpitkit/vcpkg-registry)
receives each OpenPit release first. Before the public port is merged, or when
pinning a specific OpenPit release, add `vcpkg-configuration.json` beside the
manifest. The manifest baseline pins the public vcpkg registry; the managed
registry baseline comes from the OpenPit release notes.

<!-- Test mirror: e2e/scripts/cpp-vcpkg.sh -->
```json
{
"registries": [
{
"kind": "git",
"repository": "https://github.com/openpitkit/vcpkg-registry.git",
"baseline": "<openpit-registry-baseline>",
"packages": ["openpit"]
}
]
}
```

<!-- Test mirror: e2e/clients/cpp/CMakeLists.txt -->
```cmake
find_package(OpenPit CONFIG REQUIRED)
target_link_libraries(your_target PRIVATE OpenPit::openpit)
```

Configure your project with the vcpkg toolchain file. The normal OpenPit runtime
resolver then downloads and verifies the matching released runtime asset.

## Examples

Runnable end-to-end examples live in [`examples/cpp/`](https://github.com/openpitkit/pit/tree/main/examples/cpp):
Expand Down
2 changes: 1 addition & 1 deletion bindings/cpp/cmake/OpenPitConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

include(CMakeFindDependencyMacro)

set(OPENPIT_RUNTIME_VERSION "@OPENPIT_VERSION@"
set(OPENPIT_RUNTIME_VERSION "@OPENPIT_RUNTIME_VERSION@"
CACHE STRING "OpenPit prebuilt runtime version")
set(OPENPIT_RUNTIME_REPO "@OPENPIT_RUNTIME_REPO@"
CACHE STRING "GitHub owner/repo hosting OpenPit runtime releases")
Expand Down
14 changes: 7 additions & 7 deletions bindings/js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ just test-release-e2e 0.4.0

The suite builds and checks these scenarios, then prints a pass/fail summary:
`rust-amd64`, `rust-arm64`, `python-wheel-amd64`, `python-wheel-arm64`,
`python-source-arm64`, `go-amd64`, `cpp-amd64`, `js-amd64`.
`python-source-arm64`, `go-amd64`, `cpp-amd64`, `cpp-vcpkg-amd64`,
`js-amd64`.

## How to run the tests

Expand Down
1 change: 1 addition & 0 deletions e2e/clients/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Source: bindings/cpp/README.md - Getting Started
find_package(OpenPit CONFIG REQUIRED)

add_executable(openpit_cpp_consumer main.cpp)
Expand Down
1 change: 1 addition & 0 deletions e2e/env/docker/cpp-distributable/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ RUN apt-get update \
g++ \
git \
make \
python3 \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /opt/e2e
Expand Down
43 changes: 43 additions & 0 deletions e2e/env/docker/cpp-vcpkg/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright The Pit Project Owners. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# 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
#
# http://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.
#
# Please see https://openpit.dev and the OWNERS file for details.

FROM debian:bookworm

RUN apt-get update \
&& apt-get install --yes --no-install-recommends \
ca-certificates \
cmake \
curl \
g++ \
git \
make \
python3 \
tar \
unzip \
zip \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /opt/e2e

COPY e2e/scripts/cpp-vcpkg.sh /usr/local/bin/run-release-e2e
COPY e2e/clients/cpp /opt/e2e/cpp-consumer
COPY examples/cpp /opt/e2e/examples
COPY examples/tables /opt/e2e/tables

RUN chmod +x /usr/local/bin/run-release-e2e

ENTRYPOINT ["/usr/local/bin/run-release-e2e"]
68 changes: 68 additions & 0 deletions e2e/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,40 @@ if [[ -z "${VERSION}" ]]; then
exit 1
fi

known_targets=(
rust-amd64
rust-arm64
python-wheel-amd64
python-wheel-arm64
python-source-arm64
go-amd64
cpp-amd64
cpp-vcpkg-amd64
js-amd64
)
requested_targets=()
if [[ -n "${OPENPIT_RELEASE_E2E_TARGETS:-}" ]]; then
read -r -a requested_targets <<< "${OPENPIT_RELEASE_E2E_TARGETS}"
if [[ ${#requested_targets[@]} -eq 0 ]]; then
echo "OPENPIT_RELEASE_E2E_TARGETS did not select any targets" >&2
exit 1
fi
for requested_target in "${requested_targets[@]}"; do
known=false
for target in "${known_targets[@]}"; do
if [[ "${requested_target}" == "${target}" ]]; then
known=true
break
fi
done
if [[ "${known}" != true ]]; then
echo "unknown release e2e target: ${requested_target}" >&2
printf 'known targets: %s\n' "${known_targets[*]}" >&2
exit 1
fi
done
fi

run_case() {
local name="$1"
local dockerfile="$2"
Expand All @@ -40,6 +74,24 @@ run_case() {
run_args+=(--platform "${platform}")
fi

for env_name in \
OPENPIT_RELEASE_DOWNLOAD_TOKEN \
OPENPIT_RELEASE_REPOSITORY \
OPENPIT_VCPKG_REGISTRY_BASELINE \
OPENPIT_VCPKG_REGISTRY_REPOSITORY; do
if [[ -n "${!env_name:-}" ]]; then
run_args+=(--env "${env_name}")
fi
done

if [[ "${name}" == cpp-vcpkg-* \
&& -n "${OPENPIT_VCPKG_REGISTRY_PATH:-}" ]]; then
run_args+=(
--env OPENPIT_VCPKG_REGISTRY_PATH=/opt/e2e/vcpkg-registry
--volume "${OPENPIT_VCPKG_REGISTRY_PATH}:/opt/e2e/vcpkg-registry:ro"
)
fi

echo
echo "==> Building ${name} image"
docker build --pull \
Expand Down Expand Up @@ -72,6 +124,21 @@ run_or_record() {
local dockerfile="$2"
local platform="${3:-}"

if [[ ${#requested_targets[@]} -ne 0 ]]; then
local selected=false
local target
for target in "${requested_targets[@]}"; do
if [[ "${target}" == "${name}" ]]; then
selected=true
break
fi
done
if [[ "${selected}" != true ]]; then
printf '==> %s checks skipped\n' "${name}"
return
fi
fi

if run_case "${name}" "${dockerfile}" "${platform}"; then
passes=$((passes + 1))
passed_cases+=("${name}")
Expand All @@ -92,6 +159,7 @@ run_or_record "python-wheel-arm64" "${ROOT_DIR}/e2e/env/docker/python-wheel/Dock
run_or_record "python-source-arm64" "${ROOT_DIR}/e2e/env/docker/python-sdist/Dockerfile" "linux/arm64"
run_or_record "go-amd64" "${ROOT_DIR}/e2e/env/docker/go-module/Dockerfile" "linux/amd64"
run_or_record "cpp-amd64" "${ROOT_DIR}/e2e/env/docker/cpp-distributable/Dockerfile" "linux/amd64"
run_or_record "cpp-vcpkg-amd64" "${ROOT_DIR}/e2e/env/docker/cpp-vcpkg/Dockerfile" "linux/amd64"
run_or_record "js-amd64" "${ROOT_DIR}/e2e/env/docker/js-package/Dockerfile" "linux/amd64"

if [[ "${failures}" -ne 0 ]]; then
Expand Down
Loading
Loading