From 0d652f287c72f15beeb7be2cb56d5c793597aa1b Mon Sep 17 00:00:00 2001 From: Yunspace Date: Fri, 23 Feb 2018 20:50:00 +1100 Subject: [PATCH] upgraded fsharp example to dotnet 2.0, updated docs, unit and integration tests. Removed duplicate code from docs section --- .gitignore | 4 + docker-compose.yml | 2 +- .../examples/hello-world/fsharp/Handler.fs | 17 ---- .../aws/examples/hello-world/fsharp/README.md | 18 ++-- .../hello-world/fsharp/aws-fsharp.fsproj | 24 ----- .../hello-world/fsharp/serverless.yml | 87 ------------------- lib/plugins/create/create.test.js | 2 +- .../templates/aws-fsharp/aws-fsharp.fsproj | 7 +- .../create/templates/aws-fsharp/build.cmd | 2 +- .../create/templates/aws-fsharp/build.sh | 2 +- .../create/templates/aws-fsharp/global.json | 5 -- .../templates/aws-fsharp/serverless.yml | 4 +- tests/templates/test_all_templates | 2 +- 13 files changed, 23 insertions(+), 153 deletions(-) delete mode 100644 docs/providers/aws/examples/hello-world/fsharp/Handler.fs delete mode 100644 docs/providers/aws/examples/hello-world/fsharp/aws-fsharp.fsproj delete mode 100644 docs/providers/aws/examples/hello-world/fsharp/serverless.yml delete mode 100644 lib/plugins/create/templates/aws-fsharp/global.json diff --git a/.gitignore b/.gitignore index 4d98e9617..54f8012af 100755 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,7 @@ jest # VIM *.swp + +# DotNet +[Bb]in/ +[Oo]bj/ \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 98c398c8f..4c721f1af 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -60,7 +60,7 @@ services: volumes: - ./tmp/serverless-integration-test-aws-csharp:/app aws-fsharp: - image: microsoft/dotnet:1.0.4-sdk + image: microsoft/dotnet:2.0-sdk volumes: - ./tmp/serverless-integration-test-aws-fsharp:/app aws-go: diff --git a/docs/providers/aws/examples/hello-world/fsharp/Handler.fs b/docs/providers/aws/examples/hello-world/fsharp/Handler.fs deleted file mode 100644 index b9e1806fe..000000000 --- a/docs/providers/aws/examples/hello-world/fsharp/Handler.fs +++ /dev/null @@ -1,17 +0,0 @@ -namespace AwsDotnetFsharp -open Amazon.Lambda.Core - -[)>] -do () - -type Request = { Key1 : string; Key2 : string; Key3 : string } -type Response = { Message : string; Request : Request } - -module Handler = - open System - open System.IO - open System.Text - - let hello(request:Request) = - { Message="Go Serverless v1.0! Your function executed successfully!" - Request=request } \ No newline at end of file diff --git a/docs/providers/aws/examples/hello-world/fsharp/README.md b/docs/providers/aws/examples/hello-world/fsharp/README.md index 562c1e498..b973a9c46 100644 --- a/docs/providers/aws/examples/hello-world/fsharp/README.md +++ b/docs/providers/aws/examples/hello-world/fsharp/README.md @@ -23,15 +23,15 @@ Commands ## 1. Create a service -``` -sls create --template aws-fsharp --path myService -``` - -Using the `create` command we can specify one of the available [templates](https://serverless.com/framework/docs/providers/aws/cli-reference/create#available-templates). For this example use aws-fsharp with the `--template` or shorthand `-t` flag. - -The `--path` or shorthand `-p` is the location to be created with the template service files. Change directories into this new folder. - -## 2. Build using .NET CLI tools and create zip package +``` +sls create --template aws-fsharp --path myService +``` + +Using the `create` command we can specify one of the available [templates](https://serverless.com/framework/docs/providers/aws/cli-reference/create#available-templates). For this example use aws-fsharp with the `--template` or shorthand `-t` flag. + +The `--path` or shorthand `-p` is the location to be created with the template service files. Change directories into this new folder. + +## 2. Build using .NET Core 2.X CLI tools and create zip package ``` # Linux or Mac OS diff --git a/docs/providers/aws/examples/hello-world/fsharp/aws-fsharp.fsproj b/docs/providers/aws/examples/hello-world/fsharp/aws-fsharp.fsproj deleted file mode 100644 index f3a1aafd4..000000000 --- a/docs/providers/aws/examples/hello-world/fsharp/aws-fsharp.fsproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - netcoreapp1.0 - FsharpHandlers - aws-fsharp - - - - - - - - - - - - - - - - - - diff --git a/docs/providers/aws/examples/hello-world/fsharp/serverless.yml b/docs/providers/aws/examples/hello-world/fsharp/serverless.yml deleted file mode 100644 index 6ef081deb..000000000 --- a/docs/providers/aws/examples/hello-world/fsharp/serverless.yml +++ /dev/null @@ -1,87 +0,0 @@ -# Welcome to Serverless! -# -# This file is the main config file for your service. -# It's very minimal at this point and uses default values. -# You can always add more config options for more control. -# We've included some commented out config examples here. -# Just uncomment any of them to get that config option. -# -# For full config options, check the docs: -# docs.serverless.com -# -# Happy Coding! - -service: aws-fsharp # NOTE: update this with your service name - -# You can pin your service to only deploy with a specific Serverless version -# Check out our docs for more details -# frameworkVersion: "=X.X.X" - -provider: - name: aws - runtime: dotnetcore1.0 - -# you can overwrite defaults here -# stage: dev -# region: us-east-1 - -# you can add statements to the Lambda function's IAM Role here -# iamRoleStatements: -# - Effect: "Allow" -# Action: -# - "s3:ListBucket" -# Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] } -# - Effect: "Allow" -# Action: -# - "s3:PutObject" -# Resource: -# Fn::Join: -# - "" -# - - "arn:aws:s3:::" -# - "Ref" : "ServerlessDeploymentBucket" - -# you can define service wide environment variables here -# environment: -# variable1: value1 - -# you can add packaging information here -package: - artifact: bin/release/netcoreapp1.0/deploy-package.zip -# exclude: -# - exclude-me.js -# - exclude-me-dir/** - -functions: - hello: - handler: FsharpHandlers::AwsDotnetFsharp.Handler::hello - -# The following are a few example events you can configure -# NOTE: Please make sure to change your handler code to work with those events -# Check the event documentation for details -# events: -# - http: -# path: users/create -# method: get -# - s3: ${env:BUCKET} -# - schedule: rate(10 minutes) -# - sns: greeter-topic -# - stream: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000 -# - alexaSkill: amzn1.ask.skill.xx-xx-xx-xx -# - iot: -# sql: "SELECT * FROM 'some_topic'" - -# Define function environment variables here -# environment: -# variable2: value2 - -# you can add CloudFormation resource templates here -#resources: -# Resources: -# NewResource: -# Type: AWS::S3::Bucket -# Properties: -# BucketName: my-new-bucket -# Outputs: -# NewOutput: -# Description: "Description for the output" -# Value: "Some output value" diff --git a/lib/plugins/create/create.test.js b/lib/plugins/create/create.test.js index c0bf9d726..4ea33d8b8 100644 --- a/lib/plugins/create/create.test.js +++ b/lib/plugins/create/create.test.js @@ -159,7 +159,7 @@ describe('Create', () => { expect(dirContent).to.include('build.sh'); expect(dirContent).to.include('build.cmd'); expect(dirContent).to.include('aws-fsharp.fsproj'); - expect(dirContent).to.include('global.json'); + expect(dirContent).to.not.include('global.json'); }); }); diff --git a/lib/plugins/create/templates/aws-fsharp/aws-fsharp.fsproj b/lib/plugins/create/templates/aws-fsharp/aws-fsharp.fsproj index f3a1aafd4..cb30c3303 100644 --- a/lib/plugins/create/templates/aws-fsharp/aws-fsharp.fsproj +++ b/lib/plugins/create/templates/aws-fsharp/aws-fsharp.fsproj @@ -1,7 +1,7 @@ - + - netcoreapp1.0 + netcoreapp2.0 FsharpHandlers aws-fsharp @@ -14,11 +14,10 @@ - - + diff --git a/lib/plugins/create/templates/aws-fsharp/build.cmd b/lib/plugins/create/templates/aws-fsharp/build.cmd index 468f8503a..9bd8efb21 100644 --- a/lib/plugins/create/templates/aws-fsharp/build.cmd +++ b/lib/plugins/create/templates/aws-fsharp/build.cmd @@ -1,2 +1,2 @@ dotnet restore -dotnet lambda package --configuration release --framework netcoreapp1.0 --output-package bin/release/netcoreapp1.0/deploy-package.zip +dotnet lambda package --configuration release --framework netcoreapp2.0 --output-package bin/release/netcoreapp2.0/deploy-package.zip diff --git a/lib/plugins/create/templates/aws-fsharp/build.sh b/lib/plugins/create/templates/aws-fsharp/build.sh index f57aebe45..3f92f87ce 100644 --- a/lib/plugins/create/templates/aws-fsharp/build.sh +++ b/lib/plugins/create/templates/aws-fsharp/build.sh @@ -12,4 +12,4 @@ fi dotnet restore #create deployment package -dotnet lambda package --configuration release --framework netcoreapp1.0 --output-package bin/release/netcoreapp1.0/deploy-package.zip +dotnet lambda package --configuration release --framework netcoreapp2.0 --output-package bin/release/netcoreapp2.0/deploy-package.zip diff --git a/lib/plugins/create/templates/aws-fsharp/global.json b/lib/plugins/create/templates/aws-fsharp/global.json deleted file mode 100644 index 8af244a46..000000000 --- a/lib/plugins/create/templates/aws-fsharp/global.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sdk": { - "version": "1.0.4" - } -} diff --git a/lib/plugins/create/templates/aws-fsharp/serverless.yml b/lib/plugins/create/templates/aws-fsharp/serverless.yml index 0f8ca52b4..e12d4231b 100644 --- a/lib/plugins/create/templates/aws-fsharp/serverless.yml +++ b/lib/plugins/create/templates/aws-fsharp/serverless.yml @@ -19,7 +19,7 @@ service: aws-fsharp # NOTE: update this with your service name provider: name: aws - runtime: dotnetcore1.0 + runtime: dotnetcore2.0 # you can overwrite defaults here # stage: dev @@ -47,7 +47,7 @@ provider: # you can add packaging information here package: - artifact: bin/release/netcoreapp1.0/deploy-package.zip + artifact: bin/release/netcoreapp2.0/deploy-package.zip # exclude: # - exclude-me.js # - exclude-me-dir/** diff --git a/tests/templates/test_all_templates b/tests/templates/test_all_templates index fd88105ab..88980ab50 100755 --- a/tests/templates/test_all_templates +++ b/tests/templates/test_all_templates @@ -9,7 +9,7 @@ function integration-test { } integration-test aws-csharp 'apt-get -qq update && apt-get -qq -y install zip && dotnet restore && dotnet lambda package --configuration release --framework netcoreapp1.0 --output-package bin/release/netcoreapp1.0/deploy-package.zip' -integration-test aws-fsharp 'apt-get -qq update && apt-get -qq -y install zip && dotnet restore && dotnet lambda package --configuration release --framework netcoreapp1.0 --output-package bin/release/netcoreapp1.0/deploy-package.zip' +integration-test aws-fsharp './build.sh' integration-test aws-go 'cd /go/src/app && make build' integration-test aws-go-dep 'cd /go/src/app && make build' integration-test aws-groovy-gradle ./gradlew build