upgraded fsharp example to dotnet 2.0, updated docs, unit and integration tests. Removed duplicate code from docs section

This commit is contained in:
Yunspace 2018-02-23 20:50:00 +11:00
parent 897961d475
commit 0d652f287c
13 changed files with 23 additions and 153 deletions

4
.gitignore vendored
View File

@ -52,3 +52,7 @@ jest
# VIM
*.swp
# DotNet
[Bb]in/
[Oo]bj/

View File

@ -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:

View File

@ -1,17 +0,0 @@
namespace AwsDotnetFsharp
open Amazon.Lambda.Core
[<assembly:LambdaSerializer(typeof<Amazon.Lambda.Serialization.Json.JsonSerializer>)>]
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 }

View File

@ -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

View File

@ -1,24 +0,0 @@
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
<AssemblyName>FsharpHandlers</AssemblyName>
<PackageId>aws-fsharp</PackageId>
</PropertyGroup>
<ItemGroup>
<Compile Include="Handler.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="1.0.0" />
<PackageReference Include="Amazon.Lambda.Serialization.Json" Version="1.1.0" />
<PackageReference Include="FSharp.Core" Version="4.1.*" />
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Amazon.Lambda.Tools" Version="1.6.0" />
</ItemGroup>
</Project>

View File

@ -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"

View File

@ -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');
});
});

View File

@ -1,7 +1,7 @@
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
<TargetFramework>netcoreapp2.0</TargetFramework>
<AssemblyName>FsharpHandlers</AssemblyName>
<PackageId>aws-fsharp</PackageId>
</PropertyGroup>
@ -14,11 +14,10 @@
<PackageReference Include="Amazon.Lambda.Core" Version="1.0.0" />
<PackageReference Include="Amazon.Lambda.Serialization.Json" Version="1.1.0" />
<PackageReference Include="FSharp.Core" Version="4.1.*" />
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Amazon.Lambda.Tools" Version="1.6.0" />
<DotNetCliToolReference Include="Amazon.Lambda.Tools" Version="2.0.1" />
</ItemGroup>
</Project>

View File

@ -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

View File

@ -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

View File

@ -1,5 +0,0 @@
{
"sdk": {
"version": "1.0.4"
}
}

View File

@ -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/**

View File

@ -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