Skip to content

Commit

Permalink
RS-563: Migration to Conan v2 (#83)
Browse files Browse the repository at this point in the history
* start migration to conan2

* fix conan package

* Reformat

* change conan version to 2, fix CI

* fix conan version

* Fix cmake preset name

* Fix bash command

* Add install conan action

* Add action file

* Add shell name

* Change build-package action

* Fix unit test clone

* Add install

* Fix conan install

* Add REDUCT_CPP_USE_STD_CHRONO

* Set c++ standart to 20

* Add date

* Remove install step from main ci

* Add show preset

* Add build_tests option to action

* Fix build tests

* Fix run tests

* Check windows

* Add std::chrono option logic to conanfile

* Add requirements method

* Add cmake build action

* Install OpenSSL for windows

* Update changelog

* add jira ticket id

---------

Co-authored-by: Alexey Timin <atimin@gmail.com>
  • Loading branch information
victor1234 and atimin authored Jan 22, 2025
1 parent 6ce5e17 commit 17e76a9
Show file tree
Hide file tree
Showing 15 changed files with 409 additions and 170 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ IncludeCategories:
Priority: 3
SortPriority: 0

ColumnLimit: 120
ColumnLimit: 120
50 changes: 50 additions & 0 deletions .github/actions/build-package-cmake/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "build-package-cmake"
description: "Install package and build example"
inputs:
build_tests:
default: "false"
install:
default: "true"
description: "Install the package after build"
runs:
using: "composite"
steps:
- name: Detect OS and install OpenSSL
shell: bash
run: |
if [[ "${{ runner.os }}" == "Windows" ]]; then
choco install openssl -y
openssl version
fi
- name: Detect OS and set std::chrono flag
shell: bash
run: |
if [[ "${{ runner.os }}" == "Linux" ]]; then
echo "USE_CHRONO=OFF" >> $GITHUB_ENV
elif [[ "${{ runner.os }}" == "Windows" ]]; then
echo "USE_CHRONO=ON" >> $GITHUB_ENV
fi
- name: Cmake configuration without tests
if: ${{inputs.build_tests == 'false'}}
shell: bash
run: cmake -S . -B build -DREDUCT_CPP_USE_STD_CHRONO=$USE_CHRONO

- name: Cmake configuration with tests
if: ${{inputs.build_tests == 'true'}}
shell: bash
run: cmake -S . -B build -DREDUCT_CPP_ENABLE_TESTS=ON -DREDUCT_CPP_USE_STD_CHRONO=$USE_CHRONO

- name: Build package
shell: bash
run: |
if [[ "${{ runner.os }}" == "Linux" ]]; then
cmake --build build
elif [[ "${{ runner.os }}" == "Windows" ]]; then
cmake --build build --config Release
fi
- name: Install package
if: ${{inputs.install == 'true' }}
run: sudo cmake --install build
shell: bash
45 changes: 35 additions & 10 deletions .github/actions/build-package/action.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,49 @@
name: "build-package"
description: "Install package and build example"
inputs:
build_tests:
default: "false"
install:
default: "true"
description: "Install the package after build"
runs:
using: "composite"
steps:
- uses: ./.github/actions/install-conan

- name: Run conan install
shell: bash
run: conan install . --build=missing -s:a=compiler.cppstd=20

- name: Detect OS and set preset name
shell: bash
run: |
if [[ "${{ runner.os }}" == "Linux" ]]; then
echo "PRESET=conan-release" >> $GITHUB_ENV
elif [[ "${{ runner.os }}" == "Windows" ]]; then
echo "PRESET=conan-default" >> $GITHUB_ENV
fi
- name: Cmake configuration without tests
if: ${{inputs.build_tests == 'false'}}
shell: bash
run: cmake --preset $PRESET

- name: Cmake configuration with tests
if: ${{inputs.build_tests == 'true'}}
shell: bash
run: cmake --preset $PRESET -DREDUCT_CPP_ENABLE_TESTS=ON

- name: Build package
shell: bash
run: cmake -DCMAKE_BUILD_TYPE=Debug -DREDUCT_CPP_ENABLE_EXAMPLES=ON -DREDUCT_CPP_ENABLE_TESTS=ON -S . -B build
run: |
if [[ "${{ runner.os }}" == "Linux" ]]; then
cmake --build --preset $PRESET
elif [[ "${{ runner.os }}" == "Windows" ]]; then
cmake --build build --config Release
fi
- name: Install package
if: ${{inputs.install == 'true' }}
run: sudo cmake --install build/Release
shell: bash
run: sudo cmake --build build --target install
- name: Build example
if: ${{inputs.install == 'true' }}
shell: bash
run: |
mkdir examples/build
cd examples/build
cmake ..
cmake --build .
12 changes: 12 additions & 0 deletions .github/actions/install-conan/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "install-conan"

runs:
using: "composite"
steps:
- name: Install conan
shell: bash
run: pip3 install conan==2.11.0

- name: Create profile
shell: bash
run: conan profile detect
10 changes: 5 additions & 5 deletions .github/actions/run-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ name: "run-tests"
description: "Pull storage and run tests"
inputs:
api-token: # id of input
description: 'API_TOKEN'
description: "API_TOKEN"
required: false
default: ""
tags: # id of input
description: 'Tags for tests'
description: "Tags for tests"
required: false
default: ""
reductstore-version: # id of input
description: 'Reduct Store version'
description: "Reduct Store version"
required: false
default: "main"
lic_file: # id of input
description: 'License file'
description: "License file"
required: true
runs:
using: "composite"
Expand All @@ -33,4 +33,4 @@ runs:
docker logs reduct-store
- name: Run tests
shell: bash
run: REDUCT_CPP_TOKEN_API=${{inputs.api-token}} build/bin/reduct-tests ${{inputs.tags}}
run: REDUCT_CPP_TOKEN_API=${{inputs.api-token}} build/Release/bin/reduct-tests ${{inputs.tags}}
34 changes: 23 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: ci
on:
push:
branches: [ main ]
branches: [main]
tags:
- 'v*'
- "v*"
pull_request:
branches: [ main ]
branches: [main]
jobs:
cpplint:
runs-on: ubuntu-latest
Expand All @@ -26,28 +26,35 @@ jobs:
needs: cpplint
strategy:
matrix:
build_type: [ "cmake", "conan" ]
os: [ ubuntu-22.04, windows-2019 ]
build_type: ["cmake", "conan"]
os: [ubuntu-22.04, windows-2019]
include:
- os: ubuntu-22.04
install: "true"
- os: windows-2019
install: "false"
steps:
- uses: actions/checkout@v4
- name: Install conan
with:
fetch-depth: 0
- name: Build without conan
if: ${{ matrix.build_type == 'cmake' }}
uses: ./.github/actions/build-package-cmake
with:
install: ${{ matrix.install }}

- name: Build with conan
if: ${{ matrix.build_type == 'conan' }}
run: pip3 install conan==1.64.1
- uses: ./.github/actions/build-package
uses: ./.github/actions/build-package
with:
install: ${{ matrix.install }}

unit-tests:
strategy:
matrix:
token: [ "", "TOKEN" ]
reductstore_version: [ "main", "latest" ]
license_file: [ "", "lic.key" ]
token: ["", "TOKEN"]
reductstore_version: ["main", "latest"]
license_file: ["", "lic.key"]
include:
- token: ""
exclude_token_api_tag: "~[token_api]"
Expand All @@ -65,7 +72,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/build-package
with:
build_tests: true

- name: Generate license
run: echo '${{secrets.LICENSE_KEY}}' > lic.key
Expand Down
39 changes: 27 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files

- repo: https://github.com/BlankSpruce/gersemi
rev: 0.17.1
hooks:
- id: gersemi

- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]

- repo: local
- repo: local
hooks:
- id: cpplint
name: cpplint
description: Static code analysis of C/C++ files
language: python
files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$
entry: cpplint
- id: cpplint
name: cpplint
description: Static code analysis of C/C++ files
language: python
files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$
entry: cpplint
30 changes: 5 additions & 25 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- RS-550: Add when condition to replication settings, [PR-80](https://github.com/reductstore/reduct-cpp/pull/80)

### Changed

- RS-563: Support for Conan v2, [PR-83](https://github.com/reductstore/reduct-cpp/pull/83)

## [1.13.0] - 2024-12-04

### Added
Expand Down Expand Up @@ -150,7 +154,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Removed

- `Bucket.list`, [PR-42](https://github.com/reduct-storage/reduct-cpp/pull/42)
- `Bucket.list`, [PR-42](https://github.com/reduct-storage/reduct-cpp/pull/42)

### Changed

Expand Down Expand Up @@ -231,51 +235,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Initial implementation of Reduct Storage API v0.1.0

[Unreleased]: https://github.com/reduct-storage/reduct-cpp/compare/v1.13.0...HEAD

[1.13.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.12.0...1.13.0

[1.12.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.11.0...1.12.0

[1.11.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.10.0...1.11.0

[1.10.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.9.0...1.10.0

[1.9.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.8.0...1.9.0

[1.8.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.7.1...1.8.0

[1.7.1]: https://github.com/reduct-storage/reduct-cpp/compare/v1.7.0...1.7.1

[1.7.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.6.0...1.7.0

[1.6.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.5.0...1.6.0

[1.5.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.4.0...1.5.0

[1.4.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.3.0...1.4.0

[1.3.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.2.0...1.3.0

[1.2.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.1.0...1.2.0

[1.1.0]: https://github.com/reduct-storage/reduct-cpp/compare/v1.0.1...1.1.0

[1.0.1]: https://github.com/reduct-storage/reduct-cpp/compare/v1.0.0...1.0.1

[1.0.0]: https://github.com/reduct-storage/reduct-cpp/compare/v0.8.0...1.0.0

[0.8.0]: https://github.com/reduct-storage/reduct-cpp/compare/v0.7.0...v0.8.0

[0.7.0]: https://github.com/reduct-storage/reduct-cpp/compare/v0.6.0...v0.7.0

[0.6.0]: https://github.com/reduct-storage/reduct-cpp/compare/v0.5.0...v0.6.0

[0.5.0]: https://github.com/reduct-storage/reduct-cpp/compare/v0.4.0...v0.5.0

[0.4.0]: https://github.com/reduct-storage/reduct-cpp/compare/v0.3.0...v0.4.0

[0.3.0]: https://github.com/reduct-storage/reduct-cpp/compare/v0.2.0...v0.3.0

[0.2.0]: https://github.com/reduct-storage/reduct-cpp/compare/v0.1.0...v0.2.0

[0.1.0]: https://github.com/reduct-storage/reduct-cpp/releases/tag/v0.1.0
22 changes: 17 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,30 @@ project(reductcpp VERSION ${REDUCT_CPP_FULL_VERSION})
message(STATUS "Version ${REDUCT_CPP_FULL_VERSION}")

set(REDUCT_CPP_ENABLE_TESTS OFF CACHE BOOL "Compile tests")
set(REDUCT_CPP_USE_STD_CHRONO OFF CACHE BOOL "use std::chrono instead of date library")
set(REDUCT_CPP_USE_STD_CHRONO
OFF
CACHE BOOL
"use std::chrono instead of date library"
)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

include(cmake/InstallDependencies.cmake)

configure_file(cmake/ReductCppConfig.cmake.in ${CMAKE_BINARY_DIR}/cmake/ReductCppConfig.cmake @ONLY)
configure_file(cmake/ReductCppConfigVersion.cmake.in ${CMAKE_BINARY_DIR}/cmake/ReductCppConfigVersion.cmake @ONLY)
configure_file(
cmake/ReductCppConfig.cmake.in
${CMAKE_BINARY_DIR}/cmake/ReductCppConfig.cmake
@ONLY
)
configure_file(
cmake/ReductCppConfigVersion.cmake.in
${CMAKE_BINARY_DIR}/cmake/ReductCppConfigVersion.cmake
@ONLY
)

add_subdirectory(src)
if (REDUCT_CPP_ENABLE_TESTS)
if(REDUCT_CPP_ENABLE_TESTS)
add_subdirectory(tests)
endif ()
endif()
2 changes: 1 addition & 1 deletion CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
filter=-build/c++11,-build/header_guard,-build/include
linelength=120
linelength=120
Loading

0 comments on commit 17e76a9

Please sign in to comment.