From e6dd21c76502ffa21eeed9390b9b1aee43e2b0d5 Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Mon, 1 Apr 2024 20:05:29 +0000 Subject: [PATCH 1/2] feat: add wasm plugin --- deno.lock | 16 ++ deps.ts | 3 + plugin/.gitignore | 1 + plugin/Cargo.lock | 395 ++++++++++++++++++++++++++++++++++++++++++ plugin/Cargo.toml | 13 ++ plugin/src/lib.rs | 21 +++ src/fluentci/index.ts | 0 src/fluentci/jobs.ts | 0 8 files changed, 449 insertions(+) create mode 100644 plugin/.gitignore create mode 100644 plugin/Cargo.lock create mode 100644 plugin/Cargo.toml create mode 100644 plugin/src/lib.rs create mode 100644 src/fluentci/index.ts create mode 100644 src/fluentci/jobs.ts diff --git a/deno.lock b/deno.lock index 2a18bff..c1f63e1 100644 --- a/deno.lock +++ b/deno.lock @@ -2,6 +2,7 @@ "version": "3", "packages": { "specifiers": { + "jsr:@fluentci/sdk@0.1.4": "jsr:@fluentci/sdk@0.1.4", "jsr:@std/assert@^0.217.0": "jsr:@std/assert@0.217.0", "jsr:@std/assert@^0.218.2": "jsr:@std/assert@0.218.2", "jsr:@std/flags@0.218.2": "jsr:@std/flags@0.218.2", @@ -11,6 +12,8 @@ "jsr:@std/path@0.218.2": "jsr:@std/path@0.218.2", "jsr:@std/testing@0.217.0": "jsr:@std/testing@0.217.0", "jsr:@std/testing@0.218.2": "jsr:@std/testing@0.218.2", + "jsr:@tsirysndr/env-js@0.1.2": "jsr:@tsirysndr/env-js@0.1.2", + "jsr:@tsirysndr/exit-js@0.1.0": "jsr:@tsirysndr/exit-js@0.1.0", "jsr:@tsirysndr/fluent-az-pipelines@0.3": "jsr:@tsirysndr/fluent-az-pipelines@0.3.0", "jsr:@tsirysndr/fluent-circleci@0.3": "jsr:@tsirysndr/fluent-circleci@0.3.0", "jsr:@tsirysndr/fluent-codepipeline@0.3": "jsr:@tsirysndr/fluent-codepipeline@0.3.0", @@ -20,6 +23,7 @@ "npm:@dagger.io/dagger@0.9.3": "npm:@dagger.io/dagger@0.9.3_graphql@16.8.1", "npm:graphql-request@6.1.0": "npm:graphql-request@6.1.0_graphql@16.8.1", "npm:graphql-tag@2.12.6": "npm:graphql-tag@2.12.6_graphql@16.8.1", + "npm:graphql@16.8.1": "npm:graphql@16.8.1", "npm:lodash": "npm:lodash@4.17.21", "npm:lodash@4.17.21": "npm:lodash@4.17.21", "npm:node-color-log": "npm:node-color-log@11.0.2", @@ -29,6 +33,12 @@ "npm:zod@3.22.1": "npm:zod@3.22.1" }, "jsr": { + "@fluentci/sdk@0.1.4": { + "integrity": "8e6fd257514c86fa7ccd61685dd67a3e5e9695f1282c8376e9709c9194f66790", + "dependencies": [ + "npm:graphql-request@6.1.0" + ] + }, "@std/assert@0.217.0": { "integrity": "c98e279362ca6982d5285c3b89517b757c1e3477ee9f14eb2fdf80a45aaa9642", "dependencies": [ @@ -71,6 +81,12 @@ "jsr:@std/assert@^0.218.2" ] }, + "@tsirysndr/env-js@0.1.2": { + "integrity": "16a8cf4e60c8b43f4d62dd762006de40d56e5b144a56c0954a11f99ee12c5d3a" + }, + "@tsirysndr/exit-js@0.1.0": { + "integrity": "4ea378ce2575931426bcf60d4588c9e9cf489fa93d3907cd9ee60feb38960230" + }, "@tsirysndr/fluent-az-pipelines@0.3.0": { "integrity": "a2a23089a186b0f04e45daa7a9df98527c54b845842c1ebe3b7f2cf03e5aec0d", "dependencies": [ diff --git a/deps.ts b/deps.ts index d481b89..34f62b1 100644 --- a/deps.ts +++ b/deps.ts @@ -39,3 +39,6 @@ export * as FluentGithubActions from "jsr:@tsirysndr/fluent-gh-actions@0.3"; export * as FluentCircleCI from "jsr:@tsirysndr/fluent-circleci@0.3"; export * as FluentAzurePipelines from "jsr:@tsirysndr/fluent-az-pipelines@0.3"; export * as FluentAWSCodePipeline from "jsr:@tsirysndr/fluent-codepipeline@0.3"; + +import * as fluentciSdk from "jsr:@fluentci/sdk@0.1.4"; +export { fluentciSdk }; diff --git a/plugin/.gitignore b/plugin/.gitignore new file mode 100644 index 0000000..c8b241f --- /dev/null +++ b/plugin/.gitignore @@ -0,0 +1 @@ +target/* \ No newline at end of file diff --git a/plugin/Cargo.lock b/plugin/Cargo.lock new file mode 100644 index 0000000..842433b --- /dev/null +++ b/plugin/Cargo.lock @@ -0,0 +1,395 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anyhow" +version = "1.0.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" + +[[package]] +name = "autocfg" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" + +[[package]] +name = "bytemuck" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + +[[package]] +name = "codecov" +version = "0.1.0" +dependencies = [ + "extism-pdk", + "fluentci-pdk", +] + +[[package]] +name = "either" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "extism-convert" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a63bfc6d371d3b51d6094fd96c4c32a084ceefece3b4f4b328f30067d29da064" +dependencies = [ + "anyhow", + "base64 0.22.0", + "bytemuck", + "extism-convert-macros", + "prost", + "rmp-serde", + "serde", + "serde_json", +] + +[[package]] +name = "extism-convert-macros" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "519ccf960500c87244bef99caf8e58222ac95bf1abb06a32f5217b4788857aa6" +dependencies = [ + "manyhow", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "extism-manifest" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c7d16695dc6b72418e23b58c943411a08264332af403ae9870997b4d495c3d" +dependencies = [ + "base64 0.22.0", + "serde", + "serde_json", +] + +[[package]] +name = "extism-pdk" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f9a87d636d30b75e697642dd4f6cff2054db5a7a5d69d6601041a76265bb681" +dependencies = [ + "anyhow", + "base64 0.21.7", + "extism-convert", + "extism-manifest", + "extism-pdk-derive", + "serde", + "serde_json", +] + +[[package]] +name = "extism-pdk-derive" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83995c2023720a0fd5ef2a349c89c1670efb37a979228b0218705f5ddb50d4b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "fluentci-pdk" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec1127e7eeac436e14d5a5dd93d52c2e924c645b1a098cdcb89c978365ebf9e6" +dependencies = [ + "extism-pdk", + "fluentci-types", + "serde", +] + +[[package]] +name = "fluentci-types" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9167b79ce314a69d34ba10732dbd8d167bbd5efc70b92f8e24699ba04ae730a0" +dependencies = [ + "serde", +] + +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "manyhow" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02bc2a348104913df6d14170bedef54faf224a0970ec7b1f8750748ab94fcd52" +dependencies = [ + "manyhow-macros", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "manyhow-macros" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "532aa12d5846b38a524b3acd99fb74dc8a5f193b33e65dac142ef92bd60f9416" +dependencies = [ + "proc-macro-utils", + "proc-macro2", + "quote", +] + +[[package]] +name = "memchr" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" + +[[package]] +name = "num-traits" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro-utils" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f59e109e2f795a5070e69578c4dc101068139f74616778025ae1011d4cd41a8" +dependencies = [ + "proc-macro2", + "quote", + "smallvec", +] + +[[package]] +name = "proc-macro2" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rmp" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f9860a6cc38ed1da53456442089b4dfa35e7cedaa326df63017af88385e6b20" +dependencies = [ + "byteorder", + "num-traits", + "paste", +] + +[[package]] +name = "rmp-serde" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bffea85eea980d8a74453e5d02a8d93028f3c34725de143085a844ebe953258a" +dependencies = [ + "byteorder", + "rmp", + "serde", +] + +[[package]] +name = "ryu" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" + +[[package]] +name = "serde" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.115" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "syn" +version = "2.0.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11a6ae1e52eb25aab8f3fb9fca13be982a373b8f1157ca14b897a825ba4a2d35" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" + +[[package]] +name = "toml_edit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] diff --git a/plugin/Cargo.toml b/plugin/Cargo.toml new file mode 100644 index 0000000..c39ad44 --- /dev/null +++ b/plugin/Cargo.toml @@ -0,0 +1,13 @@ +[package] +edition = "2021" +name = "codecov" +version = "0.1.0" + +[lib] +crate-type = ["cdylib"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +extism-pdk = "1.1.0" +fluentci-pdk = "0.1.3" diff --git a/plugin/src/lib.rs b/plugin/src/lib.rs new file mode 100644 index 0000000..fdb636f --- /dev/null +++ b/plugin/src/lib.rs @@ -0,0 +1,21 @@ +use extism_pdk::*; +use fluentci_pdk::dag; + +#[plugin_fn] +pub fn upload(args: String) -> FnResult { + let stdout = dag() + .pipeline("upload")? + .pkgx()? + .with_exec(vec!["pkgx", "install", "curl", "git"])? + .with_exec(vec![ + "curl", + "-Os", + "https://uploader.codecov.io/latest/linux/codecov", + ])? + .with_exec(vec!["chmod", "+x", "codecov"])? + .with_exec(vec!["mkdir", "-p", ".local/bin"])? + .with_exec(vec!["mv", "codecov", ".local/bin/codecov"])? + .with_exec(vec![".local/bin/codecov", "-t", "$CODECOV_TOKEN", &args])? + .stdout()?; + Ok(stdout) +} diff --git a/src/fluentci/index.ts b/src/fluentci/index.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/fluentci/jobs.ts b/src/fluentci/jobs.ts new file mode 100644 index 0000000..e69de29 From 08a468d1da97ec72a071abe4cb34e4b76f55353c Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Mon, 8 Apr 2024 05:09:03 +0000 Subject: [PATCH 2/2] [plugin] use fluentci-pdk v0.1.9 --- plugin/Cargo.lock | 8 ++++---- plugin/Cargo.toml | 2 +- plugin/src/lib.rs | 6 ++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/plugin/Cargo.lock b/plugin/Cargo.lock index 842433b..354bc5a 100644 --- a/plugin/Cargo.lock +++ b/plugin/Cargo.lock @@ -132,9 +132,9 @@ dependencies = [ [[package]] name = "fluentci-pdk" -version = "0.1.3" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec1127e7eeac436e14d5a5dd93d52c2e924c645b1a098cdcb89c978365ebf9e6" +checksum = "4d8004273f0e173b96811a72cb742fc9010fc54fec89c59c2c4e7e159fc2bde7" dependencies = [ "extism-pdk", "fluentci-types", @@ -143,9 +143,9 @@ dependencies = [ [[package]] name = "fluentci-types" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9167b79ce314a69d34ba10732dbd8d167bbd5efc70b92f8e24699ba04ae730a0" +checksum = "7592ba0dd1c48f06166fa485af48c8df942e7266c62216fe01360b33e33fe047" dependencies = [ "serde", ] diff --git a/plugin/Cargo.toml b/plugin/Cargo.toml index c39ad44..3125bdd 100644 --- a/plugin/Cargo.toml +++ b/plugin/Cargo.toml @@ -10,4 +10,4 @@ crate-type = ["cdylib"] [dependencies] extism-pdk = "1.1.0" -fluentci-pdk = "0.1.3" +fluentci-pdk = "0.1.9" diff --git a/plugin/src/lib.rs b/plugin/src/lib.rs index fdb636f..214409d 100644 --- a/plugin/src/lib.rs +++ b/plugin/src/lib.rs @@ -6,16 +6,14 @@ pub fn upload(args: String) -> FnResult { let stdout = dag() .pipeline("upload")? .pkgx()? - .with_exec(vec!["pkgx", "install", "curl", "git"])? + .with_packages(vec!["curl", "git"])? .with_exec(vec![ "curl", "-Os", "https://uploader.codecov.io/latest/linux/codecov", ])? .with_exec(vec!["chmod", "+x", "codecov"])? - .with_exec(vec!["mkdir", "-p", ".local/bin"])? - .with_exec(vec!["mv", "codecov", ".local/bin/codecov"])? - .with_exec(vec![".local/bin/codecov", "-t", "$CODECOV_TOKEN", &args])? + .with_exec(vec!["./codecov", "-t", "$CODECOV_TOKEN", &args])? .stdout()?; Ok(stdout) }