diff --git a/.github/workflows/cpp_test.yml b/.github/workflows/cpp_test.yml new file mode 100644 index 0000000..1375a5d --- /dev/null +++ b/.github/workflows/cpp_test.yml @@ -0,0 +1,59 @@ +name: C++ tests + +on: + push: + paths: + - include/** + - src_core/** + - tests/** + - CMakeLists.txt + - .github/workflows/cpp_test.yml + pull_request: + paths: + - include/** + - src_core/** + - tests/** + - CMakeLists.txt + - .github/workflows/cpp_test.yml + +jobs: + test-fast: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: 'release' + + - name: Configure + run: cmake -B build -DCMAKE_BUILD_TYPE=Release + + - name: Build + run: cmake --build build --target test_core --parallel + + - name: Test + run: ctest --test-dir build --output-on-failure + + test-full: + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: 'release' + + - name: Configure + run: cmake -B build -DCMAKE_BUILD_TYPE=Release + + - name: Build + run: cmake --build build --target test_core --parallel + + - name: Test + run: ctest --test-dir build --output-on-failure diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index c3c3cba..c8f150b 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -3,25 +3,46 @@ name: Python package on: push: paths: - - "py_package/**" - - ".github/workflows/python.yml" + - py_package/** + - .github/workflows/python.yml pull_request: paths: - - "py_package/**" - - ".github/workflows/python.yml" + - py_package/** + - .github/workflows/python.yml jobs: - test: + test-fast: runs-on: ubuntu-latest strategy: matrix: python-version: ["3.11", "3.12"] + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install package + run: | + python -m pip install --upgrade pip + python -m pip install ./py_package[dev] + + - name: Run tests + run: pytest py_package/tests + test-full: + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.11", "3.12"] steps: - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} diff --git a/.github/workflows/r_check.yml b/.github/workflows/r_check.yml new file mode 100644 index 0000000..be5f832 --- /dev/null +++ b/.github/workflows/r_check.yml @@ -0,0 +1,68 @@ +name: R package check + +on: + push: + paths: + - R/** + - src/** + - man/** + - inst/** + - DESCRIPTION + - NAMESPACE + - Makefile + - .github/workflows/r_check.yml + pull_request: + paths: + - R/** + - src/** + - man/** + - inst/** + - DESCRIPTION + - NAMESPACE + - .github/workflows/r_check.yml + +jobs: + test-fast: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: "release" + + - name: Sync headers + run: make r-sync-headers + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck, any::tinytest + + - uses: r-lib/actions/check-r-package@v2 + with: + error-on: '"error"' + + test-full: + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: "release" + + - name: Sync headers + run: make r-sync-headers + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck, any::tinytest + + - uses: r-lib/actions/check-r-package@v2 + with: + error-on: '"error"' diff --git a/Makefile b/Makefile index f4633be..b2b160c 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ r-doc: Rscript -e "devtools::document()" r-sync-headers: + mkdir -p inst/include cp include/*.hpp inst/include/ r-build: r-sync-headers r-doc diff --git a/src_core/MultisetMedian.cpp b/src_core/MultisetMedian.cpp index 2e65667..7e1b121 100644 --- a/src_core/MultisetMedian.cpp +++ b/src_core/MultisetMedian.cpp @@ -1,6 +1,7 @@ #include "MultisetMedian.hpp" #include #include +#include MultisetMedian::MultisetMedian(std::size_t size) : window_size_(size) { if (size <= 0) { diff --git a/src_core/SlidingWelford.cpp b/src_core/SlidingWelford.cpp index 2928cd7..c6327d7 100644 --- a/src_core/SlidingWelford.cpp +++ b/src_core/SlidingWelford.cpp @@ -1,4 +1,5 @@ #include "SlidingWelford.hpp" +#include SlidingWelford::SlidingWelford(std::size_t window_size) : window_size_(window_size), mean_(0.0), M2_(0.0) { diff --git a/src_core/SlidingWelfordRing.cpp b/src_core/SlidingWelfordRing.cpp index 3a1dc19..3efc5d6 100644 --- a/src_core/SlidingWelfordRing.cpp +++ b/src_core/SlidingWelfordRing.cpp @@ -1,4 +1,5 @@ #include "SlidingWelfordRing.hpp" +#include SlidingWelfordRing::SlidingWelfordRing(std::size_t window_size) : window_size_(window_size), mean_(0.0), M2_(0.0) {