Skip to content

Commit c5f96de

Browse files
committed
first commit with refactored working deployment and CI pipeline using LocalStack
1 parent 34adbfa commit c5f96de

28 files changed

Lines changed: 561 additions & 0 deletions
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: CI Pipeline - DEV
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- dev
7+
8+
env:
9+
GIT__BRANCH : 'dev'
10+
RELEASE_TYPE : 'minor'
11+
PACKAGE_NAME : 'osbot_fast_api_serverless'
12+
13+
jobs:
14+
15+
run-tests:
16+
name: "Run tests"
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4 # Checkout the code in dev branch
20+
21+
- name: Start Local Stack
22+
uses: owasp-sbot/OSBot-GitHub-Actions/.github/actions/docker__local-stack@dev # start LocalStack in GitHub actions
23+
with:
24+
LOCAL_STACK_SERVICES: 's3,lambda,iam,logs'
25+
26+
- name: "run-tests"
27+
uses: owasp-sbot/OSBot-GitHub-Actions/.github/actions/pytest__run-tests@dev # run tests (which use Local Stack)
28+
with:
29+
test_target: "tests"
30+
env:
31+
FAST_API__AUTH__API_KEY__NAME : 'api-key__in_github_test'
32+
FAST_API__AUTH__API_KEY__VALUE : 'this-is-the-value-of-the-api-key'
33+
34+
35+
increment-tag:
36+
name: Increment Tag - DEV
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v4
40+
- name: Increment Tag
41+
uses: owasp-sbot/OSBot-GitHub-Actions/.github/actions/git__increment-tag@dev
42+
with:
43+
release_type: ${{ env.RELEASE_TYPE }}
44+
needs:
45+
- run-tests
46+
47+
publish-to-pypi:
48+
if: False
49+
name: "Publish to: PYPI"
50+
permissions:
51+
id-token: write
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v4
55+
- name: Git Update Current Branch
56+
uses: owasp-sbot/OSBot-GitHub-Actions/.github/actions/git__update_branch@dev
57+
- name: publish-to-pypi
58+
uses: owasp-sbot/OSBot-GitHub-Actions/.github/actions/pypi__twine__publish@dev
59+
needs:
60+
- increment-tag
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name : CI Pipeline - Main
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
GIT__BRANCH : 'main'
10+
RELEASE_TYPE : 'major'
11+
PACKAGE_NAME : 'osbot_fast_api_serverless'
12+
13+
jobs:
14+
15+
run-tests:
16+
name: "Run tests"
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: "run-tests"
21+
uses: owasp-sbot/OSBot-GitHub-Actions/.github/actions/pytest__run-tests@dev
22+
23+
increment-tag:
24+
name: Increment Tag - Main
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Increment Tag
29+
uses: owasp-sbot/OSBot-GitHub-Actions/.github/actions/git__increment-tag@dev
30+
with:
31+
release_type: ${{ env.RELEASE_TYPE }}
32+
needs:
33+
- run-tests
34+
35+
publish-to-pypi:
36+
name: "Publish to: PYPI"
37+
permissions:
38+
id-token: write
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v4
42+
- name: Git Update Current Branch
43+
uses: owasp-sbot/OSBot-GitHub-Actions/.github/actions/git__update_branch@dev
44+
- name: publish-to-pypi
45+
uses: owasp-sbot/OSBot-GitHub-Actions/.github/actions/pypi__twine__publish@dev
46+
needs:
47+
- increment-tag

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,4 @@ cython_debug/
205205
marimo/_static/
206206
marimo/_lsp/
207207
__marimo__/
208+
tests/_lambda_dependencies

gh-release-to-main.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
git pull
2+
git checkout main
3+
git pull origin main
4+
git merge --no-ff dev -m "Merge dev into main"
5+
git push origin main
6+
git checkout dev
7+
git merge main -m "Merge main into dev"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
path=__path__[0]

osbot_fast_api_serverless/core/__init__.py

Whitespace-only changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from osbot_fast_api.api.Fast_API import Fast_API
2+
from mangum import Mangum
3+
from osbot_utils.utils.Env import load_dotenv
4+
from osbot_fast_api_serverless.core.fast_api.routes.Routes__Info import Routes__Info
5+
6+
7+
class Serverless__Fast_API(Fast_API):
8+
enable_cors : bool = True
9+
enable_api_key : bool = True
10+
default_routes : bool = False
11+
12+
def setup(self):
13+
load_dotenv() # needed for api key support # todo: add this to Fast_API class (maybe as an top level option)
14+
super().setup()
15+
return self
16+
17+
def handler(self):
18+
handler = Mangum(self.app())
19+
return handler
20+
21+
def setup_routes(self):
22+
self.add_routes(Routes__Info)

osbot_fast_api_serverless/core/fast_api/__init__.py

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from osbot_fast_api.api.Fast_API_Routes import Fast_API_Routes
2+
from osbot_fast_api_serverless.utils.Version import version__osbot_fast_api_serverless
3+
4+
ROUTES_PATHS__INFO = ['/info/version']
5+
6+
class Routes__Info(Fast_API_Routes):
7+
tag :str = 'info'
8+
9+
10+
def version(self):
11+
return {'version': version__osbot_fast_api_serverless}
12+
13+
14+
def setup_routes(self):
15+
self.add_route_get(self.version)
16+

osbot_fast_api_serverless/core/fast_api/routes/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)