Skip to content

Commit 6382d0f

Browse files
committed
[plugin] add setup function
1 parent f8767f3 commit 6382d0f

File tree

9 files changed

+61
-28
lines changed

9 files changed

+61
-28
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v2
13-
- name: Setup Fluent CI CLI
14-
uses: fluentci-io/setup-fluentci@v4
13+
- name: Setup Fluent CI
14+
uses: fluentci-io/setup-fluentci@v5
15+
with:
16+
wasm: true
17+
plugin: deno
18+
args: |
19+
fmt
20+
test
21+
coverage
1522
- name: Run Dagger Pipelines
1623
run: |
17-
fluentci run deno_pipeline fmt test
1824
dagger -m github.com/fluent-ci-templates/rust-pipeline@main functions
1925
- name: Upload to Codecov
20-
run: fluentci run codecov_pipeline
26+
run: fluentci run --wasm codecov upload
2127
env:
2228
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2329
publish:

.github/workflows/example.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v2
13-
13+
1414
- name: Setup Fluent CI CLI
1515
uses: fluentci-io/setup-fluentci@v5
16-
17-
- name: Run Wasm Pipeline
18-
run: fluentci run --wasm . test
19-
working-directory: example
20-
16+
with:
17+
wasm: true
18+
plugin: .
19+
args: test
20+
working-directory: example
21+
2122
- name: Run Dagger Pipelines
2223
run: dagger run deno run -A ../src/dagger/runner.ts clippy test llvm_cov build
2324
working-directory: example

dagger.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "rust",
33
"sdk": "github.com/fluentci-io/daggerverse/deno-sdk@main",
4-
"version": "v0.10.1",
4+
"version": "v0.10.2",
55
"description": "",
66
"author": "Tsiry Sandratraina",
77
"license": "MIT"
8-
}
8+
}

example/.fluentci/plugin/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/.fluentci/plugin/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
edition = "2021"
33
name = "rust"
4-
version = "0.10.1"
4+
version = "0.10.2"
55

66
[lib]
77
crate-type = ["cdylib"]

example/.fluentci/plugin/src/lib.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ use crate::helpers::set_envs;
55

66
pub mod helpers;
77

8+
#[plugin_fn]
9+
pub fn setup() -> FnResult<String> {
10+
set_envs()?;
11+
12+
let stdout = dag()
13+
.pipeline("setup")?
14+
.pkgx()?
15+
.with_packages(vec!["curl"])?
16+
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
17+
.stdout()?;
18+
Ok(stdout)
19+
}
20+
821
#[plugin_fn]
922
pub fn clippy() -> FnResult<String> {
1023
set_envs()?;
@@ -65,7 +78,7 @@ pub fn test(args: String) -> FnResult<String> {
6578
let stdout = dag()
6679
.pipeline("test")?
6780
.pkgx()?
68-
.with_packages(vec!["curl", "wget"])?
81+
.with_packages(vec!["curl"])?
6982
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
7083
.with_exec(vec!["PATH=$HOME/.cargo/bin:$PATH", "cargo", "test", &args])?
7184
.stdout()?;
@@ -79,7 +92,7 @@ pub fn build(args: String) -> FnResult<String> {
7992
let stdout = dag()
8093
.pipeline("build")?
8194
.pkgx()?
82-
.with_exec(vec!["pkgx", "install", "curl"])?
95+
.with_packages(vec!["curl"])?
8396
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
8497
.with_exec(vec!["PATH=$HOME/.cargo/bin:$PATH", "cargo", "build", &args])?
8598
.stdout()?;
@@ -93,9 +106,9 @@ pub fn target_add(args: String) -> FnResult<String> {
93106
let stdout = dag()
94107
.pipeline("target_add")?
95108
.pkgx()?
96-
.with_exec(vec!["pkgx", "install", "curl"])?
109+
.with_packages(vec!["curl"])?
97110
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
98-
.with_exec(vec!["rustup", "target", "add", &args])?
111+
.with_exec(vec!["PATH=$HOME/.cargo/bin:$PATH", "rustup", "target", "add", &args])?
99112
.stdout()?;
100113
Ok(stdout)
101114
}
@@ -107,9 +120,9 @@ pub fn component_add(args: String) -> FnResult<String> {
107120
let stdout = dag()
108121
.pipeline("component_add")?
109122
.pkgx()?
110-
.with_exec(vec!["pkgx", "install", "curl"])?
123+
.with_packages(vec![ "curl"])?
111124
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
112-
.with_exec(vec!["rustup", "component", "add", &args])?
125+
.with_exec(vec!["PATH=$HOME/.cargo/bin:$PATH", "rustup", "component", "add", &args])?
113126
.stdout()?;
114127
Ok(stdout)
115128
}

plugin/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
edition = "2021"
33
name = "rust"
4-
version = "0.10.1"
4+
version = "0.10.2"
55

66
[lib]
77
crate-type = ["cdylib"]

plugin/src/lib.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ use crate::helpers::set_envs;
55

66
pub mod helpers;
77

8+
#[plugin_fn]
9+
pub fn setup() -> FnResult<String> {
10+
set_envs()?;
11+
12+
let stdout = dag()
13+
.pipeline("setup")?
14+
.pkgx()?
15+
.with_packages(vec!["curl"])?
16+
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
17+
.stdout()?;
18+
Ok(stdout)
19+
}
20+
821
#[plugin_fn]
922
pub fn clippy() -> FnResult<String> {
1023
set_envs()?;
@@ -65,7 +78,7 @@ pub fn test(args: String) -> FnResult<String> {
6578
let stdout = dag()
6679
.pipeline("test")?
6780
.pkgx()?
68-
.with_packages(vec!["curl", "wget"])?
81+
.with_packages(vec!["curl"])?
6982
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
7083
.with_exec(vec!["PATH=$HOME/.cargo/bin:$PATH", "cargo", "test", &args])?
7184
.stdout()?;
@@ -79,7 +92,7 @@ pub fn build(args: String) -> FnResult<String> {
7992
let stdout = dag()
8093
.pipeline("build")?
8194
.pkgx()?
82-
.with_exec(vec!["pkgx", "install", "curl"])?
95+
.with_packages(vec!["curl"])?
8396
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
8497
.with_exec(vec!["PATH=$HOME/.cargo/bin:$PATH", "cargo", "build", &args])?
8598
.stdout()?;
@@ -93,9 +106,9 @@ pub fn target_add(args: String) -> FnResult<String> {
93106
let stdout = dag()
94107
.pipeline("target_add")?
95108
.pkgx()?
96-
.with_exec(vec!["pkgx", "install", "curl"])?
109+
.with_packages(vec!["curl"])?
97110
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
98-
.with_exec(vec!["rustup", "target", "add", &args])?
111+
.with_exec(vec!["PATH=$HOME/.cargo/bin:$PATH", "rustup", "target", "add", &args])?
99112
.stdout()?;
100113
Ok(stdout)
101114
}
@@ -107,9 +120,9 @@ pub fn component_add(args: String) -> FnResult<String> {
107120
let stdout = dag()
108121
.pipeline("component_add")?
109122
.pkgx()?
110-
.with_exec(vec!["pkgx", "install", "curl"])?
123+
.with_packages(vec![ "curl"])?
111124
.with_exec(vec!["type rustup > /dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"])?
112-
.with_exec(vec!["rustup", "component", "add", &args])?
125+
.with_exec(vec!["PATH=$HOME/.cargo/bin:$PATH", "rustup", "component", "add", &args])?
113126
.stdout()?;
114127
Ok(stdout)
115128
}

0 commit comments

Comments
 (0)