Skip to content

Commit

Permalink
expose a function for hermit install
Browse files Browse the repository at this point in the history
expose a function for hermit install
  • Loading branch information
tsirysndr committed Aug 19, 2024
1 parent d75f37b commit 1daad0b
Show file tree
Hide file tree
Showing 19 changed files with 120 additions and 35 deletions.
4 changes: 3 additions & 1 deletion .fluentci/src/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,14 @@ export async function e2e(
src: string | Directory | undefined = ".",
_options: string[] = []
): Promise<string> {
let plugins = [
const plugins = [
"archive",
"chmod",
"devbox",
"flox",
"git",
"hash",
"hermit",
"http",
"mise",
"nix",
Expand Down Expand Up @@ -532,6 +533,7 @@ export async function e2e(
"git",
"directory",
"envhub",
"hermit",
"mise",
"pixi",
"pkgx",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
wasm: true
pipeline: rust
args: build --release
engine-version: 0.4.0
engine-version: 0.4.7
- name: Run Build and e2e tests
run: |
export PATH=${HOME}/.cargo/bin:${PATH}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v3
- uses: fluentci-io/setup-fluentci@v5
with:
engine-version: 0.4.0
engine-version: 0.4.7
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Build
Expand Down
40 changes: 20 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ clap = "3.2.20"
extism = "1.2.0"
fluentci-core = {path = "../core", version = "0.3.6"}
fluentci-ext = {path = "../ext", version = "0.2.5"}
fluentci-server = {path = "../server", version = "0.3.6"}
fluentci-shared = {path = "../shared", version = "0.2.6"}
fluentci-server = {path = "../server", version = "0.3.7"}
fluentci-shared = {path = "../shared", version = "0.2.7"}
get-port = "4.0.0"
md5 = "0.7.0"
regex = "1.10.3"
Expand Down
1 change: 1 addition & 0 deletions crates/cli/src/cmd/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pub fn call(module: &str, command: &str) -> Result<(), Error> {
.with_function("mise", [], [PTR], user_data.clone(), mise)
.with_function("trust", [], [], user_data.clone(), trust)
.with_function("hermit", [], [PTR], user_data.clone(), hermit)
.with_function("install", [], [], user_data.clone(), install)
.with_function("with_exec", [PTR], [], user_data.clone(), with_exec)
.with_function("with_workdir", [PTR], [], user_data.clone(), with_workdir)
.with_function("with_cache", [PTR], [], user_data.clone(), with_cache)
Expand Down
2 changes: 1 addition & 1 deletion crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords = ["nix", "environment", "ci", "wasm", "devops"]
license = "MPL-2.0"
name = "fluentci-common"
repository = "https://github.com/fluentci-io/fluentci-engine"
version = "0.2.6"
version = "0.2.7"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
26 changes: 26 additions & 0 deletions crates/common/src/hermit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,29 @@ pub fn with_packages(graph: Arc<Mutex<Graph>>, packages: Vec<String>) -> Result<

Ok(())
}

pub fn install(graph: Arc<Mutex<Graph>>) -> Result<(), Error> {
let mut graph = graph.lock().unwrap();

let id = Uuid::new_v4().to_string();
let dep_id = graph.vertices[graph.size() - 1].id.clone();
let deps = match graph.size() {
1 => vec![],
_ => vec![dep_id],
};
graph.execute(GraphCommand::AddVertex(
id.clone(),
"install".into(),
"hermit install".into(),
deps,
Arc::new(Box::new(HermitExt::default())),
))?;

if graph.size() > 2 {
let x = graph.size() - 2;
let y = graph.size() - 1;
graph.execute(GraphCommand::AddEdge(x, y))?;
}

Ok(())
}
4 changes: 2 additions & 2 deletions crates/graphql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords = ["nix", "environment", "ci", "wasm", "devops"]
license = "MPL-2.0"
name = "fluentci-graphql"
repository = "https://github.com/fluentci-io/fluentci-engine"
version = "0.3.6"
version = "0.3.7"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -16,7 +16,7 @@ anyhow = "1.0.80"
async-graphql = "7.0.2"
async-graphql-actix-web = "7.0.2"
dirs = "5.0.1"
fluentci-common = {path = "../common", version = "0.2.6"}
fluentci-common = {path = "../common", version = "0.2.7"}
fluentci-core = {path = "../core", version = "0.3.6"}
fluentci-ext = {path = "../ext", version = "0.2.5"}
fluentci-secrets = {path = "../secrets", version = "0.1.0"}
Expand Down
6 changes: 6 additions & 0 deletions crates/graphql/src/schema/objects/hermit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ impl Hermit {
Ok(self)
}

async fn install(&self, ctx: &Context<'_>) -> Result<&Hermit, Error> {
let graph = ctx.data::<Arc<Mutex<Graph>>>().unwrap();
common_hermit::install(graph.clone())?;
Ok(self)
}

async fn stdout(&self, ctx: &Context<'_>) -> Result<String, Error> {
let graph = ctx.data::<Arc<Mutex<Graph>>>().unwrap();
let rx = ctx.data::<Arc<Mutex<Receiver<(String, usize)>>>>().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/pdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords = ["nix", "environment", "ci", "wasm", "devops"]
license = "MPL-2.0"
name = "fluentci-pdk"
repository = "https://github.com/fluentci-io/fluentci-engine"
version = "0.2.2"
version = "0.2.3"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
8 changes: 8 additions & 0 deletions crates/pdk/src/hermit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extern "ExtismHost" {
fn with_cache(cache: Json<Cache>);
fn with_file(file: Json<File>);
fn with_packages(packages: Json<Vec<String>>);
fn install();
fn stdout() -> String;
fn stderr() -> String;
fn as_service(name: String) -> Json<Service>;
Expand Down Expand Up @@ -91,6 +92,13 @@ impl Hermit {
})
}

pub fn install(&self) -> Result<Hermit, Error> {
unsafe { install() }?;
Ok(Hermit {
id: self.id.clone(),
})
}

pub fn stdout(&self) -> Result<String, Error> {
unsafe { stdout() }
}
Expand Down
4 changes: 2 additions & 2 deletions crates/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords = ["nix", "environment", "ci", "wasm", "devops"]
license = "MPL-2.0"
name = "fluentci-server"
repository = "https://github.com/fluentci-io/fluentci-engine"
version = "0.3.6"
version = "0.3.7"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -19,7 +19,7 @@ async-graphql = "7.0.2"
async-graphql-actix-web = "7.0.2"
fluentci-core = {path = "../core", version = "0.3.6"}
fluentci-ext = {path = "../ext", version = "0.2.5"}
fluentci-graphql = {path = "../graphql", version = "0.3.6"}
fluentci-graphql = {path = "../graphql", version = "0.3.7"}
mime_guess = "2.0.4"
owo-colors = "4.0.0"
tokio = "1.36.0"
4 changes: 2 additions & 2 deletions crates/shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ keywords = ["nix", "environment", "ci", "wasm", "devops"]
license = "MPL-2.0"
name = "fluentci-shared"
repository = "https://github.com/fluentci-io/fluentci-engine"
version = "0.2.6"
version = "0.2.7"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0.82"
extism = "1.2.0"
extism-pdk = "1.1.0"
fluentci-common = {path = "../common", version = "0.2.6"}
fluentci-common = {path = "../common", version = "0.2.7"}
fluentci-core = {path = "../core", version = "0.3.6"}
fluentci-ext = {path = "../ext", version = "0.2.5"}
fluentci-secrets = {path = "../secrets", version = "0.1.0"}
Expand Down
12 changes: 10 additions & 2 deletions crates/shared/src/hermit.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use extism::{convert::Json, *};
use fluentci_common::hermit::hermit as common_hermit;
use fluentci_common::hermit as common_hermit;

use crate::state::State;

Expand All @@ -8,6 +8,14 @@ host_fn!(pub hermit(user_data: State;) -> Json<Hermit> {
let state = state.lock().unwrap();
let graph = state.graph.clone();

let hermit = common_hermit(graph, true)?;
let hermit = common_hermit::hermit(graph, true)?;
Ok(Json(hermit))
});

host_fn!(pub install(user_data: State;) {
let state = user_data.get()?;
let state = state.lock().unwrap();
let graph = state.graph.clone();
common_hermit::install(graph)?;
Ok(())
});
Loading

0 comments on commit 1daad0b

Please sign in to comment.