diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 1e000c2..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,33 +0,0 @@ -version: 2 -jobs: - test_debug: - docker: - - image: tschijnmo/drudge:corebase - steps: - - run: | - git clone --recurse-submodules https://github.com/tschijnmo/fbitset.git - mkdir cmake-test-debug - cd cmake-test-debug - cmake -DCMAKE_BUILD_TYPE=debug ../fbitset - make - ./test/testmain - - test_release: - docker: - - image: tschijnmo/drudge:corebase - steps: - - run: | - git clone --recurse-submodules https://github.com/tschijnmo/fbitset.git - mkdir cmake-test-release - cd cmake-test-release - cmake -DCMAKE_BUILD_TYPE=release ../fbitset - make - ./test/testmain - -workflows: - version: 2 - tests: - jobs: - - test_debug - - test_release - diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..a17d287 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + labels: + - "dependencies" + - "github-actions" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a4fa6c6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +name: CI + +on: + push: + branches: + - master + - 'release/*' + pull_request: + branches: + - master + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + permissions: + contents: read + strategy: + matrix: + build_type: [Debug, Release] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y cmake g++ make + + - name: Configure CMake + run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + + - name: Build + run: cmake --build build + + - name: Run tests + run: ./build/test/testmain diff --git a/.gitignore b/.gitignore index c4e088d..7d68fb2 100644 --- a/.gitignore +++ b/.gitignore @@ -32,5 +32,9 @@ *.app /cmake-build-*/ +/build-*/ +/build/ +/_codeql_build_dir/ +/_codeql_detected_source_root /.idea/ /test/catch.hpp diff --git a/.ycm_extra_conf.py b/.ycm_extra_conf.py deleted file mode 100644 index a589206..0000000 --- a/.ycm_extra_conf.py +++ /dev/null @@ -1,7 +0,0 @@ -import os.path -def FlagsForFile(filename, **kwargs): - proj_dir = os.path.dirname(os.path.realpath(__file__)) - - proj_include = os.path.join(proj_dir, 'include'); - flags = ['-std=gnu++1z', '-I/usr/local/include', '-I' + proj_include, '-I.'] - return {'flags': flags} diff --git a/README.md b/README.md index c559702..c889a7a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://circleci.com/gh/tschijnmo/fbitset.svg?style=shield)](https://circleci.com/gh/tschijnmo/fbitset) +[![CI](https://github.com/DrudgeCAS/fbitset/workflows/CI/badge.svg)](https://github.com/DrudgeCAS/fbitset/actions) # fbitset A highly optimized and tunable C++ bitset library diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 50d1e89..dfdf8c3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,9 +1,15 @@ -# Download the Catch2 single header. +# Fetch Catch2 v3 using FetchContent +# To update Catch2, change the GIT_TAG to the desired version +# Check releases at: https://github.com/catchorg/Catch2/releases +include(FetchContent) -file(DOWNLOAD - "https://github.com/catchorg/Catch2/releases/download/v2.0.1/catch.hpp" - "${CMAKE_CURRENT_BINARY_DIR}/catch.hpp" - ) +FetchContent_Declare( + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG v3.11.0 # renovate: datasource=github-releases depName=catchorg/Catch2 +) + +FetchContent_MakeAvailable(Catch2) # The main test driver. @@ -12,9 +18,7 @@ add_executable(testmain basic.cpp ) -target_include_directories(testmain - PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - ) +target_link_libraries(testmain PRIVATE Catch2::Catch2) # Tests supposed to crash with assertion failure. add_executable(crash_no_ext crash_no_ext.cpp) diff --git a/test/basic.cpp b/test/basic.cpp index 30a7345..2ccb5f9 100644 --- a/test/basic.cpp +++ b/test/basic.cpp @@ -18,11 +18,20 @@ #include #include #include - -#include +#include #include +// Provide stream operator for Fbitset to prevent Catch2 from trying to treat it as a range +namespace fbitset { + template + std::ostream& operator<<(std::ostream& os, const Fbitset& bs) { + return os << "{Fbitset}"; + } +} + +#include + using namespace fbitset; TEST_CASE("Fbitset has basic behaviour") diff --git a/test/testmain.cpp b/test/testmain.cpp index f442470..89487e3 100644 --- a/test/testmain.cpp +++ b/test/testmain.cpp @@ -1,5 +1,4 @@ -#define CATCH_CONFIG_RUNNER -#include +#include int main(int argc, char* argv[]) {