Skip to content

Commit

Permalink
support new runtime custom.debian11 and python3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
mozhou52 committed Nov 13, 2024
1 parent 4f08173 commit ce6789c
Show file tree
Hide file tree
Showing 23 changed files with 180 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci_with_docker_linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ jobs:
- name: test local with nas
run: |
cd __tests__/e2e/local && sudo ./run && cd -
- name: test custom.debian11
run: |
cd __tests__/e2e/custom.debian11 && sudo ./run && cd -
5 changes: 4 additions & 1 deletion .github/workflows/ci_with_docker_macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,7 @@ jobs:
cd __tests__/e2e/custom-container && ./run && cd -
- name: test local with nas
run: |
cd __tests__/e2e/local && sudo ./run && cd -
cd __tests__/e2e/local && sudo ./run && cd -
- name: test custom.debian11
run: |
cd __tests__/e2e/custom.debian11 && ./run && cd -
2 changes: 1 addition & 1 deletion __tests__/complete-props.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ resources:
logstore: string
project: string
memorySize: 512
instanceConcurrency: 1 # 该参数仅针对 custom/custom.debian10/custom-container runtime 有效,范围为 [1, 100]
instanceConcurrency: 1 # 该参数仅针对 custom/custom.debian10/custom.debian11/custom-container runtime 有效,范围为 [1, 200]
nasConfig:
groupId: 65534
mountPoints:
Expand Down
2 changes: 2 additions & 0 deletions __tests__/e2e/custom.debian11/go/code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python
__pycache__
11 changes: 11 additions & 0 deletions __tests__/e2e/custom.debian11/go/code/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module example.com/m

go 1.17

require github.com/awesome-fc/golang-runtime v0.0.0-20230119040721-3f65ab4b97d3

require (
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 // indirect
golang.org/x/sys v0.4.0 // indirect
)
27 changes: 27 additions & 0 deletions __tests__/e2e/custom.debian11/go/code/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
github.com/awesome-fc/golang-runtime v0.0.0-20230119040721-3f65ab4b97d3 h1:d0/nCeQMEqCokk7qCx4kssYtdck2R5Pe6xQzptuKfO8=
github.com/awesome-fc/golang-runtime v0.0.0-20230119040721-3f65ab4b97d3/go.mod h1:W4bhz/v/p6E48AW5CH9j3kI1Xmp/fH/g6NNJXRvCtL4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 h1:J6v8awz+me+xeb/cUTotKgceAYouhIB3pjzgRd6IlGk=
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
27 changes: 27 additions & 0 deletions __tests__/e2e/custom.debian11/go/code/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package main

import (
"encoding/json"

gr "github.com/awesome-fc/golang-runtime"
)

func initialize(ctx *gr.FCContext) error {
ctx.GetLogger().Infoln("init golang!")
return nil
}

func handler(ctx *gr.FCContext, event []byte) ([]byte, error) {
fcLogger := ctx.GetLogger()
_, err := json.Marshal(ctx)
if err != nil {
fcLogger.Error("error:", err)
}
fcLogger.Infof("hello golang!")
fcLogger.Infof("hello golang2!")
return event, nil
}

func main() {
gr.Start(handler, initialize)
}
29 changes: 29 additions & 0 deletions __tests__/e2e/custom.debian11/go/s.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
edition: 3.0.0
name: test-custom-debian11-go
access: quanxi

vars:
region: ${env('REGION', 'cn-huhehaote')}

resources:
fcDemo:
component: ${env('fc_component_version', path('../../../../'))}
actions:
pre-deploy:
- run: go mod tidy
path: ./code
- run: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o target/main main.go
path: ./code
props:
region: ${vars.region}
functionName: fc3-event-debian11-${env('fc_component_function_name', 'go1')}
description: 'hello world by serverless devs'
timeout: 30
memorySize: 512
cpu: 0.5
diskSize: 512
runtime: custom.debian11
code: ./code/target
customRuntimeConfig:
command:
- '/code/main'
14 changes: 14 additions & 0 deletions __tests__/e2e/custom.debian11/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -e

echo "test custom.debian11 go runtime ..."
rm -rf ./go/code/go.sum
export fc_component_function_name=go1-$(uname)-$(uname -m)
s deploy -y -t ./go/s.yaml
s invoke -e '{"hello":"fc custom.debian11 go"}' -t ./go/s.yaml
s local invoke -e '{"hello":"fc custom.debian11 go"}' -t ./go/s.yaml
s info -t ./go/s.yaml
s remove -y -t ./go/s.yaml
rm -rf ./go/code/target

1 change: 0 additions & 1 deletion __tests__/e2e/python/code/index.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
import subprocess
import fc2
from bs4 import BeautifulSoup
import logging
import flask
Expand Down
10 changes: 10 additions & 0 deletions __tests__/e2e/python/run
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ s info
s invoke -e '{"hello":"fc python3"}'
s remove -y

export fc_component_runtime=python3.12
export fc_component_function_name=python312-$(uname)-$(uname -m)
rm -rf ./code/python
echo "test python3.12 runtime ..."
s build
s local invoke -e '{"hello":"fc python3.12"}'
s deploy -y
s invoke -e '{"hello":"fc python3.12"}'
s remove -y

export fc_component_runtime=python3.10
export fc_component_function_name=python310-$(uname)-$(uname -m)
rm -rf ./code/python
Expand Down
9 changes: 9 additions & 0 deletions __tests__/e2e/python/run-windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ s info
s invoke -e '{"hello":"fc python3"}'
s remove -y

$env:fc_component_runtime = "python3.12"
$env:fc_component_function_name = "python312-$($env:OS)-$($env:PROCESSOR_ARCHITECTURE)"
Remove-Item -Recurse -Force ./code/python -ErrorAction SilentlyContinue
Write-Host "test python3.12 runtime ..."
s build
s local invoke -e '{"hello":"fc python3.12"}'
s deploy -y
s invoke -e '{"hello":"fc python3.12"}'
s remove -y

$env:fc_component_runtime = "python3.10"
$env:fc_component_function_name = "python310-$($env:OS)-$($env:PROCESSOR_ARCHITECTURE)"
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@alicloud/pop-core": "^1.7.13",
"@serverless-cd/srm-aliyun-pop-core": "^0.0.7-beta.16",
"@serverless-cd/srm-aliyun-ram20150501": "^0.0.2-beta.9",
"@serverless-cd/srm-aliyun-sls20201230": "0.0.4-beta.1",
"@serverless-cd/srm-aliyun-sls20201230": "0.0.5-beta.3",
"@serverless-devs/diff": "^0.0.3-beta.6",
"@serverless-devs/downloads": "^0.0.6",
"@serverless-devs/load-component": "^0.0.8",
Expand Down
2 changes: 2 additions & 0 deletions publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ Parameters:
- python3
- python3.9
- python3.10
- python3.12
- php7.2
- java8
- java11
- dotnetcore3.1
- custom
- custom.debian10
- custom.debian11
- custom-container

code:
Expand Down
2 changes: 2 additions & 0 deletions src/interface/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export enum Runtime {
'nodejs16' = 'nodejs16',
'nodejs18' = 'nodejs18',
'nodejs20' = 'nodejs20',
'python3.12' = 'python3.12',
'python3.10' = 'python3.10',
'python3.9' = 'python3.9',
'python3' = 'python3',
Expand All @@ -35,6 +36,7 @@ export enum Runtime {
'dotnetcore3.1' = 'dotnetcore3.1',
'dotnetcore2.1' = 'dotnetcore2.1',
'custom.debian10' = 'custom.debian10',
'custom.debian11' = 'custom.debian11',
'custom' = 'custom',
'custom-container' = 'custom-container',
}
Expand Down
6 changes: 5 additions & 1 deletion src/resources/fc/impl/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export function isCustomContainerRuntime(runtime: string): boolean {
}

export function isCustomRuntime(runtime: string): boolean {
return runtime === Runtime.custom || runtime === Runtime['custom.debian10'];
return (
runtime === Runtime.custom ||
runtime === Runtime['custom.debian10'] ||
runtime === Runtime['custom.debian11']
);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@
"custom",
"custom-container",
"custom.debian10",
"custom.debian11",
"dotnetcore2.1",
"dotnetcore3.1",
"go1",
Expand All @@ -824,7 +825,8 @@
"python2.7",
"python3",
"python3.10",
"python3.9"
"python3.9",
"python3.12"
],
"type": "string"
},
Expand Down
6 changes: 5 additions & 1 deletion src/subCommands/build/impl/baseBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ export abstract class Builder {
if (runtime === 'python3') {
runtime = 'python3.6';
}
image = `${fcDockerVersionRegistry}/${fcDockerNameSpace}/runtime-${runtime}:build-${fcDockerVersion}`;
if (runtime === 'python3.12' || runtime === 'custom.debian11') {
image = `${fcDockerVersionRegistry}/${fcDockerNameSpace}/runtime:${runtime}-build-${fcDockerVersion}`;
} else {
image = `${fcDockerVersionRegistry}/${fcDockerNameSpace}/runtime-${runtime}:build-${fcDockerVersion}`;
}
logger.debug(`use fc docker image: ${image}`);
await runCommand(`docker pull ${image}`, runCommand.showStdout.inherit);
}
Expand Down
2 changes: 2 additions & 0 deletions src/subCommands/build/impl/defaultBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ vendor`;
case 'python3':
case 'python3.9':
case 'python3.10':
case 'python3.12':
if (this.existManifest('requirements.txt')) {
tasks.push(
`pip install -t ${buildPythonLocalPath} -r requirements.txt --upgrade ${customArgs}`,
Expand All @@ -258,6 +259,7 @@ vendor`;
break;
case 'custom':
case 'custom.debian10':
case 'custom.debian11':
if (this.existManifest('requirements.txt')) {
tasks.push(
`pip install -t ${buildPythonLocalPath} -r requirements.txt --upgrade ${customArgs}`,
Expand Down
1 change: 0 additions & 1 deletion src/subCommands/deploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { verify } from '../../utils';
import { IInputs } from '../../interface';
import Info from '../info/index';
import { GetApiType } from '../../resources/fc';
import _ from 'lodash';

export default class Deploy {
readonly opts: Record<string, any>;
Expand Down
11 changes: 8 additions & 3 deletions src/subCommands/local/impl/baseLocal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,11 @@ export class BaseLocal {
if (runtime === 'python3') {
runtime = 'python3.6';
}
image = `${fcDockerVersionRegistry}/${fcDockerNameSpace}/runtime-${runtime}:${fcDockerVersion}`;
if (runtime === 'python3.12' || runtime === 'custom.debian11') {
image = `${fcDockerVersionRegistry}/${fcDockerNameSpace}/runtime:${runtime}-${fcDockerVersion}`;
} else {
image = `${fcDockerVersionRegistry}/${fcDockerNameSpace}/runtime-${runtime}:${fcDockerVersion}`;
}
logger.debug(`use fc docker image: ${image}`);
await runCommand(`docker pull ${image}`, runCommand.showStdout.inherit);
}
Expand Down Expand Up @@ -349,7 +353,8 @@ export class BaseLocal {
}
case 'python3':
case 'python3.9':
case 'python3.10': {
case 'python3.10':
case 'python3.12': {
return JSON.stringify(
{
version: '0.2.0',
Expand Down Expand Up @@ -453,7 +458,6 @@ export class BaseLocal {
return false;
}
// TODO check if runtime support breakpoint debugging

if (!this.canSupportDebug(this.getRuntime()) && _.isFinite(this.getDebugPort())) {
logger.error(`breakpoint debugging is not support in ${this.getRuntime()} runtime`);
return false;
Expand Down Expand Up @@ -503,6 +507,7 @@ export class BaseLocal {
'python3',
'python3.9',
'python3.10',
'python3.12',
'java8',
'java11',
'php7.2',
Expand Down
Loading

0 comments on commit ce6789c

Please sign in to comment.