diff --git a/.github/workflows/ci_with_docker_linux.yaml b/.github/workflows/ci_with_docker_linux.yaml index d046b79..7d1efe1 100644 --- a/.github/workflows/ci_with_docker_linux.yaml +++ b/.github/workflows/ci_with_docker_linux.yaml @@ -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 - diff --git a/.github/workflows/ci_with_docker_macos.yaml b/.github/workflows/ci_with_docker_macos.yaml index a44b21f..322eda1 100644 --- a/.github/workflows/ci_with_docker_macos.yaml +++ b/.github/workflows/ci_with_docker_macos.yaml @@ -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 - \ No newline at end of file + cd __tests__/e2e/local && sudo ./run && cd - + - name: test custom.debian11 + run: | + cd __tests__/e2e/custom.debian11 && ./run && cd - \ No newline at end of file diff --git a/__tests__/complete-props.yaml b/__tests__/complete-props.yaml index ee81ea3..05fd7f1 100644 --- a/__tests__/complete-props.yaml +++ b/__tests__/complete-props.yaml @@ -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: diff --git a/__tests__/e2e/custom.debian11/go/code/.gitignore b/__tests__/e2e/custom.debian11/go/code/.gitignore new file mode 100644 index 0000000..0125409 --- /dev/null +++ b/__tests__/e2e/custom.debian11/go/code/.gitignore @@ -0,0 +1,2 @@ +python +__pycache__ diff --git a/__tests__/e2e/custom.debian11/go/code/go.mod b/__tests__/e2e/custom.debian11/go/code/go.mod new file mode 100644 index 0000000..4b64604 --- /dev/null +++ b/__tests__/e2e/custom.debian11/go/code/go.mod @@ -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 +) diff --git a/__tests__/e2e/custom.debian11/go/code/go.sum b/__tests__/e2e/custom.debian11/go/code/go.sum new file mode 100644 index 0000000..16c6017 --- /dev/null +++ b/__tests__/e2e/custom.debian11/go/code/go.sum @@ -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= diff --git a/__tests__/e2e/custom.debian11/go/code/main.go b/__tests__/e2e/custom.debian11/go/code/main.go new file mode 100644 index 0000000..70ca43d --- /dev/null +++ b/__tests__/e2e/custom.debian11/go/code/main.go @@ -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) +} diff --git a/__tests__/e2e/custom.debian11/go/s.yaml b/__tests__/e2e/custom.debian11/go/s.yaml new file mode 100644 index 0000000..074aab0 --- /dev/null +++ b/__tests__/e2e/custom.debian11/go/s.yaml @@ -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' diff --git a/__tests__/e2e/custom.debian11/run b/__tests__/e2e/custom.debian11/run new file mode 100755 index 0000000..b8d04c5 --- /dev/null +++ b/__tests__/e2e/custom.debian11/run @@ -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 + diff --git a/__tests__/e2e/python/code/index.py b/__tests__/e2e/python/code/index.py index 03d9a97..84f7423 100644 --- a/__tests__/e2e/python/code/index.py +++ b/__tests__/e2e/python/code/index.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- import subprocess -import fc2 from bs4 import BeautifulSoup import logging import flask diff --git a/__tests__/e2e/python/run b/__tests__/e2e/python/run index afbf129..3b96954 100755 --- a/__tests__/e2e/python/run +++ b/__tests__/e2e/python/run @@ -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 diff --git a/__tests__/e2e/python/run-windows.ps1 b/__tests__/e2e/python/run-windows.ps1 index 979f29a..abfa62a 100755 --- a/__tests__/e2e/python/run-windows.ps1 +++ b/__tests__/e2e/python/run-windows.ps1 @@ -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)" diff --git a/package-lock.json b/package-lock.json index a7637dc..0acc1ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,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", @@ -2341,9 +2341,9 @@ } }, "node_modules/@serverless-cd/srm-aliyun-sls20201230": { - "version": "0.0.4-beta.1", - "resolved": "https://registry.npmjs.org/@serverless-cd/srm-aliyun-sls20201230/-/srm-aliyun-sls20201230-0.0.4-beta.1.tgz", - "integrity": "sha512-hhq9IHZriRPeiDT+/+L2pOJ64BvLeY49JwgFuiIFCUN+5xr0V0JJXxAQasX5f+pKuTQwFSBMNrYE/Mmj6Wdy6Q==", + "version": "0.0.5-beta.3", + "resolved": "https://registry.npmmirror.com/@serverless-cd/srm-aliyun-sls20201230/-/srm-aliyun-sls20201230-0.0.5-beta.3.tgz", + "integrity": "sha512-pHfytUZz9PNWPxIU9jau3M0zPgBcdWbgtVgUhxlEmztTqs0J9S7Lf1bkPIwCegsTb+ZFQdKloZJSlMu9Bb5n+w==", "dependencies": { "@alicloud/openapi-client": "^0.4.4", "@alicloud/openapi-util": "^0.3.1", @@ -15430,9 +15430,9 @@ } }, "@serverless-cd/srm-aliyun-sls20201230": { - "version": "0.0.4-beta.1", - "resolved": "https://registry.npmjs.org/@serverless-cd/srm-aliyun-sls20201230/-/srm-aliyun-sls20201230-0.0.4-beta.1.tgz", - "integrity": "sha512-hhq9IHZriRPeiDT+/+L2pOJ64BvLeY49JwgFuiIFCUN+5xr0V0JJXxAQasX5f+pKuTQwFSBMNrYE/Mmj6Wdy6Q==", + "version": "0.0.5-beta.3", + "resolved": "https://registry.npmmirror.com/@serverless-cd/srm-aliyun-sls20201230/-/srm-aliyun-sls20201230-0.0.5-beta.3.tgz", + "integrity": "sha512-pHfytUZz9PNWPxIU9jau3M0zPgBcdWbgtVgUhxlEmztTqs0J9S7Lf1bkPIwCegsTb+ZFQdKloZJSlMu9Bb5n+w==", "requires": { "@alicloud/openapi-client": "^0.4.4", "@alicloud/openapi-util": "^0.3.1", diff --git a/package.json b/package.json index 6b91565..560f57e 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/publish.yaml b/publish.yaml index ea9e115..1ffbf27 100644 --- a/publish.yaml +++ b/publish.yaml @@ -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: diff --git a/src/interface/base.ts b/src/interface/base.ts index 974b283..50861f3 100644 --- a/src/interface/base.ts +++ b/src/interface/base.ts @@ -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', @@ -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', } diff --git a/src/resources/fc/impl/utils.ts b/src/resources/fc/impl/utils.ts index 51ad814..db1ee9e 100644 --- a/src/resources/fc/impl/utils.ts +++ b/src/resources/fc/impl/utils.ts @@ -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'] + ); } /** diff --git a/src/schema.json b/src/schema.json index 45163d4..8b9d54d 100644 --- a/src/schema.json +++ b/src/schema.json @@ -808,6 +808,7 @@ "custom", "custom-container", "custom.debian10", + "custom.debian11", "dotnetcore2.1", "dotnetcore3.1", "go1", @@ -824,7 +825,8 @@ "python2.7", "python3", "python3.10", - "python3.9" + "python3.9", + "python3.12" ], "type": "string" }, diff --git a/src/subCommands/build/impl/baseBuilder.ts b/src/subCommands/build/impl/baseBuilder.ts index e4394c6..0f6a66f 100644 --- a/src/subCommands/build/impl/baseBuilder.ts +++ b/src/subCommands/build/impl/baseBuilder.ts @@ -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); } diff --git a/src/subCommands/build/impl/defaultBuilder.ts b/src/subCommands/build/impl/defaultBuilder.ts index 6ff8812..8af834a 100644 --- a/src/subCommands/build/impl/defaultBuilder.ts +++ b/src/subCommands/build/impl/defaultBuilder.ts @@ -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}`, @@ -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}`, diff --git a/src/subCommands/deploy/index.ts b/src/subCommands/deploy/index.ts index 26216b7..535e31b 100644 --- a/src/subCommands/deploy/index.ts +++ b/src/subCommands/deploy/index.ts @@ -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; diff --git a/src/subCommands/local/impl/baseLocal.ts b/src/subCommands/local/impl/baseLocal.ts index c2a7a57..e1e1863 100644 --- a/src/subCommands/local/impl/baseLocal.ts +++ b/src/subCommands/local/impl/baseLocal.ts @@ -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); } @@ -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', @@ -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; @@ -503,6 +507,7 @@ export class BaseLocal { 'python3', 'python3.9', 'python3.10', + 'python3.12', 'java8', 'java11', 'php7.2', diff --git a/src/subCommands/local/index.ts b/src/subCommands/local/index.ts index 10ba988..d0ba0cc 100644 --- a/src/subCommands/local/index.ts +++ b/src/subCommands/local/index.ts @@ -48,7 +48,8 @@ export default class ComponentLocal { // case 'python2.7': case 'python3': case 'python3.9': - case 'python3.10': { + case 'python3.10': + case 'python3.12': { const pythonLocalInvoker = new PythonLocalInvoke(inputs); await pythonLocalInvoker.invoke(); break; @@ -75,7 +76,8 @@ export default class ComponentLocal { break; } case 'custom': - case 'custom.debian10': { + case 'custom.debian10': + case 'custom.debian11': { const customLocalInvoker = new CustomLocalInvoke(inputs); await customLocalInvoker.invoke(); break; @@ -118,7 +120,8 @@ export default class ComponentLocal { } case 'python3': case 'python3.9': - case 'python3.10': { + case 'python3.10': + case 'python3.12': { const pythonLocalStart = new PythonLocalStart(inputs); await pythonLocalStart.start(); break; @@ -145,7 +148,8 @@ export default class ComponentLocal { break; } case 'custom': - case 'custom.debian10': { + case 'custom.debian10': + case 'custom.debian11': { const customLocalStart = new CustomLocalStart(inputs); await customLocalStart.start(); break;