From 180d3380ee35a6d30460e7ddb3a90f631c27b287 Mon Sep 17 00:00:00 2001 From: Daniel Hartig Date: Wed, 17 Feb 2021 16:28:27 -0600 Subject: [PATCH 1/5] Verified working wskdeploy with rust --- runtimes/runtimes.go | 16 ++++++++++++++++ specification/html/spec_actions.md | 1 + 2 files changed, 17 insertions(+) diff --git a/runtimes/runtimes.go b/runtimes/runtimes.go index 30e1bc066..186ee9d6d 100644 --- a/runtimes/runtimes.go +++ b/runtimes/runtimes.go @@ -497,6 +497,22 @@ var RUNTIME_DETAILS = []byte(`{ "attachmentType": "text/plain" } } + ], + "rust": [ + { + "kind": "rust:1.34", + "default": true, + "deprecated": false, + "attached": { + "attachmentName": "codefile", + "attachmentType": "text/plain" + }, + "image": { + "prefix": "openwhisk", + "name": "actionloop-rust-v1.34", + "tag": "latest" + } + } ] }, "blackboxes": [ diff --git a/specification/html/spec_actions.md b/specification/html/spec_actions.md index 56920c6da..991bc9764 100644 --- a/specification/html/spec_actions.md +++ b/specification/html/spec_actions.md @@ -168,6 +168,7 @@ The following runtime values are currently supported by the OpenWhisk platform " | swift@3.1.1 **(deprecated)** | swift:3.1.1 | [openwhisk/action-swift-v3.1.1](https://hub.docker.com/r/openwhisk/action-swift-v3.1.1) | nightly | Swift 3.1.1 language runtime | | dotnet | dotnet@2.2 (default) | dotnet:2.2 | [openwhisk/action-dotnet-v2.2](https://hub.docker.com/r/openwhisk/action-dotnet-v2.2) | nightly | .NET Core 2.2 runtime | | dotnet@3.1 | dotnet:3.1 | [openwhisk/action-dotnet-v3.1](https://hub.docker.com/r/openwhisk/action-dotnet-v3.1) | nightly | .NET Core 3.1 runtime | +| rust@1.34 | rust:1.34 | openwhisk/actionloop-rust-v1.34:latest | Latest Rust 1.34 language runtime | | language:default | N/A | N/A | N/A | Permit the OpenWhisk platform to select the correct default language runtime. | See the file [runtimes.json](https://github.com/apache/openwhisk/blob/master/ansible/files/runtimes.json) in From 78fac5d20ce4d5973a0d4b1712b3c28f5d1defef Mon Sep 17 00:00:00 2001 From: Daniel Hartig Date: Sat, 20 Feb 2021 12:01:25 -0600 Subject: [PATCH 2/5] Added unit tests --- specification/html/spec_actions.md | 5 ++++ .../integration/runtimetests/manifest.yaml | 8 ++++++ tests/src/integration/runtimetests/src/lib.rs | 27 +++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 tests/src/integration/runtimetests/src/lib.rs diff --git a/specification/html/spec_actions.md b/specification/html/spec_actions.md index 991bc9764..6995348fc 100644 --- a/specification/html/spec_actions.md +++ b/specification/html/spec_actions.md @@ -223,6 +223,11 @@ following file extensions are recognized and will be run on the version of corre ruby Latest Ruby language runtime. + + .rs + rust + Latest Rust language runtime. + diff --git a/tests/src/integration/runtimetests/manifest.yaml b/tests/src/integration/runtimetests/manifest.yaml index 7cbf18957..b6531e208 100644 --- a/tests/src/integration/runtimetests/manifest.yaml +++ b/tests/src/integration/runtimetests/manifest.yaml @@ -157,6 +157,14 @@ packages: place: string outputs: payload: string + hellorust134-with-explicit-runtime: + function: src/lib.rs + runtime: rust:1.34 + inputs: + name: string + place: string + outputs: + payload: string TestImplicitRuntimes: actions: greetingnodejs-without-explicit-runtime: diff --git a/tests/src/integration/runtimetests/src/lib.rs b/tests/src/integration/runtimetests/src/lib.rs new file mode 100644 index 000000000..17c8876e8 --- /dev/null +++ b/tests/src/integration/runtimetests/src/lib.rs @@ -0,0 +1,27 @@ +extern crate serde_json; + +use serde_derive::{Deserialize, Serialize}; +use serde_json::{Error, Value}; + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +struct Input { + #[serde(default = "stranger")] + name: String, +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +struct Output { + greeting: String, +} + +fn stranger() -> String { + "stranger".to_string() +} + +pub fn main(args: Value) -> Result { + let input: Input = serde_json::from_value(args)?; + let output = Output { + greeting: format!("Hello, {}", input.name), + }; + serde_json::to_value(output) +} \ No newline at end of file From 7ab51aae82cc8671703bfe7b0e6da6f237d83261 Mon Sep 17 00:00:00 2001 From: Daniel Hartig Date: Sat, 20 Feb 2021 14:41:29 -0600 Subject: [PATCH 3/5] Working tests; rs file extension still does not work --- runtimes/runtimes.go | 6 ++++++ tests/src/integration/runtimetests/Cargo.toml | 10 ++++++++++ tests/src/integration/runtimetests/helloCargo.zip | Bin 0 -> 746 bytes tests/src/integration/runtimetests/manifest.yaml | 14 ++++++++++++-- 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/src/integration/runtimetests/Cargo.toml create mode 100644 tests/src/integration/runtimetests/helloCargo.zip diff --git a/runtimes/runtimes.go b/runtimes/runtimes.go index 186ee9d6d..58fc9ae6b 100644 --- a/runtimes/runtimes.go +++ b/runtimes/runtimes.go @@ -44,6 +44,7 @@ const ( ZIP_FILE_EXTENSION = "zip" RUBY_FILE_EXTENSION = "rb" GO_FILE_EXTENSION = "go" + RUST_FILE_EXTENSION = "rs" NODEJS_RUNTIME = "nodejs" SWIFT_RUNTIME = SWIFT_FILE_EXTENSION PYTHON_RUNTIME = "python" @@ -52,6 +53,7 @@ const ( PHP_RUNTIME = PHP_FILE_EXTENSION RUBY_RUNTIME = "ruby" GO_RUNTIME = GO_FILE_EXTENSION + RUST_RUNTIME = "rust" HTTP_CONTENT_TYPE_KEY = "Content-Type" HTTP_CONTENT_TYPE_VALUE = "application/json; charset=UTF-8" RUNTIME_NOT_SPECIFIED = "NOT SPECIFIED" @@ -210,6 +212,8 @@ func FileExtensionRuntimes(op OpenWhiskInfo) (ext map[string]string) { } else if strings.Contains(k, DOTNET_RUNTIME) { ext[CSHARP_FILE_EXTENSION] = k ext[ZIP_FILE_EXTENSION] = k + } else if strings.Contains(k, RUST_RUNTIME) { + ext[RUST_FILE_EXTENSION] = k } } return @@ -237,6 +241,8 @@ func FileRuntimeExtensions(op OpenWhiskInfo) (rte map[string]string) { rte[v[i].Kind] = GO_FILE_EXTENSION } else if strings.Contains(k, DOTNET_RUNTIME) { rte[v[i].Kind] = CSHARP_FILE_EXTENSION + } else if strings.Contains(k, RUST_RUNTIME) { + rte[v[i].Kind] = RUST_FILE_EXTENSION } } } diff --git a/tests/src/integration/runtimetests/Cargo.toml b/tests/src/integration/runtimetests/Cargo.toml new file mode 100644 index 000000000..9b7aa967f --- /dev/null +++ b/tests/src/integration/runtimetests/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "actions" +version = "0.1.0" +authors = ["Dan Hartig "] +edition = "2018" + +[dependencies] +serde_json = "1.0" +serde_derive = "1.0" +serde = "1.0" \ No newline at end of file diff --git a/tests/src/integration/runtimetests/helloCargo.zip b/tests/src/integration/runtimetests/helloCargo.zip new file mode 100644 index 0000000000000000000000000000000000000000..53658a9fce9beee9a0ea480f705c9888644673f4 GIT binary patch literal 746 zcmWIWW@Zs#U|`^2a4ilAn)czxrWPP?GZ1qz$S^o37NzIwmE`BA<`|5*cy*Zn5_wIM;KZYJc-;VG$xmhKAT{<;J zrSt0agN!R}69eajzhKi9f2(hFBWB*;q>|SM-xc{T={U$Pe(n9_n`V$JY zifu5wa;i=Budd9VsN$^`1Qr$E5$=sTbku#?;lD*UcqgnrzB6zt-)f!jI~LzIv1TX_AcgT@7i*V&qFWv5R1ukb9rdh#(-=D!_3+*e90os%}} z*(%Y}J9koF8gng_nDcvz>&~6}=IM-=-7jri$1NVZxXb$odw@41lN>XyR3iaQI}8lK zz-L&}2x1|pAy!BlLJN0f^Dtu%*}M}#^N`~bXdWmoG0bCS1KG?3gbRSQ2{08fFaQ9M Co)l>S literal 0 HcmV?d00001 diff --git a/tests/src/integration/runtimetests/manifest.yaml b/tests/src/integration/runtimetests/manifest.yaml index b6531e208..ecb0020b3 100644 --- a/tests/src/integration/runtimetests/manifest.yaml +++ b/tests/src/integration/runtimetests/manifest.yaml @@ -150,6 +150,8 @@ packages: runtime: dotnet:2.2 main: Apache.OpenWhisk.Example.Dotnet::Apache.OpenWhisk.Example.Dotnet.Hello::Main zipaction-with-explicit-runtime: + annotations: + web-export: true function: src/helloworld runtime: nodejs:default inputs: @@ -157,8 +159,16 @@ packages: place: string outputs: payload: string - hellorust134-with-explicit-runtime: - function: src/lib.rs + # hellorust134-with-explicit-runtime: + # function: src/lib.rs + # runtime: rust:1.34 + # inputs: + # name: string + # place: string + # outputs: + # payload: string + hellocargo134-with-explicit-runtime: + function: helloCargo.zip runtime: rust:1.34 inputs: name: string From 07a67dd96f049b26ecc8f35531e2a3cdbc9f19f4 Mon Sep 17 00:00:00 2001 From: Daniel Hartig Date: Sat, 20 Feb 2021 15:00:43 -0600 Subject: [PATCH 4/5] Added headers to files and removed un-needed Cargo source files --- tests/src/integration/runtimetests/Cargo.toml | 10 --------- .../integration/runtimetests/manifest.yaml | 2 +- .../runtimetests/{ => src}/helloCargo.zip | Bin tests/src/integration/runtimetests/src/lib.rs | 19 +++++++++++++++++- 4 files changed, 19 insertions(+), 12 deletions(-) delete mode 100644 tests/src/integration/runtimetests/Cargo.toml rename tests/src/integration/runtimetests/{ => src}/helloCargo.zip (100%) diff --git a/tests/src/integration/runtimetests/Cargo.toml b/tests/src/integration/runtimetests/Cargo.toml deleted file mode 100644 index 9b7aa967f..000000000 --- a/tests/src/integration/runtimetests/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "actions" -version = "0.1.0" -authors = ["Dan Hartig "] -edition = "2018" - -[dependencies] -serde_json = "1.0" -serde_derive = "1.0" -serde = "1.0" \ No newline at end of file diff --git a/tests/src/integration/runtimetests/manifest.yaml b/tests/src/integration/runtimetests/manifest.yaml index ecb0020b3..c2084a007 100644 --- a/tests/src/integration/runtimetests/manifest.yaml +++ b/tests/src/integration/runtimetests/manifest.yaml @@ -168,7 +168,7 @@ packages: # outputs: # payload: string hellocargo134-with-explicit-runtime: - function: helloCargo.zip + function: src/helloCargo.zip runtime: rust:1.34 inputs: name: string diff --git a/tests/src/integration/runtimetests/helloCargo.zip b/tests/src/integration/runtimetests/src/helloCargo.zip similarity index 100% rename from tests/src/integration/runtimetests/helloCargo.zip rename to tests/src/integration/runtimetests/src/helloCargo.zip diff --git a/tests/src/integration/runtimetests/src/lib.rs b/tests/src/integration/runtimetests/src/lib.rs index 17c8876e8..83598f8af 100644 --- a/tests/src/integration/runtimetests/src/lib.rs +++ b/tests/src/integration/runtimetests/src/lib.rs @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + extern crate serde_json; use serde_derive::{Deserialize, Serialize}; @@ -24,4 +41,4 @@ pub fn main(args: Value) -> Result { greeting: format!("Hello, {}", input.name), }; serde_json::to_value(output) -} \ No newline at end of file +} From e4cb0f51db5d2dac11b5e4ea8d5645ddfda034c8 Mon Sep 17 00:00:00 2001 From: Daniel Hartig Date: Sat, 20 Feb 2021 21:03:25 -0600 Subject: [PATCH 5/5] Merge resolution --- runtimes/runtimes.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/runtimes/runtimes.go b/runtimes/runtimes.go index bedf00c30..db1bea91a 100644 --- a/runtimes/runtimes.go +++ b/runtimes/runtimes.go @@ -43,7 +43,6 @@ const ( PHP_FILE_EXTENSION = "php" ZIP_FILE_EXTENSION = "zip" RUBY_FILE_EXTENSION = "rb" - RUST_FILE_EXTENSION = "rs" GO_FILE_EXTENSION = "go" RUST_FILE_EXTENSION = "rs" NODEJS_RUNTIME = "nodejs" @@ -53,7 +52,6 @@ const ( DOTNET_RUNTIME = ZIP_FILE_EXTENSION PHP_RUNTIME = PHP_FILE_EXTENSION RUBY_RUNTIME = "ruby" - RUST_RUNTIME = "rust" GO_RUNTIME = GO_FILE_EXTENSION RUST_RUNTIME = "rust" HTTP_CONTENT_TYPE_KEY = "Content-Type"