From 421294cfbf447e7d3f78186fef8d2980b884e9d1 Mon Sep 17 00:00:00 2001 From: Erik De Smedt Date: Wed, 6 Mar 2024 12:18:04 +0100 Subject: [PATCH] CI: Create a github action which runs rust-tests (#1) This pipeline builds the packages and runs all rust-tests. These are mainly unit-tests. The `lsps-server` requires to have a dummy database for testing. This database is created in the pipeline before running the tests --- .github/workflows/test-rust.yml | 24 ++++++++++++++++++++++++ Cargo.toml | 2 -- Makefile | 3 +++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test-rust.yml diff --git a/.github/workflows/test-rust.yml b/.github/workflows/test-rust.yml new file mode 100644 index 0000000..8f4de26 --- /dev/null +++ b/.github/workflows/test-rust.yml @@ -0,0 +1,24 @@ +name: rust-unit-tests +run-name: $${ github.actor }} - Unit Tests +on: [push] +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - name: Create Sqlite database + uses: actions-rs/cargo@v1 + with: + command: install + args: sqlx-cli + - run: make db + - uses: actions-rs/cargo@v1 + with: + command: test + args: --workspace --all-features + diff --git a/Cargo.toml b/Cargo.toml index 6949970..57303e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,5 @@ members = [ ] [dependencies] -lsps-client = { path = "plugins/lsps-client/" } -lsps-server = { path = "plugins/lsps-server/" } lsp-primitives = {path = "libs/lsp-primitives"} cln-lsps = {path = "libs/cln-lsps" } diff --git a/Makefile b/Makefile index 044d2fe..2bdd9a8 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,9 @@ all: lsps-server lsps-client base: mkdir -p build/plugins +# Initiates a database that is used for testing +db: plugins/lsps-server/data/lsp_server.db + plugins/lsps-server/data/lsp_server.db: mkdir -p plugins/lsps-server/data sqlx database create --database-url sqlite:plugins/lsps-server/data/lsp_server.db