-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add arangodb service feat: add arangodb service feat: add arangodb service fix arangodb service fix arangodb service
- Loading branch information
Showing
12 changed files
with
372 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: ci | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- arangodb/** | ||
- .github/workflows/arangodb.yml | ||
jobs: | ||
arangodb-test: | ||
runs-on: ubuntu-latest | ||
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: arangodb | ||
env: | ||
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Start arangodb Server | ||
run: | | ||
fluentci run target/wasm32-unknown-unknown/release/arangodb.wasm start | ||
fluentci ps | ||
fluentci status arangodb | ||
fluentci run target/wasm32-unknown-unknown/release/arangodb.wasm stop | ||
working-directory: arangodb | ||
env: | ||
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NIX_CONFIG: extra-access-tokens = github.com=${{ secrets.GH_ACCESS_TOKEN }} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[package] | ||
authors = [ | ||
"Tsiry Sandratraina <[email protected]>", | ||
] | ||
description = "ArangoDB plugin for FluentCI" | ||
edition = "2021" | ||
license = "MIT" | ||
name = "arangodb" | ||
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2024 Tsiry Sandratraina <[email protected]> | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# ArangoDB Plugin | ||
|
||
[![fluentci pipeline](https://shield.fluentci.io/x/arangodb)](https://pkg.fluentci.io/arangodb) | ||
[![ci](https://github.com/fluentci-io/services/actions/workflows/arangodb.yml/badge.svg)](https://github.com/fluentci-io/services/actions/workflows/arangodb.yml) | ||
|
||
ArangoDB service plugin for FluentCI. | ||
|
||
## 🚀 Usage | ||
|
||
Add the following command to your CI configuration file: | ||
|
||
```bash | ||
fluentci run --wasm arangodb start | ||
``` | ||
|
||
## Functions | ||
|
||
| Name | Description | | ||
| ------ | -----------------------------------------| | ||
| start | Start arangodb server | | ||
| stop | Stop arangodb server | | ||
|
||
## 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/[email protected]?wasm=1", "start", vec![])?; | ||
``` | ||
|
||
## 📚 Examples | ||
|
||
Github Actions: | ||
|
||
```yaml | ||
- name: Setup Fluent CI CLI | ||
uses: fluentci-io/setup-fluentci@v5 | ||
with: | ||
wasm: true | ||
plugin: arangodb | ||
args: | | ||
start | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# ArangoDB configuration file | ||
# | ||
# Documentation: | ||
# https://www.arangodb.com/docs/stable/administration-configuration.html | ||
# | ||
|
||
[database] | ||
directory = $ARANGODB_DATADIR | ||
|
||
[server] | ||
# Specify the endpoint for HTTP requests by clients. | ||
# tcp://ipv4-address:port | ||
# tcp://[ipv6-address]:port | ||
# ssl://ipv4-address:port | ||
# ssl://[ipv6-address]:port | ||
# unix:///path/to/socket | ||
# | ||
# Examples: | ||
# endpoint = tcp://0.0.0.0:8529 | ||
# endpoint = tcp://127.0.0.1:8529 | ||
# endpoint = tcp://localhost:8529 | ||
# endpoint = tcp://myserver.arangodb.com:8529 | ||
# endpoint = tcp://[::]:8529 | ||
# endpoint = tcp://[fe80::21a:5df1:aede:98cf]:8529 | ||
# | ||
endpoint = tcp://127.0.0.1:$ARANGODB_PORT | ||
storage-engine = auto | ||
|
||
# reuse a port on restart or wait until it is freed by the operating system | ||
# reuse-address = false | ||
|
||
authentication = true | ||
|
||
# number of maximal server threads. use 0 to make arangod determine the | ||
# number of threads automatically, based on available CPUs | ||
# maximal-threads = 0 | ||
|
||
# gather server statistics | ||
statistics = true | ||
|
||
# the user and group are normally set in the start script | ||
# uid = arangodb | ||
# gid = arangodb | ||
|
||
uid = $USER | ||
|
||
|
||
[javascript] | ||
startup-directory = /nix/store/gcr7n4cvkyprwgf6r8f882yxvwi5zgdb-arangodb-3.10.5.2/share/arangodb3/js | ||
app-path = ../../arangodb3-apps | ||
# app-path = //arangodb3/apps | ||
|
||
# number of V8 contexts available for JavaScript execution. use 0 to | ||
# make arangod determine the number of contexts automatically. | ||
# v8-contexts = 0 | ||
|
||
[foxx] | ||
# enable Foxx queues in the server | ||
# queues = true | ||
|
||
# interval (seconds) to use for polling jobs in Foxx queues | ||
# queues-poll-interval = 1 | ||
|
||
[log] | ||
level = info | ||
file = ../../arangod.log | ||
|
||
[cluster] | ||
|
||
[rocksdb] | ||
# encryption-keyfile=/your-encryption-file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
authors = [ | ||
"Tsiry Sandratraina <[email protected]>", | ||
] | ||
description = "ArangoDB Plugin for FluentCI" | ||
keywords = [ | ||
"arangodb", | ||
] | ||
license = "MIT" | ||
name = "arangodb" | ||
version = "0.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
use anyhow::Error; | ||
use fluentci_pdk::dag; | ||
|
||
pub fn setup() -> Result<String, Error> { | ||
let os = dag().get_os()?; | ||
dag() | ||
.pipeline("setup")? | ||
.with_exec(vec![ | ||
"mkdir", | ||
"-p", | ||
".fluentci/arangodb", | ||
"arangodb3-apps", | ||
"arangodb3-data", | ||
])? | ||
.stdout()?; | ||
|
||
let arangodb_port = dag().get_env("ARANGODB_PORT")?; | ||
let arangodb_datadir = dag().get_env("ARANGODB_DATADIR")?; | ||
let arangodb_version = dag().get_env("ARANGODB_VERSION")?; | ||
let is_root = dag() | ||
.pkgx()? | ||
.with_exec(vec!["whoami"])? | ||
.stdout()? | ||
.contains("root"); | ||
|
||
if arangodb_port.is_empty() { | ||
dag().set_envs(vec![("ARANGODB_PORT".into(), "8529".into())])?; | ||
} | ||
|
||
if is_root { | ||
dag().set_envs(vec![("USER".into(), "fluentci".into())])?; | ||
} | ||
|
||
if arangodb_datadir.is_empty() { | ||
dag().set_envs(vec![( | ||
"ARANGODB_DATADIR".into(), | ||
"../../arangodb3-data".into(), | ||
)])?; | ||
} | ||
|
||
if arangodb_version.is_empty() { | ||
dag().set_envs(vec![("ARANGODB_VERSION".into(), "3.10.5.2".into())])?; | ||
} | ||
|
||
dag().set_envs(vec![ | ||
( | ||
"ICU_DATA".into(), | ||
".devbox/nix/profile/default/share/arangodb3/".into(), | ||
), | ||
( | ||
"TZ_DATA".into(), | ||
".devbox/nix/profile/default/share/arangodb3/tzdata/".into(), | ||
), | ||
])?; | ||
|
||
if os == "linux" { | ||
dag() | ||
.devbox()? | ||
.with_workdir("/tmp")? | ||
.with_exec(vec![match is_root { | ||
true => "chown -R fluentci /nix", | ||
false => "true", | ||
}])? | ||
.with_exec(vec!["rm", "`which devbox`"])? | ||
.stdout()?; | ||
} | ||
|
||
let command = match os.as_str() { | ||
"linux" => match is_root { | ||
true => "grep -q arangodb: Procfile || echo -e 'arangodb: sudo -H -E -u fluentci PATH=$PATH bash -c \"devbox run arangod --configuration ../../arangod.conf\" \\n' >> Procfile", | ||
false => "grep -q arangodb: Procfile || echo -e 'arangodb: devbox run arangod --configuration ../../arangod.conf \\n' >> Procfile" | ||
}, | ||
_ => &format!("grep -q arangodb: Procfile || echo -e 'arangodb: pkgx docker run -p $ARANGODB_PORT:8529 arangodb:{} \\n' >> Procfile", arangodb_version) | ||
}; | ||
|
||
let stdout = dag() | ||
.devbox()? | ||
.with_workdir(".fluentci/arangodb")? | ||
.with_exec( | ||
match os.as_str() { | ||
"linux" => vec!["devbox", "add", "arangodb@$ARANGODB_VERSION", "overmind", "tmux"], | ||
_ => vec!["devbox", "add", "overmind", "tmux"] | ||
} | ||
)? | ||
.with_exec(vec!["[ -f arangod.conf.template ] || pkgx wget https://raw.githubusercontent.com/fluentci-io/services/main/arangodb/arangod.conf.template"])? | ||
.with_exec(vec!["[ -f ../../arangod.conf ] || pkgx envsubst < arangod.conf.template > ../../arangod.conf "])? | ||
.with_exec(vec![ | ||
match is_root && os == "linux" { | ||
true => "chown -R fluentci ../.. /nix", | ||
false => "true" | ||
} | ||
])? | ||
.with_exec(vec![ command ])? | ||
.stdout()?; | ||
|
||
Ok(stdout) | ||
} |
Oops, something went wrong.