Skip to content
This repository was archived by the owner on Jul 14, 2020. It is now read-only.

Commit 8c72bc9

Browse files
authored
moved makefile. ci builds all examples. (#24)
examples folder name is now lowercase.
1 parent 1999d57 commit 8c72bc9

File tree

35 files changed

+144
-62
lines changed

35 files changed

+144
-62
lines changed

.github/workflows/ci.yaml

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@ on:
88
- master
99

1010
jobs:
11-
"Integration-Tests":
11+
"Build-Examples":
1212
runs-on: ubuntu-18.04
13+
strategy:
14+
matrix:
15+
example:
16+
- EventSources
17+
- SquareNumber
18+
- TodoAPIGateway
19+
- URLRequestWithSession
1320
env:
1421
SWIFT_VERSION: 5.1.3
1522
steps:
@@ -19,20 +26,27 @@ jobs:
1926
fetch-depth: 1
2027
- name: Install ruby
2128
uses: actions/setup-ruby@v1
22-
- name: Install aws-sam-cli
23-
run: sudo pip install aws-sam-cli
2429
- name: Build Docker Swift Dev Image
2530
run: docker build --build-arg SWIFT_VERSION=${SWIFT_VERSION} -t fabianfett/amazonlinux-swift:${SWIFT_VERSION}-amazonlinux2-dev ./docker
26-
- name: Download local layer
27-
run: |
28-
mkdir -p Layer
29-
curl -o Layer/swift-${SWIFT_VERSION}-RELEASE.zip https://amazonlinux-swift.s3.eu-central-1.amazonaws.com/layers/swift-${SWIFT_VERSION}-RELEASE.zip
30-
unzip Layer/swift-${SWIFT_VERSION}-RELEASE.zip -d Layer/swift-lambda-layer
31-
- name: test local lambda
32-
run: make test_lambda
33-
env:
34-
EXAMPLE_LAMBDA: SquareNumber
35-
31+
- name: Build example
32+
run: |
33+
cd examples/${{ matrix.example }}
34+
make package_lambda
35+
- name: Install sam cli
36+
if: matrix.example == 'SquareNumber'
37+
run: sudo pip install aws-sam-cli
38+
- name: Download layer
39+
if: matrix.example == 'SquareNumber'
40+
run: |
41+
cd examples/${{ matrix.example }}
42+
make download_layer
43+
- name: Run example
44+
if: matrix.example == 'SquareNumber'
45+
run: |
46+
cd examples/${{ matrix.example }}
47+
echo '{"number": 9 }' | sam local invoke -v . "SquareNumberFunction"
48+
echo '{"number": 3 }' | sam local invoke -v . "PrintNumberFunction"
49+
3650
"tuxOS-Tests":
3751
runs-on: ubuntu-latest
3852
strategy:

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.build
33
/*.xcodeproj
44
xcuserdata
5-
Layer
6-
Examples/**/lambda.zip
75
packaged.yaml
8-
bootstrap
6+
examples/**/bootstrap
7+
examples/**/lambda.zip
8+
examples/**/swift-lambda-layer

Examples/SquareNumber/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Lines changed: 0 additions & 7 deletions
This file was deleted.

Examples/TodoAPIGateway/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Lines changed: 0 additions & 7 deletions
This file was deleted.
File renamed without changes.

examples/EventSources/makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Example settings
2+
LAMBDA_NAME=EventSources
3+
EXECUTABLE=$(LAMBDA_NAME)
4+
LAMBDA_ZIP=lambda.zip
5+
6+
SWIFT_VERSION=5.1.3
7+
SWIFT_DOCKER_IMAGE=fabianfett/amazonlinux-swift:${SWIFT_VERSION}-amazonlinux2-dev
8+
9+
clean_lambda:
10+
rm bootstrap || true
11+
rm lambda.zip || true
12+
13+
build_lambda:
14+
docker run \
15+
--rm \
16+
--volume "$(shell pwd)/../..:/src" \
17+
--workdir "/src/examples/$(LAMBDA_NAME)/" \
18+
$(SWIFT_DOCKER_IMAGE) \
19+
swift build -c release
20+
21+
package_lambda: build_lambda
22+
cp .build/release/$(EXECUTABLE) ./bootstrap
23+
zip -r -j $(LAMBDA_ZIP) ./bootstrap
24+
25+

examples/SquareNumber/makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Example settings
2+
LAMBDA_NAME=SquareNumber
3+
EXECUTABLE=$(LAMBDA_NAME)
4+
LAMBDA_ZIP=lambda.zip
5+
6+
SWIFT_VERSION=5.1.3
7+
SWIFT_DOCKER_IMAGE=fabianfett/amazonlinux-swift:${SWIFT_VERSION}-amazonlinux2-dev
8+
9+
clean_lambda:
10+
rm bootstrap || true
11+
rm lambda.zip || true
12+
13+
build_lambda:
14+
docker run \
15+
--rm \
16+
--volume "$(shell pwd)/../..:/src" \
17+
--workdir "/src/examples/$(LAMBDA_NAME)/" \
18+
$(SWIFT_DOCKER_IMAGE) \
19+
swift build -c release
20+
21+
package_lambda: build_lambda
22+
cp .build/release/$(EXECUTABLE) ./bootstrap
23+
zip -r -j $(LAMBDA_ZIP) ./bootstrap
24+
25+
download_layer:
26+
curl -o swift-${SWIFT_VERSION}-RELEASE.zip https://amazonlinux-swift.s3.eu-central-1.amazonaws.com/layers/swift-${SWIFT_VERSION}-RELEASE.zip
27+
unzip swift-${SWIFT_VERSION}-RELEASE.zip -d swift-lambda-layer
28+
rm swift-${SWIFT_VERSION}-RELEASE.zip

Examples/SquareNumber/template.yaml renamed to examples/SquareNumber/template.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ Resources:
1515
SwiftLayer:
1616
Type: AWS::Serverless::LayerVersion
1717
Properties:
18-
ContentUri: Layer/swift-lambda-layer/
18+
ContentUri: swift-lambda-layer/
1919

2020
SquareNumberFunction:
2121
Type: AWS::Serverless::Function
2222
Properties:
23-
CodeUri: Examples/SquareNumber/lambda.zip
23+
CodeUri: lambda.zip
2424
Handler: "squareNumber"
2525
Runtime: provided
2626
Layers:
@@ -29,7 +29,7 @@ Resources:
2929
PrintNumberFunction:
3030
Type: AWS::Serverless::Function
3131
Properties:
32-
CodeUri: Examples/SquareNumber/lambda.zip
32+
CodeUri: lambda.zip
3333
Handler: "printNumber"
3434
Runtime: provided
3535
Layers:

Examples/TodoAPIGateway/Package.resolved renamed to examples/TodoAPIGateway/Package.resolved

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

examples/TodoAPIGateway/makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Example settings
2+
LAMBDA_NAME=TodoAPIGateway
3+
EXECUTABLE=$(LAMBDA_NAME)
4+
LAMBDA_ZIP=lambda.zip
5+
6+
SWIFT_VERSION=5.1.3
7+
SWIFT_DOCKER_IMAGE=fabianfett/amazonlinux-swift:${SWIFT_VERSION}-amazonlinux2-dev
8+
9+
clean_lambda:
10+
rm bootstrap || true
11+
rm lambda.zip || true
12+
13+
build_lambda:
14+
docker run \
15+
--rm \
16+
--volume "$(shell pwd)/../..:/src" \
17+
--workdir "/src/examples/$(LAMBDA_NAME)/" \
18+
$(SWIFT_DOCKER_IMAGE) \
19+
swift build -c release
20+
21+
package_lambda: build_lambda
22+
cp .build/release/$(EXECUTABLE) ./bootstrap
23+
zip -r -j $(LAMBDA_ZIP) ./bootstrap
24+
25+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Example settings
2+
LAMBDA_NAME=URLRequestWithSession
3+
EXECUTABLE=$(LAMBDA_NAME)
4+
LAMBDA_ZIP=lambda.zip
5+
6+
SWIFT_VERSION=5.1.3
7+
SWIFT_DOCKER_IMAGE=fabianfett/amazonlinux-swift:${SWIFT_VERSION}-amazonlinux2-dev
8+
9+
clean_lambda:
10+
rm bootstrap || true
11+
rm lambda.zip || true
12+
13+
build_lambda:
14+
docker run \
15+
--rm \
16+
--volume "$(shell pwd)/../..:/src" \
17+
--workdir "/src/examples/$(LAMBDA_NAME)/" \
18+
$(SWIFT_DOCKER_IMAGE) \
19+
swift build -c release
20+
21+
package_lambda: build_lambda
22+
cp .build/release/$(EXECUTABLE) ./bootstrap
23+
zip -r -j $(LAMBDA_ZIP) ./bootstrap

Examples/URLRequestWithSession/template.yaml renamed to examples/URLRequestWithSession/template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Resources:
1515
EchoCallFunction:
1616
Type: AWS::Serverless::Function
1717
Properties:
18-
CodeUri: Examples/URLRequestWithSession/lambda.zip
18+
CodeUri: lambda.zip
1919
Handler: "echoCall"
2020
Runtime: provided
2121
Layers:

makefile

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)