You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2020/02/13 14:15:37 UTC

[GitHub] [openwhisk-runtime-nodejs] sciabarra opened a new pull request #160: Actionloop based runtime for Typescript

sciabarra opened a new pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160
 
 
   Implemented support for typescript using actionloop and its compilation ability.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r379831894
 
 

 ##########
 File path: tests/src/test/scala/runtime/actionContainers/NodeJsNonConcurrentTests.scala
 ##########
 @@ -27,9 +27,10 @@ abstract class NodeJsNonConcurrentTests extends NodeJsActionContainerTests {
     withActionContainer()(code)
 
   it should "NOT allow running activations concurrently (without proper env setup)" in {
-    val (out, err) = withNodeJsContainer { c =>
-      //this action will create a log entry, and only complete after 1s, to guarantee previous is still running
-      val code = """
+    if (!isTypeScript) {
 
 Review comment:
   you can move this check out to wrap the test itself: 
   
   If (...) { it(...)...}

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] sciabarra commented on a change in pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
sciabarra commented on a change in pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r382470328
 
 

 ##########
 File path: core/typescript37Action/lib/launcher.ts
 ##########
 @@ -0,0 +1,101 @@
+/*
+#
+# 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.
+#
+*/
+try {
+const main = require("./main__").main
+const readline = require('readline');
+const fs = require("fs")
+const os = require("os")
+
+function vscodeDebug() {
+  let ifaces = os.networkInterfaces()
+  for(let iface of Object.keys(ifaces)) {
+    for(let ip of ifaces[iface]) {
+      if(!ip.internal) {
+        return {
+          "type": "node",
+          "request": "attach",
+          "name": process.env["__OW_ACTION_NAME"],
+          "address": ip.address,
+          "port": 8081,
+          "localRoot": "${workspaceFolder}",
+          "remoteRoot": __dirname
+        }
+      }
+    }
+  }
+  return {"error": "cannot find external interface"}
+}
+
+async function actionLoop() {
+  const out = fs.createWriteStream(null,
+    { fd: 3, encoding: "utf8" })
+    process.stdin.setEncoding('utf8');
+  const rl = readline.createInterface({
+    input: process.stdin
+  });
+  const debugging = "__OW_DEBUG_PORT" in process.env
+  out.write(JSON.stringify({"ok":true})+"\n");
+  for await (const line of rl) {
+    try {
+      let args = JSON.parse(line)
+      let value = args.value || {}
+      for (let key in args) {
+          if(key !== "value") {
+            let envar = "__OW_"+key.toUpperCase()
+            process.env[envar] = args[key]
+          }
+      }
+      let result = {}
+      if(debugging && "debugWith" in value) {
+        if(value["debugWith"]==="vscode")
+          result = vscodeDebug()
+        else
+          result = {"error": "requested unknown debugger"}
+      } else {
+        result = main(value)
+        if(typeof result === 'undefined') {
+          result = {}
+        }
+        if(Promise.resolve(result) == result) 
 
 Review comment:
   Promise.resolve(result) == result IS a check that is a promise and it is the recommended way according stack overflow:  https://stackoverflow.com/questions/27746304/how-do-i-tell-if-an-object-is-a-promise

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r382264917
 
 

 ##########
 File path: core/typescript37Action/lib/launcher.ts
 ##########
 @@ -0,0 +1,101 @@
+/*
+#
+# 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.
+#
+*/
+try {
+const main = require("./main__").main
+const readline = require('readline');
+const fs = require("fs")
+const os = require("os")
+
+function vscodeDebug() {
+  let ifaces = os.networkInterfaces()
+  for(let iface of Object.keys(ifaces)) {
+    for(let ip of ifaces[iface]) {
+      if(!ip.internal) {
+        return {
+          "type": "node",
+          "request": "attach",
+          "name": process.env["__OW_ACTION_NAME"],
+          "address": ip.address,
+          "port": 8081,
+          "localRoot": "${workspaceFolder}",
+          "remoteRoot": __dirname
+        }
+      }
+    }
+  }
+  return {"error": "cannot find external interface"}
+}
+
+async function actionLoop() {
+  const out = fs.createWriteStream(null,
+    { fd: 3, encoding: "utf8" })
+    process.stdin.setEncoding('utf8');
+  const rl = readline.createInterface({
+    input: process.stdin
+  });
+  const debugging = "__OW_DEBUG_PORT" in process.env
+  out.write(JSON.stringify({"ok":true})+"\n");
+  for await (const line of rl) {
+    try {
+      let args = JSON.parse(line)
+      let value = args.value || {}
+      for (let key in args) {
+          if(key !== "value") {
+            let envar = "__OW_"+key.toUpperCase()
+            process.env[envar] = args[key]
+          }
+      }
+      let result = {}
+      if(debugging && "debugWith" in value) {
+        if(value["debugWith"]==="vscode")
+          result = vscodeDebug()
+        else
+          result = {"error": "requested unknown debugger"}
+      } else {
+        result = main(value)
+        if(typeof result === 'undefined') {
+          result = {}
+        }
+        if(Promise.resolve(result) == result) 
 
 Review comment:
   so this is a check that `result` is a `Promise`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r379831475
 
 

 ##########
 File path: core/typescript37Action/invoke.py
 ##########
 @@ -0,0 +1,135 @@
+#!/usr/bin/env python
+"""Executable Python script for testing the action proxy.
+/*
+ * 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.
+ */
+
+  This script is useful for testing the action proxy (or its derivatives)
+  by simulating invoker interactions. Use it in combination with
+  docker run <image> which starts up the action proxy.
+  Example:
+     docker run -i -t -p 8080:8080 dockerskeleton # locally built images may be referenced without a tag
+     ./invoke.py init <action source file>
+     ./invoke.py run '{"some":"json object as a string"}'
+
+  For additional help, try ./invoke.py -h
+"""
+
 
 Review comment:
   I know many of the runtimes have a copy of this file. They’re likely not all in sync with enhancements made from the canonical version. Perhaps this should later be removed systematically and replaced with a fetch from the openwhisk repo. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] rabbah commented on issue #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
rabbah commented on issue #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#issuecomment-588250579
 
 
   @sciabarra please resolve conflict and my last few comments above.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r382262632
 
 

 ##########
 File path: tests/src/test/scala/runtime/actionContainers/NodeJsActionContainerTests.scala
 ##########
 @@ -176,7 +177,10 @@ abstract class NodeJsActionContainerTests extends BasicActionRunnerTests with Ws
       initCode should be(200)
 
       val (runCode, runRes) = c.run(runPayload(JsObject()))
-      runCode should not be (200)
+      // actionloop proxy does not return a different error code when there is an error,
+      // because it communicates only through json
 
 Review comment:
   i dont understand this comment - communicates with the HTTP caller? so the status code is always 200 from the proxy?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r382263012
 
 

 ##########
 File path: tests/src/test/scala/runtime/actionContainers/NodeJsActionContainerTests.scala
 ##########
 @@ -293,18 +297,21 @@ abstract class NodeJsActionContainerTests extends BasicActionRunnerTests with Ws
           | }
         """.stripMargin
 
-      c.init(initPayload(code))._1 should be(200)
-
-      val (runCode, result) = c.run(runPayload(JsObject("payload" -> JsString("test"))))
-      runCode should be(200)
-      result should be(Some(JsObject("payload" -> JsString("hello, test!"))))
+      if (isTypeScript)
+        c.init(initPayload(code))._1 should be(502)
+      else {
+        c.init(initPayload(code))._1 should be(200)
+        val (runCode, result) = c.run(runPayload(JsObject("payload" -> JsString("test"))))
+        runCode should be(200)
+        result should be(Some(JsObject("payload" -> JsString("hello, test!"))))
+      }
     }
-
-    checkStreams(out, err, {
-      case (o, e) =>
-        o shouldBe "hello, test!"
-        e shouldBe empty
-    })
+    if (!isTypeScript)
+      checkStreams(out, err, {
+        case (o, e) =>
+          o shouldBe "hello, test!"
+          e shouldBe empty
+      })
 
 Review comment:
   ```suggestion
         })
       }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r382263059
 
 

 ##########
 File path: tests/src/test/scala/runtime/actionContainers/NodeJsActionContainerTests.scala
 ##########
 @@ -293,18 +297,21 @@ abstract class NodeJsActionContainerTests extends BasicActionRunnerTests with Ws
           | }
         """.stripMargin
 
-      c.init(initPayload(code))._1 should be(200)
-
-      val (runCode, result) = c.run(runPayload(JsObject("payload" -> JsString("test"))))
-      runCode should be(200)
-      result should be(Some(JsObject("payload" -> JsString("hello, test!"))))
+      if (isTypeScript)
+        c.init(initPayload(code))._1 should be(502)
+      else {
+        c.init(initPayload(code))._1 should be(200)
+        val (runCode, result) = c.run(runPayload(JsObject("payload" -> JsString("test"))))
+        runCode should be(200)
+        result should be(Some(JsObject("payload" -> JsString("hello, test!"))))
+      }
     }
-
-    checkStreams(out, err, {
-      case (o, e) =>
-        o shouldBe "hello, test!"
-        e shouldBe empty
-    })
+    if (!isTypeScript)
 
 Review comment:
   ```suggestion
       if (!isTypeScript) {
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] sciabarra commented on a change in pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
sciabarra commented on a change in pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r382469500
 
 

 ##########
 File path: tests/src/test/scala/runtime/actionContainers/NodeJsActionContainerTests.scala
 ##########
 @@ -176,7 +177,10 @@ abstract class NodeJsActionContainerTests extends BasicActionRunnerTests with Ws
       initCode should be(200)
 
       val (runCode, runRes) = c.run(runPayload(JsObject()))
-      runCode should not be (200)
+      // actionloop proxy does not return a different error code when there is an error,
+      // because it communicates only through json
 
 Review comment:
   yes it is and it is a long standing "issue", but it is not really an issue since the controller sets a different error code if the body is "error". Already discussed a few times.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] sciabarra commented on issue #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
sciabarra commented on issue #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#issuecomment-588286460
 
 
   Ok....

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r379831375
 
 

 ##########
 File path: core/typescript37Action/Dockerfile
 ##########
 @@ -0,0 +1,68 @@
+#
+# 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.
+#
+FROM golang:1.12 as builder
+#RUN env CGO_ENABLED=0 go get github.com/apache/openwhisk-runtime-go/main \
+#    && mv /go/bin/main /bin/proxy
+RUN git clone --branch ack-and-versioning \
+   https://github.com/nimbella-corp/openwhisk-runtime-go /src ;\
+   cd /src ; env GO111MODULE=on CGO_ENABLED=0 go build main/proxy.go && \
+   mv proxy /bin/proxy
+FROM node:12.1.0-stretch
+ENV TYPESCRIPT_VERSION=3.7.4
+COPY --from=builder /bin/proxy /bin/proxy
+RUN apt-get update && apt-get install -y \
+    imagemagick \
+    graphicsmagick \
+    unzip \
+    wget \
+    && rm -rf /var/lib/apt/lists/* &&\
+    mkdir -p /app/action
+RUN cd /app ;\
+  npm install -g yarn ;\
+  npm install -g typescript@${TYPESCRIPT_VERSION} ;\
+  echo '{"private":true}' >package.json ;\
+  npm install --save --no-package-lock --production \
+  axios@0.19.0 \
+  async@2.6.1 \
+  aws-sdk@2.401.0 \
+  bluebird@3.5.3 \
+  body-parser@1.18.3 \
+  btoa@1.2.1 \
+  gm@1.23.1 \
+  @google-cloud/datastore@4.4.1 \
+  @google-cloud/storage@4.0.1 \
+  nano@8.0.0 \
+  redis@2.8.0 \
+  tmp@0.0.31 \
+  twilio@3.28.0 \
+  uuid@3.0.0 \
+  openwhisk@3.18.0 \
+  && npm cache clean --force
+WORKDIR /app
+
+EXPOSE 8080
+
+ARG __LAMBDA_COMPAT
+ENV __LAMBDA_COMPAT=$__LAMBDA_COMPAT
 
 Review comment:
   Remove these. I don’t think you’re using them here. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] rabbah commented on issue #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
rabbah commented on issue #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#issuecomment-586267110
 
 
   one day you'll set up scancode locally on your git commit hooks 😅 ?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r379831732
 
 

 ##########
 File path: tests/src/test/scala/runtime/actionContainers/NodeJsActionContainerTests.scala
 ##########
 @@ -88,6 +89,7 @@ abstract class NodeJsActionContainerTests extends BasicActionRunnerTests with Ws
       """.stripMargin.trim)
   }
 
+  /* TODO:
   override val testEnvParameters = {
 
 Review comment:
   Why is this commented out?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r379831680
 
 

 ##########
 File path: core/typescript37Action/lib/launcher.ts
 ##########
 @@ -0,0 +1,101 @@
+/*
+#
+# 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.
+#
+*/
+try {
+const main = require("./main__").main
+const readline = require('readline');
+const fs = require("fs")
+const os = require("os")
+
+function vscodeDebug() {
+  let ifaces = os.networkInterfaces()
+  for(let iface of Object.keys(ifaces)) {
+    for(let ip of ifaces[iface]) {
+      if(!ip.internal) {
+        return {
+          "type": "node",
+          "request": "attach",
+          "name": process.env["__OW_ACTION_NAME"],
+          "address": ip.address,
+          "port": 8081,
+          "localRoot": "${workspaceFolder}",
+          "remoteRoot": __dirname
+        }
+      }
+    }
+  }
+  return {"error": "cannot find external interface"}
+}
+
+async function actionLoop() {
+  const out = fs.createWriteStream(null,
+    { fd: 3, encoding: "utf8" })
+    process.stdin.setEncoding('utf8');
+  const rl = readline.createInterface({
+    input: process.stdin
+  });
+  const debugging = "__OW_DEBUG_PORT" in process.env
+  out.write(JSON.stringify({"ok":true})+"\n");
+  for await (const line of rl) {
+    try {
+      let args = JSON.parse(line)
+      let value = args.value || {}
+      for (let key in args) {
+          if(key !== "value") {
+            let envar = "__OW_"+key.toUpperCase()
+            process.env[envar] = args[key]
+          }
+      }
+      let result = {}
+      if(debugging && "debugWith" in value) {
+        if(value["debugWith"]==="vscode")
+          result = vscodeDebug()
+        else
+          result = {"error": "requested unknown debugger"}
+      } else {
+        result = main(value)
+        if(typeof result === 'undefined') {
+          result = {}
+        }
+        if(Promise.resolve(result) == result) 
 
 Review comment:
   I don’t understand this test. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] sciabarra commented on a change in pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
sciabarra commented on a change in pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r382171480
 
 

 ##########
 File path: tests/src/test/scala/runtime/actionContainers/NodeJsActionContainerTests.scala
 ##########
 @@ -293,18 +296,21 @@ abstract class NodeJsActionContainerTests extends BasicActionRunnerTests with Ws
           | }
         """.stripMargin
 
-      c.init(initPayload(code))._1 should be(200)
-
-      val (runCode, result) = c.run(runPayload(JsObject("payload" -> JsString("test"))))
-      runCode should be(200)
-      result should be(Some(JsObject("payload" -> JsString("hello, test!"))))
+      if (isTypeScript)
+        c.init(initPayload(code))._1 should be(502)
+      else {
+        c.init(initPayload(code))._1 should be(200)
+        val (runCode, result) = c.run(runPayload(JsObject("payload" -> JsString("test"))))
+        runCode should be(200)
+        result should be(Some(JsObject("payload" -> JsString("hello, test!"))))
+      }
     }
-
-    checkStreams(out, err, {
-      case (o, e) =>
-        o shouldBe "hello, test!"
-        e shouldBe empty
-    })
 
 Review comment:
   I do not understand...

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] sciabarracom merged pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
sciabarracom merged pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r379831842
 
 

 ##########
 File path: tests/src/test/scala/runtime/actionContainers/NodeJsActionContainerTests.scala
 ##########
 @@ -293,18 +296,21 @@ abstract class NodeJsActionContainerTests extends BasicActionRunnerTests with Ws
           | }
         """.stripMargin
 
-      c.init(initPayload(code))._1 should be(200)
-
-      val (runCode, result) = c.run(runPayload(JsObject("payload" -> JsString("test"))))
-      runCode should be(200)
-      result should be(Some(JsObject("payload" -> JsString("hello, test!"))))
+      if (isTypeScript)
+        c.init(initPayload(code))._1 should be(502)
+      else {
+        c.init(initPayload(code))._1 should be(200)
+        val (runCode, result) = c.run(runPayload(JsObject("payload" -> JsString("test"))))
+        runCode should be(200)
+        result should be(Some(JsObject("payload" -> JsString("hello, test!"))))
+      }
     }
-
-    checkStreams(out, err, {
-      case (o, e) =>
-        o shouldBe "hello, test!"
-        e shouldBe empty
-    })
 
 Review comment:
   Use {} for consistency. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] sciabarra commented on a change in pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
sciabarra commented on a change in pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r382168758
 
 

 ##########
 File path: core/typescript37Action/lib/launcher.ts
 ##########
 @@ -0,0 +1,101 @@
+/*
+#
+# 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.
+#
+*/
+try {
+const main = require("./main__").main
+const readline = require('readline');
+const fs = require("fs")
+const os = require("os")
+
+function vscodeDebug() {
+  let ifaces = os.networkInterfaces()
+  for(let iface of Object.keys(ifaces)) {
+    for(let ip of ifaces[iface]) {
+      if(!ip.internal) {
+        return {
+          "type": "node",
+          "request": "attach",
+          "name": process.env["__OW_ACTION_NAME"],
+          "address": ip.address,
+          "port": 8081,
+          "localRoot": "${workspaceFolder}",
+          "remoteRoot": __dirname
+        }
+      }
+    }
+  }
+  return {"error": "cannot find external interface"}
+}
+
+async function actionLoop() {
+  const out = fs.createWriteStream(null,
+    { fd: 3, encoding: "utf8" })
+    process.stdin.setEncoding('utf8');
+  const rl = readline.createInterface({
+    input: process.stdin
+  });
+  const debugging = "__OW_DEBUG_PORT" in process.env
+  out.write(JSON.stringify({"ok":true})+"\n");
+  for await (const line of rl) {
+    try {
+      let args = JSON.parse(line)
+      let value = args.value || {}
+      for (let key in args) {
+          if(key !== "value") {
+            let envar = "__OW_"+key.toUpperCase()
+            process.env[envar] = args[key]
+          }
+      }
+      let result = {}
+      if(debugging && "debugWith" in value) {
+        if(value["debugWith"]==="vscode")
+          result = vscodeDebug()
+        else
+          result = {"error": "requested unknown debugger"}
+      } else {
+        result = main(value)
+        if(typeof result === 'undefined') {
+          result = {}
+        }
+        if(Promise.resolve(result) == result) 
 
 Review comment:
   Some tests assume undefined mean `{}`, you told me it is to support 'function main() { console.log("hello") }` where you do not provide any answer so I had to add this.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r382263521
 
 

 ##########
 File path: tests/src/test/scala/runtime/actionContainers/NodeJsActionContainerTests.scala
 ##########
 @@ -638,7 +656,7 @@ abstract class NodeJsActionContainerTests extends BasicActionRunnerTests with Ws
         """,
       Seq("other.js") ->
         """
-          | exports.niam = function (args) {
+          |exports.niam = function (args) {
 
 Review comment:
   ```suggestion
             | exports.niam = function (args) {
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] sciabarra commented on issue #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
sciabarra commented on issue #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#issuecomment-589229609
 
 
   > one day you'll set up scancode locally on your git commit hooks 😅 ?
   
   The problem is that I have thousand of copies and I remove and clone all the time and I always forget to setup the hook

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r382261866
 
 

 ##########
 File path: settings.gradle
 ##########
 @@ -21,9 +21,12 @@ include 'core:nodejsActionBase'
 include 'core:nodejs8Action'
 include 'core:nodejs10Action'
 include 'core:nodejs12Action'
+include 'core:typescript37Action'
+include 'tests:dat:docker:nodejs6docker'
 
 Review comment:
   bad merge?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] sciabarra commented on a change in pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
sciabarra commented on a change in pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r382168917
 
 

 ##########
 File path: tests/src/test/scala/runtime/actionContainers/NodeJsActionContainerTests.scala
 ##########
 @@ -88,6 +89,7 @@ abstract class NodeJsActionContainerTests extends BasicActionRunnerTests with Ws
       """.stripMargin.trim)
   }
 
+  /* TODO:
   override val testEnvParameters = {
 
 Review comment:
   Because it does not work :D 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [openwhisk-runtime-nodejs] rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript

Posted by GitBox <gi...@apache.org>.
rabbah commented on a change in pull request #160: Actionloop based runtime for Typescript
URL: https://github.com/apache/openwhisk-runtime-nodejs/pull/160#discussion_r379831837
 
 

 ##########
 File path: tests/src/test/scala/runtime/actionContainers/NodeJsActionContainerTests.scala
 ##########
 @@ -293,18 +296,21 @@ abstract class NodeJsActionContainerTests extends BasicActionRunnerTests with Ws
           | }
         """.stripMargin
 
-      c.init(initPayload(code))._1 should be(200)
-
-      val (runCode, result) = c.run(runPayload(JsObject("payload" -> JsString("test"))))
-      runCode should be(200)
-      result should be(Some(JsObject("payload" -> JsString("hello, test!"))))
+      if (isTypeScript)
+        c.init(initPayload(code))._1 should be(502)
 
 Review comment:
   A comment as to why this is different will be helpful. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services