diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 7a1e4dc..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: CMake Build and Test - -on: - push: - branches: - - master - - develop - - githubactions* - - feature/** - - fix/** - - pr/** -jobs: - build-test: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ ubuntu-latest, windows-latest, macos-latest ] - - steps: - - uses: actions/checkout@v2 - - - name: Setup CMake - uses: actions/setup-cmake@v3 - with: - cmake-version: '3.18.2' - - - name: Configure CMake - run: cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=cmake/conan_provider.cmake - - - name: Build - run: cmake --build build - - - name: Test - run: ctest --build build --target test diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..4903098 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,60 @@ +name: Linux builds + +on: + push: + branches: + - master + - develop + - githubactions* + - feature/** + - fix/** + - pr/** +jobs: + build-test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest] + compiler: [g++-12, g++-13] + + env: + CONAN_USER_HOME: "${{ github.workspace }}/release/" + CONAN_USER_HOME_SHORT: "${{ github.workspace }}/release/short" + + steps: + - uses: actions/checkout@v2 + + - name: ccache + uses: hendrikmuhs/ccache-action@v1.1 + with: + key: ${{ matrix.os }}-${{ matrix.compiler }} + + - name: ccache + uses: hendrikmuhs/ccache-action@v1.1 + with: + key: ${{ matrix.os }}-${{ matrix.compiler }} + + - name: Using the builtin GitHub Cache Action for .conan + id: cache-conan + uses: actions/cache@v1 + env: + cache-name: cache-conan-modules + with: + path: ${{ env.CONAN_USER_HOME }} + key: ${{ runner.os }}-builder-${{ env.cache-name }}-${{ hashFiles('conanfile.txt') }} + restore-keys: ${{ runner.os }}-builder-${{ env.cache-name }} + + - name: Conan installation + id: conan + uses: turtlebrowser/get-conan@v1.0 + + - name: Configure, Build, and Test Project + uses: threeal/cmake-action@v1.3.0 + with: + run-build: true + run-test: true + options: CMAKE_PROJECT_TOP_LEVEL_INCLUDES=cmake/conan_provider.cmake CMAKE_BUILD_TYPE=Release CMAKE_CXX_COMPILER_LAUNCHER=ccache + + env: + CXX: ${{ matrix.compiler }} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 0000000..d55a2b4 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,56 @@ +name: MacOs builds + +on: + push: + branches: + - master + - develop + - githubactions* + - feature/** + - fix/** + - pr/** +jobs: + build-test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [macos-13] + compiler: ['15.0.1', '14.3.1', '14.2'] + + env: + CONAN_USER_HOME: "${{ github.workspace }}/release/" + CONAN_USER_HOME_SHORT: "${{ github.workspace }}/release/short" + + steps: + - uses: actions/checkout@v2 + + - name: ccache + uses: hendrikmuhs/ccache-action@v1.1 + with: + key: ${{ matrix.os }}-${{ matrix.compiler }} + + - name: Using the builtin GitHub Cache Action for .conan + id: cache-conan + uses: actions/cache@v1 + env: + cache-name: cache-conan-modules + with: + path: ${{ env.CONAN_USER_HOME }} + key: ${{ runner.os }}-builder-${{ env.cache-name }}-${{ hashFiles('conanfile.txt') }} + restore-keys: ${{ runner.os }}-builder-${{ env.cache-name }} + + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{ matrix.compiler }} + + - name: Conan installation + id: conan + uses: turtlebrowser/get-conan@v1.0 + + - name: Configure, Build, and Test Project + uses: threeal/cmake-action@v1.3.0 + with: + run-build: true + run-test: true + options: CMAKE_PROJECT_TOP_LEVEL_INCLUDES=cmake/conan_provider.cmake CMAKE_BUILD_TYPE=Release CMAKE_CXX_COMPILER_LAUNCHER=ccache diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2899e97..1908fda 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,3 +15,9 @@ repos: hooks: - id: clang-format types_or: [c++, c, cuda] + +- repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.27.2 + hooks: + - id: check-github-workflows + args: ["--verbose"] diff --git a/CMakeLists.txt b/CMakeLists.txt index 16e372b..3754e21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,8 @@ add_custom_target(nova_symbol_project_files SOURCES conanfile.txt Readme.md License.txt - .github/workflows/ci.yml + .github/workflows/linux.yml + .github/workflows/macos.yml ) set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS conanfile.txt) @@ -44,6 +45,8 @@ target_link_libraries(nova_symbol option(NOVA_SYMBOL_BUILD_TEST "Build unit tests" ON) if (NOVA_SYMBOL_BUILD_TEST) + enable_testing() + add_executable(nova_symbol_test test/symbol_test.cpp) add_test(NAME nova_symbol_test COMMAND nova_symbol_test) diff --git a/conanfile.txt b/conanfile.txt index c8eca91..ae65aa8 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -2,8 +2,14 @@ boost/1.83.0 catch2/3.4.0 cityhash/cci.20130801 + [generators] CMakeDeps CMakeToolchain + [layout] cmake_layout + +[options] +boost*:header_only=True +catch2*:shared=False diff --git a/inc/nova/symbol/symbol.hpp b/inc/nova/symbol/symbol.hpp index dbb4609..5e552af 100644 --- a/inc/nova/symbol/symbol.hpp +++ b/inc/nova/symbol/symbol.hpp @@ -24,8 +24,11 @@ #include +#include -#include +#ifdef __cpp_lib_format +# include +#endif #include @@ -138,6 +141,8 @@ inline symbol operator""_sym( const char* literal, size_t size ) } // namespace nova +#ifdef __cpp_lib_format + template <> struct std::formatter< nova::symbol, char > : std::formatter< std::string_view > { @@ -148,6 +153,8 @@ struct std::formatter< nova::symbol, char > : std::formatter< std::string_view > } }; +#endif + #if __has_include( ) # include diff --git a/test/symbol_test.cpp b/test/symbol_test.cpp index 1b45f30..6f38e4d 100644 --- a/test/symbol_test.cpp +++ b/test/symbol_test.cpp @@ -23,8 +23,13 @@ TEST_CASE( "symbol" ) CHECK( b != a_4 ); } + +#ifdef __cpp_lib_format + TEST_CASE( "format" ) { nova::symbol a( "a" ); CHECK( std::format( "{}", a ) == "a" ); } + +#endif