Skip to content

Commit

Permalink
nodejs and python with tests published
Browse files Browse the repository at this point in the history
  • Loading branch information
msciabarra committed Feb 21, 2024
1 parent 63592e7 commit d555cd6
Show file tree
Hide file tree
Showing 20 changed files with 29 additions and 15 deletions.
10 changes: 9 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ tasks:
RUNTIME="{{.BASEIMG}}/runtime-{{.RT}}-{{.VER}}:{{.TAG}}"
if test -n "{{.PUSH}}"
then {{.DRY}} docker buildx build -t "$RUNTIME" --build-arg COMMON="{{.COMMON}}" --platform linux/amd64,linux/arm64 . --push
else {{.DRY}} docker buildx build -t "$RUNTIME" --build-arg COMMON="{{.COMMON}}" . --load
else {{.DRY}} docker buildx build -t "$RUNTIME" --build-arg COMMON="{{.COMMON}}" . --push
fi
echo "Built $RUNTIME"
Expand All @@ -76,6 +76,7 @@ tasks:
- task: docker-login
- task build-lang RT=golang
- task build-lang RT=python
- task build-lang RT=nodejs

run-runtime:
requires: { vars: [RT, VER] }
Expand All @@ -99,3 +100,10 @@ tasks:
desc: run a command, provide a jons with '-- <json-payload>'
cmds:
- nuv ide run J={{.CLI_ARGS}}

test-runtime:
requires: { vars: [RT, VER] }
dir: "runtime/{{.RT}}/{{.VER}}"
cmds:
- docker run -p 8080:8080 -d --name=test-runtime "{{.BASEIMG}}/runtime-{{.RT}}-{{.VER}}:{{.TAG}}"
- nuv init A={{.RT}}/{{.ITEM}}
3 changes: 2 additions & 1 deletion packages/nodejs/hello.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//--web true
//--kind nodejs:default
//--docker ghcr.io/nuvolaris/runtime-nodejs-v21:3.1.0-mastrogpt.2402201748

function main(args) {
let name = args.name || "world"
return { body: `Hello, ${name}` }
}

8 changes: 4 additions & 4 deletions packages/nodejs/multifile/hello.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function hello() {
return "hello world"
function hello(args) {
let name = args.name || "world".
return `Hello, ${name}.`
}

module.exports = hello

module.exports = hello
5 changes: 3 additions & 2 deletions packages/nodejs/multifile/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//--web true
//--kind nodejs:default
//--docker ghcr.io/nuvolaris/runtime-nodejs-v21:3.1.0-mastrogpt.2402201748


const hello = require("./hello")

Expand All @@ -9,4 +10,4 @@ function main(args) {
}
}

module.exports = main
module.exports = main
6 changes: 4 additions & 2 deletions packages/nodejs/withreqs/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//--web true
//--kind nodejs:default
//--docker ghcr.io/nuvolaris/runtime-nodejs-v21:3.1.0-mastrogpt.2402201748


const marked = require("marked");

function main(args) {
let text = `# Welcome\n\nHello, *world*.`
let name = args.name || "world".
let text = `# Welcome\n\nHello, ${name}.`
return {
body: marked.parse(text)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/python/multifile/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

def main(args):
return {
"body": hello.hello()
"body": hello.hello(args)
}
5 changes: 3 additions & 2 deletions packages/python/multifile/hello.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
def hello():
return "hello world"
def hello(args):
name = args.get("name", "world")
return "Hello, f{name}."
3 changes: 2 additions & 1 deletion packages/python/withreqs/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import htmlgenerator as hg

def main(args):
page = hg.HTML(hg.HEAD(), hg.BODY(hg.H1("Hello, world")))
name = args.get("name", "world")
page = hg.HTML(hg.HEAD(), hg.BODY(hg.H1(f"Hello, {name}.")))
return {
"body": hg.render(page, {})
}
2 changes: 1 addition & 1 deletion runtime/python/v3.12/requirements_common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ scrapy==2.5.0
simplejson==3.17.5
twisted==21.7.0
netifaces==0.11.0
pyyaml==6.0
pyyaml==6.0.1
redis==4.4.2
boto3==1.28.25
psycopg==3.1.10
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit d555cd6

Please sign in to comment.