Skip to content

Commit 2973d06

Browse files
author
Andrea Scuderi
committed
Add GitHub configuration
1 parent b4891f9 commit 2973d06

File tree

8 files changed

+219
-50
lines changed

8 files changed

+219
-50
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/workflows/meterian.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# .github/workflows/meterian.yml
2+
3+
name: Meterian Scanner workflow
4+
5+
on: push
6+
7+
jobs:
8+
meterian_scan:
9+
name: Meterian client scan
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
- name: Meterian Scanner
15+
uses: MeterianHQ/[email protected]
16+
with:
17+
oss: true
18+
cli_args: --tags=swift

.github/workflows/swift-test.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: 'Run Swift Tests'
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
10+
env:
11+
AWS_ENABLE_LOGGING : "true"
12+
AWS_LOG_LEVEL: "trace"
13+
14+
jobs:
15+
swift-tests:
16+
name: 'Swift Tests'
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
image:
21+
- swift:5.7.3-amazonlinux2
22+
container:
23+
image: ${{ matrix.image }}
24+
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
25+
defaults:
26+
run:
27+
shell: bash
28+
29+
steps:
30+
# Checkout the repository to the GitHub Actions runner
31+
- name: Checkout
32+
uses: actions/checkout@v3
33+
- name: Setup
34+
run: |
35+
yum -y update && yum -y install git make curl
36+
- name: Test
37+
run: |
38+
make test
39+
- name: Coverage
40+
run: |
41+
make coverage
42+
- name: Upload Code Coverage
43+
uses: codecov/codecov-action@v3
44+
with:
45+
files: ${{ github.workspace }}/lcov.info

Makefile

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -28,42 +28,4 @@ test:
2828
coverage:
2929
llvm-cov export $(SWIFT_BIN_PATH)/BreezePackageTests.xctest \
3030
--instr-profile=$(SWIFT_BIN_PATH)/codecov/default.profdata \
31-
--format=lcov > $(GITHUB_WORKSPACE)/lcov.info
32-
33-
install_yq:
34-
yum -y install wget
35-
wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
36-
chmod a+x /usr/local/bin/yq
37-
38-
generate_lambda_api_temp:
39-
swift run breeze generate-lambda-api -c ./Sources/BreezeCommand/Resources/breeze.yml -t $(BUILD_TEMP) -f -y
40-
41-
generate_github_weboook_temp:
42-
swift run breeze generate-github-webhook -c ./Sources/BreezeCommand/Resources/breeze-github-webhook.yml -t $(BUILD_TEMP) -f -y
43-
44-
generate_webhook_temp:
45-
swift run breeze generate-webhook -c ./Sources/BreezeCommand/Resources/breeze-webhook.yml -t $(BUILD_TEMP) -f -y
46-
47-
generate_lambda_api_example:
48-
swift run breeze generate-lambda-api -c ./Sources/BreezeCommand/Resources/breeze.yml -t $(EXAMPLE_PATH) -f
49-
50-
generate_github_weboook_example:
51-
swift run breeze generate-github-webhook -c ./Sources/BreezeCommand/Resources/breeze-github-webhook.yml -t $(EXAMPLE_GITHUB_WEBHOOK_PATH) -f
52-
53-
generate_weboook_example:
54-
swift run breeze generate-webhook -c ./Sources/BreezeCommand/Resources/breeze-webhook.yml -t $(EXAMPLE_WEBHOOK_PATH) -f
55-
56-
compare_breeze_lambda_api_output_with_example: install_yq generate_lambda_api_temp
57-
bash -c "diff <(yq -P 'sort_keys(..)' $(EXAMPLE_PATH)/serverless.yml) <(yq -P 'sort_keys(..)' $(BUILD_TEMP)/serverless.yml)"
58-
bash -c "diff <(yq -P 'sort_keys(..)' $(EXAMPLE_PATH)/serverless-x86_64.yml) <(yq -P 'sort_keys(..)' $(BUILD_TEMP)/serverless-x86_64.yml)"
59-
diff -rb $(EXAMPLE_PATH) $(BUILD_TEMP) --exclude=*.yml --exclude=Package.resolved
60-
61-
compare_breeze_github_weboook_output_with_example: install_yq generate_github_weboook_temp
62-
bash -c "diff <(yq -P 'sort_keys(..)' $(EXAMPLE_GITHUB_WEBHOOK_PATH)/serverless.yml) <(yq -P 'sort_keys(..)' $(BUILD_TEMP)/serverless.yml)"
63-
bash -c "diff <(yq -P 'sort_keys(..)' $(EXAMPLE_GITHUB_WEBHOOK_PATH)/serverless-x86_64.yml) <(yq -P 'sort_keys(..)' $(BUILD_TEMP)/serverless-x86_64.yml)"
64-
diff -rb $(EXAMPLE_GITHUB_WEBHOOK_PATH) $(BUILD_TEMP) --exclude=*.yml --exclude=Package.resolved
65-
66-
compare_breeze_weboook_output_with_example: install_yq generate_webhook_temp
67-
bash -c "diff <(yq -P 'sort_keys(..)' $(EXAMPLE_WEBHOOK_PATH)/serverless.yml) <(yq -P 'sort_keys(..)' $(BUILD_TEMP)/serverless.yml)"
68-
bash -c "diff <(yq -P 'sort_keys(..)' $(EXAMPLE_WEBHOOK_PATH)/serverless-x86_64.yml) <(yq -P 'sort_keys(..)' $(BUILD_TEMP)/serverless-x86_64.yml)"
69-
diff -rb $(EXAMPLE_WEBHOOK_PATH) $(BUILD_TEMP) --exclude=*.yml --exclude=Package.resolved
31+
--format=lcov > $(GITHUB_WORKSPACE)/lcov.info

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.

README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,94 @@
77

88
![Breeze](logo.png)
99

10+
## Usage
11+
12+
Add the package `BreezeLambdaWebHook` to a package:
13+
14+
```swift
15+
// swift-tools-version:5.7
16+
// The swift-tools-version declares the minimum version of Swift required to build this package.
17+
18+
import PackageDescription
19+
20+
let package = Package(
21+
name: "BreezeWebHook",
22+
platforms: [
23+
.macOS(.v13),
24+
],
25+
products: [
26+
.executable(name: "WebHook", targets: ["WebHook"]),
27+
],
28+
dependencies: [
29+
.package(url: "https://github.com/swift-sprinter/BreezeLambdaWebHook.git", from: "0.4.0")
30+
],
31+
targets: [
32+
.executableTarget(
33+
name: "WebHook",
34+
dependencies: [
35+
.product(name: "BreezeLambdaWebHook", package: "Breeze"),
36+
]
37+
)
38+
]
39+
)
40+
```
41+
42+
Add the implementation to the Lambda:
43+
44+
```swift
45+
import Foundation
46+
import AWSLambdaEvents
47+
import AWSLambdaRuntimeCore
48+
import BreezeLambdaWebHook
49+
import Foundation
50+
51+
enum WebHookError: Error {
52+
case invalidHandler
53+
}
54+
55+
class WebHook: BreezeLambdaWebHookHandler {
56+
57+
let handlerContext: HandlerContext
58+
59+
required init(handlerContext: HandlerContext) {
60+
self.handlerContext = handlerContext
61+
}
62+
63+
func handle(context: AWSLambdaRuntimeCore.LambdaContext, event: AWSLambdaEvents.APIGatewayV2Request) async -> AWSLambdaEvents.APIGatewayV2Response {
64+
do {
65+
// Check the handler
66+
guard let handler = handlerContext.handler else {
67+
throw WebHookError.invalidHandler
68+
}
69+
// Evaluate the event
70+
context.logger.info("event: \(event)")
71+
let incomingRequest: ... = try event.bodyObject()
72+
// Implement the business logic
73+
let body = ...
74+
// Return an APIGatewayV2Response
75+
return APIGatewayV2Response(with: body, statusCode: .ok)
76+
} catch {
77+
// Return an APIGatewayV2Response in case of error
78+
return APIGatewayV2Response(with: error, statusCode: .badRequest)
79+
}
80+
}
81+
}
82+
```
83+
84+
Add the Lambda runtime to the file `swift.main`
85+
```
86+
import Foundation
87+
import AWSLambdaEvents
88+
import AWSLambdaRuntimeCore
89+
import BreezeLambdaWebHook
90+
91+
BreezeLambdaWebHook<WebHook>.main()
92+
```
93+
94+
## Documentation
95+
96+
Refer to the main project https://github.com/swift-serverless/Breeze for more info and working examples.
97+
1098
## Contributing
1199

12100
Contributions are welcome! If you encounter any issues or have ideas for improvements, please open an issue or submit a pull request.

docker/docker-compose.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,8 @@ services:
1515
volumes:
1616
- ..:/src
1717
working_dir: /src
18-
depends_on:
19-
- localstack
20-
environment:
21-
- LOCALSTACK_ENDPOINT=http://localstack:4566
2218
command: /bin/bash -xcl "swift test --sanitize=thread"
2319

24-
localstack:
25-
image: localstack/localstack
26-
2720
shell:
2821
<<: *common
29-
depends_on:
30-
- localstack
31-
environment:
32-
- LOCALSTACK_ENDPOINT=http://localstack:4566
3322
entrypoint: /bin/bash

0 commit comments

Comments
 (0)