From f6d93a8d035ef89a0f671554ab0a2e507b92fe0d Mon Sep 17 00:00:00 2001 From: Mikkel Wienberg Madsen Date: Wed, 17 Apr 2024 16:55:37 +0200 Subject: [PATCH] Setup CI --- .github/workflows/ci.yml | 26 ++++++++++++++++++++++++++ ccare/mexcare.cpp | 38 -------------------------------------- rust-toolchain | 3 +++ 3 files changed, 29 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 ccare/mexcare.cpp create mode 100644 rust-toolchain diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..60a063d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +name: "Test Suite" +on: + push: + pull_request: + +jobs: + test: + name: cargo test + runs-on: self-hosted + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + - run: cargo test + + # Check formatting with rustfmt + formatting: + name: cargo fmt + runs-on: self-hosted + steps: + - uses: actions/checkout@v4 + # Ensure rustfmt is installed and setup problem matcher + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt + - name: Rustfmt Check + uses: actions-rust-lang/rustfmt@v1 diff --git a/ccare/mexcare.cpp b/ccare/mexcare.cpp deleted file mode 100644 index 034bb34..0000000 --- a/ccare/mexcare.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "libcaring.h" -#include "mex.hpp" -#include "mexAdapter.hpp" -#include - -using namespace matlab::data; -using matlab::mex::ArgumentList; - - -class MexFunction : public matlab::mex::Function { -public: - void operator()(matlab::mex::ArgumentList outputs, matlab::mex::ArgumentList inputs) { - // Function implementation - checkArguments(outputs, inputs); - TypedArray data = std::move(inputs[0]); - auto n = data.getNumberOfElements(); - int err = care_sum_many(data.release(), n); - // TODO: Handle errors - outputs[0] = std::move(data); - } - - void checkArguments(ArgumentList outputs, ArgumentList inputs) { - std::shared_ptr matlabPtr = getEngine(); - ArrayFactory factory; - if (inputs[0].getType() != ArrayType::DOUBLE || - inputs[0].getType() == ArrayType::COMPLEX_DOUBLE) - { - matlabPtr->feval(u"error", 0, - std::vector({ factory.createScalar("Input must be double array") })); - } - - if (outputs.size() > 1) { - matlabPtr->feval(u"error", 0, - std::vector({ factory.createScalar("Only one output is returned") })); - } - } -}; - diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000..22989e3 --- /dev/null +++ b/rust-toolchain @@ -0,0 +1,3 @@ +# vim: ft=toml +[toolchain] +channel = "nightly-2024-04-17"