Skip to content

Commit

Permalink
[plugin] add setup function
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Apr 14, 2024
1 parent f8767f3 commit 6382d0f
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 28 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Fluent CI CLI
uses: fluentci-io/setup-fluentci@v4
- name: Setup Fluent CI
uses: fluentci-io/setup-fluentci@v5
with:
wasm: true
plugin: deno
args: |
fmt
test
coverage
- name: Run Dagger Pipelines
run: |
fluentci run deno_pipeline fmt test
dagger -m github.com/fluent-ci-templates/rust-pipeline@main functions
- name: Upload to Codecov
run: fluentci run codecov_pipeline
run: fluentci run --wasm codecov upload
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
publish:
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Fluent CI CLI
uses: fluentci-io/setup-fluentci@v5

- name: Run Wasm Pipeline
run: fluentci run --wasm . test
working-directory: example

with:
wasm: true
plugin: .
args: test
working-directory: example

- name: Run Dagger Pipelines
run: dagger run deno run -A ../src/dagger/runner.ts clippy test llvm_cov build
working-directory: example
4 changes: 2 additions & 2 deletions dagger.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "rust",
"sdk": "github.com/fluentci-io/daggerverse/deno-sdk@main",
"version": "v0.10.1",
"version": "v0.10.2",
"description": "",
"author": "Tsiry Sandratraina",
"license": "MIT"
}
}
2 changes: 1 addition & 1 deletion example/.fluentci/plugin/Cargo.lock

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

2 changes: 1 addition & 1 deletion example/.fluentci/plugin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "rust"
version = "0.10.1"
version = "0.10.2"

[lib]
crate-type = ["cdylib"]
Expand Down
25 changes: 19 additions & 6 deletions example/.fluentci/plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ use crate::helpers::set_envs;

pub mod helpers;

#[plugin_fn]
pub fn setup() -> FnResult<String> {
set_envs()?;

let stdout = dag()
.pipeline("setup")?
.pkgx()?
.with_packages(vec!["curl"])?
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
.stdout()?;
Ok(stdout)
}

#[plugin_fn]
pub fn clippy() -> FnResult<String> {
set_envs()?;
Expand Down Expand Up @@ -65,7 +78,7 @@ pub fn test(args: String) -> FnResult<String> {
let stdout = dag()
.pipeline("test")?
.pkgx()?
.with_packages(vec!["curl", "wget"])?
.with_packages(vec!["curl"])?
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
.with_exec(vec!["PATH=$HOME/.cargo/bin:$PATH", "cargo", "test", &args])?
.stdout()?;
Expand All @@ -79,7 +92,7 @@ pub fn build(args: String) -> FnResult<String> {
let stdout = dag()
.pipeline("build")?
.pkgx()?
.with_exec(vec!["pkgx", "install", "curl"])?
.with_packages(vec!["curl"])?
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
.with_exec(vec!["PATH=$HOME/.cargo/bin:$PATH", "cargo", "build", &args])?
.stdout()?;
Expand All @@ -93,9 +106,9 @@ pub fn target_add(args: String) -> FnResult<String> {
let stdout = dag()
.pipeline("target_add")?
.pkgx()?
.with_exec(vec!["pkgx", "install", "curl"])?
.with_packages(vec!["curl"])?
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
.with_exec(vec!["rustup", "target", "add", &args])?
.with_exec(vec!["PATH=$HOME/.cargo/bin:$PATH", "rustup", "target", "add", &args])?
.stdout()?;
Ok(stdout)
}
Expand All @@ -107,9 +120,9 @@ pub fn component_add(args: String) -> FnResult<String> {
let stdout = dag()
.pipeline("component_add")?
.pkgx()?
.with_exec(vec!["pkgx", "install", "curl"])?
.with_packages(vec![ "curl"])?
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
.with_exec(vec!["rustup", "component", "add", &args])?
.with_exec(vec!["PATH=$HOME/.cargo/bin:$PATH", "rustup", "component", "add", &args])?
.stdout()?;
Ok(stdout)
}
2 changes: 1 addition & 1 deletion plugin/Cargo.lock

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

2 changes: 1 addition & 1 deletion plugin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "rust"
version = "0.10.1"
version = "0.10.2"

[lib]
crate-type = ["cdylib"]
Expand Down
25 changes: 19 additions & 6 deletions plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ use crate::helpers::set_envs;

pub mod helpers;

#[plugin_fn]
pub fn setup() -> FnResult<String> {
set_envs()?;

let stdout = dag()
.pipeline("setup")?
.pkgx()?
.with_packages(vec!["curl"])?
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
.stdout()?;
Ok(stdout)
}

#[plugin_fn]
pub fn clippy() -> FnResult<String> {
set_envs()?;
Expand Down Expand Up @@ -65,7 +78,7 @@ pub fn test(args: String) -> FnResult<String> {
let stdout = dag()
.pipeline("test")?
.pkgx()?
.with_packages(vec!["curl", "wget"])?
.with_packages(vec!["curl"])?
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
.with_exec(vec!["PATH=$HOME/.cargo/bin:$PATH", "cargo", "test", &args])?
.stdout()?;
Expand All @@ -79,7 +92,7 @@ pub fn build(args: String) -> FnResult<String> {
let stdout = dag()
.pipeline("build")?
.pkgx()?
.with_exec(vec!["pkgx", "install", "curl"])?
.with_packages(vec!["curl"])?
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
.with_exec(vec!["PATH=$HOME/.cargo/bin:$PATH", "cargo", "build", &args])?
.stdout()?;
Expand All @@ -93,9 +106,9 @@ pub fn target_add(args: String) -> FnResult<String> {
let stdout = dag()
.pipeline("target_add")?
.pkgx()?
.with_exec(vec!["pkgx", "install", "curl"])?
.with_packages(vec!["curl"])?
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
.with_exec(vec!["rustup", "target", "add", &args])?
.with_exec(vec!["PATH=$HOME/.cargo/bin:$PATH", "rustup", "target", "add", &args])?
.stdout()?;
Ok(stdout)
}
Expand All @@ -107,9 +120,9 @@ pub fn component_add(args: String) -> FnResult<String> {
let stdout = dag()
.pipeline("component_add")?
.pkgx()?
.with_exec(vec!["pkgx", "install", "curl"])?
.with_packages(vec![ "curl"])?
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
.with_exec(vec!["rustup", "component", "add", &args])?
.with_exec(vec!["PATH=$HOME/.cargo/bin:$PATH", "rustup", "component", "add", &args])?
.stdout()?;
Ok(stdout)
}

0 comments on commit 6382d0f

Please sign in to comment.