diff --git a/.github/workflows/neo4j.yml b/.github/workflows/neo4j.yml new file mode 100644 index 0000000..485a308 --- /dev/null +++ b/.github/workflows/neo4j.yml @@ -0,0 +1,37 @@ +name: ci +on: + push: + branches: + - main + paths: + - neo4j/** + - .github/workflows/neo4j.yml +jobs: + neo4j-test: + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: Setup Fluent CI + uses: fluentci-io/setup-fluentci@v5 + with: + wasm: true + plugin: rust + args: | + target_add wasm32-unknown-unknown + build --release --target wasm32-unknown-unknown + working-directory: neo4j + env: + GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Start neo4j + run: | + fluentci run target/wasm32-unknown-unknown/release/neo4j.wasm start + fluentci ps + fluentci status neo4j + fluentci run target/wasm32-unknown-unknown/release/neo4j.wasm stop + working-directory: neo4j + env: + GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NIX_CONFIG: extra-access-tokens = github.com=${{ secrets.GH_ACCESS_TOKEN }} diff --git a/Cargo.lock b/Cargo.lock index 6ad0ebd..327a0af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -507,6 +507,16 @@ dependencies = [ "fluentci-types", ] +[[package]] +name = "neo4j" +version = "0.1.0" +dependencies = [ + "anyhow", + "extism-pdk", + "fluentci-pdk", + "fluentci-types", +] + [[package]] name = "nginx" version = "0.1.1" diff --git a/Cargo.toml b/Cargo.toml index 2374443..6262944 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ default-members = [ "mongodb", "mysql", "nats", + "neo4j", "nginx", "nsq", "opentelemetry-collector", @@ -80,6 +81,7 @@ members = [ "mongodb", "mysql", "nats", + "neo4j", "nginx", "nsq", "opentelemetry-collector", diff --git a/README.md b/README.md index 14140cd..f399370 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ fluentci run --wasm postgres start | [mongodb](./mongodb) | A general purpose, document-based, distributed database | | [mysql](./mysql) | The world's most popular open source database | | [nats](./nats) | A simple, secure and high performance messaging system | +| [neo4j](./neo4j) | A graph database management system | | [nginx](./nginx) | HTTP and reverse proxy server | | [nsq](./nsq) | A realtime distributed messaging platform | | [opentelemetry-collector](./opentelemetry-collector) | OpenTelemetry Collector superset with additional collectors | diff --git a/neo4j/Cargo.toml b/neo4j/Cargo.toml new file mode 100644 index 0000000..1ae9ada --- /dev/null +++ b/neo4j/Cargo.toml @@ -0,0 +1,20 @@ +[package] +authors = [ + "Tsiry Sandratraina ", +] +description = "Neo4j plugin for FluentCI" +edition = "2021" +license = "MIT" +name = "neo4j" +version = "0.1.0" + +[lib] +crate-type = [ + "cdylib", +] + +[dependencies] +anyhow = "1.0.82" +extism-pdk = "1.1.0" +fluentci-pdk = "0.2.1" +fluentci-types = "0.1.7" diff --git a/neo4j/LICENSE b/neo4j/LICENSE new file mode 100644 index 0000000..515dd5f --- /dev/null +++ b/neo4j/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2024 Tsiry Sandratraina + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/neo4j/README.md b/neo4j/README.md new file mode 100644 index 0000000..05bfc87 --- /dev/null +++ b/neo4j/README.md @@ -0,0 +1,54 @@ +# Neo4j Plugin + +[![fluentci pipeline](https://shield.fluentci.io/x/neo4j)](https://pkg.fluentci.io/neo4j) +[![ci](https://github.com/fluentci-io/services/actions/workflows/neo4j.yml/badge.svg)](https://github.com/fluentci-io/services/actions/workflows/neo4j.yml) + +Neo4j service plugin for FluentCI. + +## 🚀 Usage + +Add the following command to your CI configuration file: + +```bash +fluentci run --wasm neo4j start +``` + +## Functions + +| Name | Description | +| ------ | ------------------------------ | +| start | Start neo4j | +| stop | Stop neo4j | + +## Code Usage + +Add `fluentci-pdk` crate to your `Cargo.toml`: + +```toml +[dependencies] +fluentci-pdk = "0.2.1" +``` + +Use the following code to call the plugin: + +```rust +use fluentci_pdk::dag; + +// ... + +dag().call("https://pkg.fluentci.io/neo4j@v0.1.0?wasm=1", "start", vec![])?; +``` + +## 📚 Examples + +Github Actions: + +```yaml +- name: Setup Fluent CI CLI + uses: fluentci-io/setup-fluentci@v5 + with: + wasm: true + plugin: neo4j + args: | + start +``` diff --git a/neo4j/fluentci.toml b/neo4j/fluentci.toml new file mode 100644 index 0000000..47d5906 --- /dev/null +++ b/neo4j/fluentci.toml @@ -0,0 +1,11 @@ +[package] +authors = [ + "Tsiry Sandratraina ", +] +description = "Neo4j Plugin for FluentCI" +keywords = [ + "neo4j", +] +license = "MIT" +name = "neo4j" +version = "0.1.0" diff --git a/neo4j/src/helpers.rs b/neo4j/src/helpers.rs new file mode 100644 index 0000000..99f0b53 --- /dev/null +++ b/neo4j/src/helpers.rs @@ -0,0 +1,26 @@ +use anyhow::Error; +use fluentci_pdk::dag; + +pub fn setup() -> Result { + dag() + .pipeline("setup")? + .with_exec(vec!["mkdir", "-p", ".fluentci/neo4j"])? + .stdout()?; + + let stdout = dag() + .devbox()? + .with_workdir(".fluentci/neo4j")? + .with_exec(vec![ + "devbox", + "add", + "neo4j", + "overmind", + "tmux", + ])? + .with_exec(vec![ + "grep -q neo4j: Procfile || echo -e 'neo4j: devbox run neo4j console $NEO4J_ARGS \\n' >> Procfile", + ])? + .stdout()?; + + Ok(stdout) +} diff --git a/neo4j/src/lib.rs b/neo4j/src/lib.rs new file mode 100644 index 0000000..fa89a93 --- /dev/null +++ b/neo4j/src/lib.rs @@ -0,0 +1,43 @@ +use extism_pdk::*; +use fluentci_pdk::dag; + +pub mod helpers; + +#[plugin_fn] +pub fn start(_args: String) -> FnResult { + helpers::setup()?; + + let stdout = dag() + .devbox()? + .with_workdir(".fluentci/neo4j")? + .with_exec(vec!["overmind", "--version"])? + .with_exec(vec!["type", "overmind"])? + .with_exec(vec!["type neo4j"])? + .with_exec(vec!["neo4j --version"])? + .with_exec(vec![ + "overmind start -f Procfile --daemonize || devbox run overmind restart neo4j", + ])? + .wait_on(7474, None)? + .wait_on(7687, None)? + .with_exec(vec!["overmind", "status"])? + .stdout()?; + Ok(stdout) +} + +#[plugin_fn] +pub fn stop(args: String) -> FnResult { + helpers::setup()?; + + let args = if args.is_empty() { + "neo4j".to_string() + } else { + args + }; + + let stdout = dag() + .devbox()? + .with_workdir(".fluentci/neo4j")? + .with_exec(vec!["overmind", "stop", &args])? + .stdout()?; + Ok(stdout) +} diff --git a/neo4j/target b/neo4j/target new file mode 120000 index 0000000..78bc337 --- /dev/null +++ b/neo4j/target @@ -0,0 +1 @@ +../target \ No newline at end of file