From 5eb303600e5b9101f966d694f54f89632afcfe3a Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Mon, 17 Jun 2024 11:47:24 +0000 Subject: [PATCH] add fluentci.toml --- .github/workflows/zenith.yml | 2 +- deno.json | 2 +- fluentci.toml | 8 ++++++++ plugin/src/helpers.rs | 21 ++++++++++----------- plugin/src/lib.rs | 24 +++++++----------------- 5 files changed, 27 insertions(+), 30 deletions(-) create mode 100644 fluentci.toml diff --git a/.github/workflows/zenith.yml b/.github/workflows/zenith.yml index 6427fc5..28bcc6a 100644 --- a/.github/workflows/zenith.yml +++ b/.github/workflows/zenith.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v2 - name: Setup Dagger Zenith run: | - curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.11.0 sh + curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.11.7 sh sudo mv bin/dagger /usr/local/bin dagger version - name: Run Dagger Pipelines diff --git a/deno.json b/deno.json index 11470e7..5492f7e 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@fluentci/swift", - "version": "0.6.0", + "version": "0.7.0", "exports": "./mod.ts", "importMap": "import_map.json", "tasks": { diff --git a/fluentci.toml b/fluentci.toml new file mode 100644 index 0000000..779ad60 --- /dev/null +++ b/fluentci.toml @@ -0,0 +1,8 @@ +[package] +authors = [ + "Tsiry Sandratraina ", +] +description = "CI/CD Plugin for Swift" +license = "MIT" +name = "swift" +version = "0.7.0" diff --git a/plugin/src/helpers.rs b/plugin/src/helpers.rs index e5965d8..ea0eaeb 100644 --- a/plugin/src/helpers.rs +++ b/plugin/src/helpers.rs @@ -1,19 +1,18 @@ use anyhow::Error; use fluentci_pdk::dag; -pub fn setup_swift(version: String) -> Result { - let mut version = version; - if version.is_empty() { - version = "5.7".into(); - } +pub fn setup_swift() -> Result { + let path = dag().get_env("PATH")?; + + dag().set_envs(vec![( + "PATH".into(), + format!("/home/linuxbrew/.linuxbrew/bin:{}", path), + )])?; let stdout = dag() - .devbox()? - .with_exec(vec!["[ -f devbox.json ] || devbox init"])? - .with_exec(vec![&format!( - "grep -q 'swift' devbox.json || devbox add swift@{} swiftpm", - version - )])? + .pipeline("setup")? + .with_exec(vec![r#"type brew > /dev/null || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)""#])? + .with_exec(vec!["type swift > /dev/null || brew install swift"])? .stdout()?; Ok(stdout) } diff --git a/plugin/src/lib.rs b/plugin/src/lib.rs index b87edb2..abe57f3 100644 --- a/plugin/src/lib.rs +++ b/plugin/src/lib.rs @@ -8,37 +8,27 @@ use crate::helpers::setup_swift; pub mod helpers; #[plugin_fn] -pub fn setup(version: String) -> FnResult { - let stdout = setup_swift(version)?; +pub fn setup() -> FnResult { + let stdout = setup_swift()?; Ok(stdout) } #[plugin_fn] pub fn build(args: String) -> FnResult { - let mut version = dag().get_env("SWIFT_VERSION").unwrap_or_default(); - if version.is_empty() { - version = "5.7".into(); - } - - setup_swift(version)?; + setup_swift()?; let stdout = dag() - .devbox()? - .with_exec(vec!["devbox run -- swift build", &args])? + .pipeline("build")? + .with_exec(vec!["swift", "build", &args])? .stdout()?; Ok(stdout) } #[plugin_fn] pub fn test(args: String) -> FnResult { - let mut version = dag().get_env("SWIFT_VERSION").unwrap_or_default(); - if version.is_empty() { - version = "5.7".into(); - } - - setup_swift(version)?; + setup_swift()?; let stdout = dag() .devbox()? - .with_exec(vec!["devbox run -- swift test", &args])? + .with_exec(vec!["swift", "test", &args])? .stdout()?; Ok(stdout) }