This is an automated email from the ASF dual-hosted git repository. dgrove pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/openwhisk-runtime-nodejs.git
commit 2f03a589fae931ec5acfd8e0a704382c74a9a131 Author: David Grove <[email protected]> AuthorDate: Fri Apr 28 11:01:17 2023 -0400 drop typescript37 runtime 1. obsolete version of TypeScript 2. The base Node.js and OS versions long past EOL and not supported. --- .github/workflows/ci.yaml | 2 - .gitignore | 3 - core/typescript37Action/.dockerignore | 13 -- core/typescript37Action/Dockerfile | 80 ---------- core/typescript37Action/Makefile | 32 ---- core/typescript37Action/bin/compile | 162 --------------------- core/typescript37Action/build.gradle | 30 ---- core/typescript37Action/lib/launcher.ts | 100 ------------- settings.gradle | 2 - tests/dat/docker/typescript37docker/Dockerfile | 20 --- tests/dat/docker/typescript37docker/build.gradle | 19 --- .../actionContainers/Typescript37BasicTests.scala | 93 ------------ .../actionContainers/Typescript37CommonTests.scala | 29 ---- 13 files changed, 585 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 75f48bd..612fcb4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -92,8 +92,6 @@ jobs: ./gradlew :core:nodejs16Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=$SHORT_COMMIT ./gradlew :core:nodejs18Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=nightly ./gradlew :core:nodejs18Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=$SHORT_COMMIT - ./gradlew :core:typescript37Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=nightly - ./gradlew :core:typescript37Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=$SHORT_COMMIT - name: Push Release Images if: ${{ env.PUSH_RELEASE == 'true' }} working-directory: runtime diff --git a/.gitignore b/.gitignore index 0f904f2..d5aef40 100644 --- a/.gitignore +++ b/.gitignore @@ -17,9 +17,6 @@ results !/ansible/environments/local !/ansible/environments/mac -# actionloop action compiler script -!core/typescript37Action/bin/compile - # Eclipse bin/ **/.project diff --git a/core/typescript37Action/.dockerignore b/core/typescript37Action/.dockerignore deleted file mode 100644 index a1d03cb..0000000 --- a/core/typescript37Action/.dockerignore +++ /dev/null @@ -1,13 +0,0 @@ -*.*~ -*.yaml -*.tmpl -*.gradle -.dockerignore -.project -.settings -build.xml -Dockerfile -logs -node_modules -package-lock.json -test.js diff --git a/core/typescript37Action/Dockerfile b/core/typescript37Action/Dockerfile deleted file mode 100644 index 02ab73d..0000000 --- a/core/typescript37Action/Dockerfile +++ /dev/null @@ -1,80 +0,0 @@ -# -# 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. -# - -# build go proxy from source -FROM golang:1.15 AS builder_source -ARG GO_PROXY_GITHUB_USER=apache -ARG GO_PROXY_GITHUB_BRANCH=master -RUN git clone --branch ${GO_PROXY_GITHUB_BRANCH} \ - https://github.com/${GO_PROXY_GITHUB_USER}/openwhisk-runtime-go /src ;\ - cd /src ; env GO111MODULE=on CGO_ENABLED=0 go build main/proxy.go && \ - mv proxy /bin/proxy - -# or build it from a release -FROM golang:1.15 AS builder_release -ARG [email protected] -RUN curl -sL \ - https://github.com/apache/openwhisk-runtime-go/archive/{$GO_PROXY_RELEASE_VERSION}.tar.gz\ - | tar xzf -\ - && cd openwhisk-runtime-go-*/main\ - && GO111MODULE=on go build -o /bin/proxy - -FROM node:12.1.0-stretch - -# select the builder to use -ARG GO_PROXY_BUILD_FROM=release - -ENV TYPESCRIPT_VERSION=3.7.4 -ENV OW_COMPILER=/bin/compile -ENV OW_LOG_INIT_ERROR=1 -ENV OW_WAIT_FOR_ACK=1 -ENV OW_EXECUTION_ENV=openwhisk/typescript3.7 - -# Initial update and some basics. -# -RUN apt-get update && apt-get install -y \ - imagemagick \ - graphicsmagick \ - unzip \ - && rm -rf /var/lib/apt/lists/* &&\ - mkdir -p /app/action - -WORKDIR /proxy -COPY --from=builder_source /bin/proxy /bin/proxy_source -COPY --from=builder_release /bin/proxy /bin/proxy_release -RUN mv /bin/proxy_${GO_PROXY_BUILD_FROM} /bin/proxy - -# Add sources and copy the package.json to root container, -# so npm packages from user functions take precedence. -# -WORKDIR /app -COPY bin/compile /bin/compile -COPY lib/launcher.ts /lib/launcher.ts -COPY package.json / - -# Customize runtime with additional packages. -# -RUN cd / && npm install -g \ - yarn \ - typescript@${TYPESCRIPT_VERSION} \ - && npm install --no-package-lock --production @types/[email protected] \ - && npm install --no-package-lock --production \ - && npm cache clean --force - -EXPOSE 8080 - -ENTRYPOINT ["/bin/proxy"] diff --git a/core/typescript37Action/Makefile b/core/typescript37Action/Makefile deleted file mode 100644 index 373f831..0000000 --- a/core/typescript37Action/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# -# 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. -# -PREFIX=whisk -IMG=action-typescript-v3.7 - -start: - docker run -p 8080:8080 -ti -v $(PWD):/mnt $(IMG) - -debug: - docker run -p 8080:8080 -p 8081:8081 -ti --entrypoint=/bin/bash \ - -v $(PWD):/mnt -e OW_COMPILER=/mnt/bin/compile $(IMG) - -build: - docker build . -t $(IMG) - docker tag $(IMG) whisk/$(IMG) - docker images | grep $(IMG) - -.PHONY: start debug build diff --git a/core/typescript37Action/bin/compile b/core/typescript37Action/bin/compile deleted file mode 100755 index 2635459..0000000 --- a/core/typescript37Action/bin/compile +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/env node -/* - * 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. - */ - -const path = require("path") -const fs = require("fs") -const execFileSync = require('child_process').execFileSync; - -// write a file creating intermediate directories -function write_file(file, body, executable) { - fs.mkdirSync(path.dirname(file), { recursive: true }) - fs.writeFileSync(file, body) - if (executable) { - fs.chmodSync(file, 0755) - } -} - -// copy a file eventually replacing a substring -function copy_replace(src, dst, match, replacement) { - let body = fs.readFileSync(src, "utf-8") - if (match) { - body = body.replace(match, replacement) - } - write_file(dst, body) -} - -function deext(filename) { - const pos = filename.lastIndexOf(".") - filename = pos > -1 ? filename.substring(0, pos) : filename - return filename -} - -// resolve dependencies from package.json - return the main file -function dependencies(src_dir) { - const pkg_config = src_dir + "/package.json" - const node_modules = src_dir + "/node_modules" - if (fs.existsSync(pkg_config)) { - if (!fs.existsSync(node_modules)) { - execFileSync("yarn", [], { - "cwd": src_dir - }) - } - const config = JSON.parse(fs.readFileSync(pkg_config, "utf-8")) - if ("main" in config) { - return deext(config["main"]) - } - } - return "index" -} - -// assemble sources -function sources(launcher, main_file, main_func, src_dir) { - // init config - const src_config = src_dir + "/tsconfig.json" - const config = {} - if (fs.existsSync(src_config)) { - config = JSON.parse(fs.readFileSync(src_config, "utf-8")) - } - - if (!("files" in config)) { - config["files"] = [] - } - - if (!("compilerOptions" in config)) { - config["compilerOptions"] = {} - } - - config["compilerOptions"]["inlineSourceMap"] = true - - if ("sourceMap" in config["compilerOptions"]) { - delete config["compilerOptions"]["sourceMap"] - } - - if (!("outDir" in config["compilerOptions"])) { - config["compilerOptions"]["outDir"] = "." - } - - // copy main src file if any (and use it as main) - const src_file = src_dir + "/exec" - const tgt_file = src_dir + "/" + main_file + ".ts" - if (fs.existsSync(src_file) && !fs.existsSync(tgt_file)) { - const re = RegExp('(?<!export\\s+)function\\s+' + main_func) - copy_replace(src_file, tgt_file, re, "export function " + main_func) - config["files"].push(main_file + ".ts") - } - - // copy launcher and replace main - copy_replace(launcher, - src_dir + "/exec__.ts", - 'require("./main__").main', - 'require("./' + main_file + '").' + main_func) - - // complete tsconfig.json - config["files"].push("exec__.ts") - write_file(src_config, JSON.stringify(config)) -} - -function build(src_dir, bin_dir) { - try { - fs.rmdirSync(bin_dir) - fs.renameSync(src_dir, bin_dir) - execFileSync("tsc", [], { - cwd: bin_dir, - stdio: 'inherit', - stderr: 'inherit' - }) - write_file(bin_dir + "/exec", - '#!/bin/bash\n' + - 'if [ "$(cat $0.env)" != "$__OW_EXECUTION_ENV" ]\n' + - 'then cd "$(dirname $0)"\n' + - ' echo "Execution Environment Mismatch"\n' + - ' echo "Expected: $(cat $0.env)"\n' + - ' echo "Actual: $__OW_EXECUTION_ENV"\n' + - ' exit 1\n' + - 'fi\n' + - 'cd "$(dirname $0)"\n' + - 'if [ -z "$__OW_DEBUG_PORT" ]\n' + - 'then node exec__.js\n' + - 'else node --inspect=":$__OW_DEBUG_PORT" exec__.js\n' + - 'fi\n', true) - write_file(bin_dir + "/exec.env", process.env["__OW_EXECUTION_ENV"]) - } catch (err) { - console.log("syntax error:", err.message) - } -} - -function compile() { - if (process.argv.length < 4) { - console.log("usage: <main-function> <source-dir> <target-dir>") - process.exit(1) - } - const launcher = path.dirname(path.dirname(process.argv[1])) + "/lib/launcher.ts" - const src_dir = path.resolve(process.argv[3]) - const bin_dir = path.resolve(process.argv[4]) - let main_func = process.argv[2] - let main_file = dependencies(src_dir) - const pieces = main_func.split(".") - if (pieces.length > 1) { - main_file = pieces.shift() - main_func = pieces.join(".") - } - sources(launcher, main_file, main_func, src_dir) - build(src_dir, bin_dir) -} - -if (require.main === module) { - compile() -} diff --git a/core/typescript37Action/build.gradle b/core/typescript37Action/build.gradle deleted file mode 100644 index 1a17b56..0000000 --- a/core/typescript37Action/build.gradle +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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. - */ - -ext.dockerImageName = 'action-typescript-v3.7' -apply from: '../../gradle/docker.gradle' - -distDocker.dependsOn 'copyPackageJson' - -task copyPackageJson(type: Copy) { - from '../nodejsActionBase/package.json' - into '.' -} - -task cleanup(type: Delete) { - delete 'package.json' -} diff --git a/core/typescript37Action/lib/launcher.ts b/core/typescript37Action/lib/launcher.ts deleted file mode 100644 index 95b428d..0000000 --- a/core/typescript37Action/lib/launcher.ts +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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) - try { - result = await result - } catch (error) { - if (typeof error === 'undefined') { - error = {} - } - result = { "error": error } - } - } - out.write(JSON.stringify(result) + "\n"); - } catch (err) { - console.log(err); - let message = err.message || err.toString() - let error = { "error": message } - out.write(JSON.stringify(error) + "\n"); - } - } - } - actionLoop() -} catch (e) { - if (e.code == "MODULE_NOT_FOUND") { - console.log("zipped actions must contain either package.json or index.js at the root.") - } - console.log(e) - process.exit(1) -} diff --git a/settings.gradle b/settings.gradle index 43e6aad..a15000e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -20,10 +20,8 @@ include 'tests' include 'core:nodejsActionBase' include 'core:nodejs16Action' include 'core:nodejs18Action' -include 'core:typescript37Action' include 'tests:dat:docker:nodejs16docker' include 'tests:dat:docker:nodejs18docker' -include 'tests:dat:docker:typescript37docker' rootProject.name = 'runtime-nodejs' diff --git a/tests/dat/docker/typescript37docker/Dockerfile b/tests/dat/docker/typescript37docker/Dockerfile deleted file mode 100644 index b6b31ec..0000000 --- a/tests/dat/docker/typescript37docker/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -# -# 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 action-typescript-v3.7 -RUN cd /app && \ - npm add --save [email protected] && \ - npm install --production diff --git a/tests/dat/docker/typescript37docker/build.gradle b/tests/dat/docker/typescript37docker/build.gradle deleted file mode 100644 index 0d894ee..0000000 --- a/tests/dat/docker/typescript37docker/build.gradle +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 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. - */ - -ext.dockerImageName = 'typescript37docker' -apply from: '../../../../gradle/docker.gradle' diff --git a/tests/src/test/scala/runtime/actionContainers/Typescript37BasicTests.scala b/tests/src/test/scala/runtime/actionContainers/Typescript37BasicTests.scala deleted file mode 100644 index 4006cde..0000000 --- a/tests/src/test/scala/runtime/actionContainers/Typescript37BasicTests.scala +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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. - */ -package runtime.actionContainers - -import actionContainers.ActionContainer.withContainer -import actionContainers.{ActionContainer, BasicActionRunnerTests} -import common.WskActorSystem -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -class Typescript37BasicTests extends BasicActionRunnerTests with WskActorSystem { - - val image = "action-typescript-v3.7" - - override def withActionContainer(env: Map[String, String] = Map.empty)(code: ActionContainer => Unit) = { - withContainer(image, env)(code) - } - - def withActionLoopContainer(code: ActionContainer => Unit) = - withContainer(image)(code) - - behavior of image - - override val testNoSourceOrExec = TestConfig("") - - override val testNotReturningJson = - TestConfig(""" - |export function main(args) { - | return "not a json object" - |} - """.stripMargin) - - override val testEcho = TestConfig("""|export function main(args) { - | console.log("hello stdout") - | console.error("hello stderr") - | return args - |} - """.stripMargin) - - override val testUnicode = TestConfig("""|export function main(args) { - | let delimiter = args['delimiter'] - | let msg = delimiter+" ☃ "+delimiter - | console.log(msg) - | return { "winter": msg } - |} - """.stripMargin) - - override val testEnv = TestConfig("""|export function main(args) { - | let env = process.env - | return { - | "api_host": env["__OW_API_HOST"], - | "api_key": env["__OW_API_KEY"], - | "namespace": env["__OW_NAMESPACE"], - | "activation_id": env["__OW_ACTIVATION_ID"], - | "action_name": env["__OW_ACTION_NAME"], - | "deadline": env["__OW_DEADLINE"], - | "action_version": env["__OW_ACTION_VERSION"] - | } - |} - """.stripMargin) - - override val testInitCannotBeCalledMoreThanOnce = TestConfig(s"""|export function main(args) { - | return args - |} - """.stripMargin) - - override val testEntryPointOtherThanMain = TestConfig( - s"""|export function niam(args) { - | return args - |} - """.stripMargin, - main = "niam") - - override val testLargeInput = TestConfig(s"""|export function main(args) { - | return args - |} - """.stripMargin) -} diff --git a/tests/src/test/scala/runtime/actionContainers/Typescript37CommonTests.scala b/tests/src/test/scala/runtime/actionContainers/Typescript37CommonTests.scala deleted file mode 100644 index e39e246..0000000 --- a/tests/src/test/scala/runtime/actionContainers/Typescript37CommonTests.scala +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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. - */ - -package runtime.actionContainers - -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -class Typescript37CommonTests extends NodeJsNonConcurrentTests { - - override lazy val nodejsContainerImageName = "action-typescript-v3.7" - override lazy val nodejsTestDockerImageName = "typescript37docker" - override val isTypeScript = true -}
