Skip to content

Commit

Permalink
add fluentci.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Jun 17, 2024
1 parent 5f10db2 commit 5eb3036
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/zenith.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fluentci/swift",
"version": "0.6.0",
"version": "0.7.0",
"exports": "./mod.ts",
"importMap": "import_map.json",
"tasks": {
Expand Down
8 changes: 8 additions & 0 deletions fluentci.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
authors = [
"Tsiry Sandratraina <tsiry.sndr@fluentci.io>",
]
description = "CI/CD Plugin for Swift"
license = "MIT"
name = "swift"
version = "0.7.0"
21 changes: 10 additions & 11 deletions plugin/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
use anyhow::Error;
use fluentci_pdk::dag;

pub fn setup_swift(version: String) -> Result<String, Error> {
let mut version = version;
if version.is_empty() {
version = "5.7".into();
}
pub fn setup_swift() -> Result<String, Error> {
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)
}
24 changes: 7 additions & 17 deletions plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,27 @@ use crate::helpers::setup_swift;
pub mod helpers;

#[plugin_fn]
pub fn setup(version: String) -> FnResult<String> {
let stdout = setup_swift(version)?;
pub fn setup() -> FnResult<String> {
let stdout = setup_swift()?;
Ok(stdout)
}

#[plugin_fn]
pub fn build(args: String) -> FnResult<String> {
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<String> {
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)
}

0 comments on commit 5eb3036

Please sign in to comment.