Skip to content

Commit 59f4dc8

Browse files
committed
revamp the application ci & makefile
1 parent 2dc98a3 commit 59f4dc8

4 files changed

Lines changed: 31 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ jobs:
2525
- name: Setup Node.js
2626
uses: actions/setup-node@v3
2727
with:
28-
node-version: 20
28+
node-version: 22
2929

3030
- name: Install Python
3131
uses: actions/setup-python@v4
3232
with:
33-
python-version: '3.10'
33+
python-version: '3.11'
3434

3535
- name: Install CDK
3636
run: |
@@ -55,4 +55,4 @@ jobs:
5555
5656
- name: Run tests
5757
run: |
58-
make run
58+
make test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
.venv/
22
volume/
3+
cdk.out
4+
dms_sample
5+
__pycache__/

Makefile

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
SHELL := /bin/bash
2+
13
VENV_BIN ?= python3 -m venv
24
VENV_DIR ?= .venv
35
PIP_CMD ?= pip3
@@ -33,28 +35,41 @@ $(VENV_ACTIVATE):
3335

3436
venv: $(VENV_ACTIVATE) ## Create a new (empty) virtual environment
3537

36-
start:
37-
$(LOCAL_ENV) docker compose up --build --detach --wait
38+
check: ## Check if all required prerequisites are available
39+
@command -v docker > /dev/null 2>&1 || { echo "Docker is not installed."; exit 1; }
40+
@command -v localstack > /dev/null 2>&1 || { echo "LocalStack is not installed."; exit 1; }
41+
@command -v python > /dev/null 2>&1 || { echo "Python is not installed."; exit 1; }
42+
@command -v cdk > /dev/null 2>&1 || { echo "AWS CDK is not installed."; exit 1; }
43+
@command -v cdklocal > /dev/null 2>&1 || { echo "CDK Local is not installed."; exit 1; }
44+
@echo "All required prerequisites are available."
45+
46+
start: ## Start localstack
47+
$(LOCAL_ENV) @LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) docker compose up --build --detach --wait
3848

39-
install: venv
49+
install: venv ## Install dependencies
4050
$(VENV_RUN); $(PIP_CMD) install -r requirements.txt
4151

42-
deploy:
52+
deploy: ## Deploy the stack on LocalStack
4353
$(VENV_RUN); $(LOCAL_ENV) cdklocal bootstrap --output ./cdk.local.out
4454
$(VENV_RUN); $(LOCAL_ENV) cdklocal deploy --require-approval never --output ./cdk.local.out
4555

46-
deploy-aws:
56+
deploy-aws: ## Deploy the stack on AWS
4757
$(VENV_RUN); $(CLOUD_ENV) cdk bootstrap
4858
$(VENV_RUN); $(CLOUD_ENV) cdk deploy --require-approval never
4959

50-
destroy:
60+
destroy: ## Destroy the stack on LocalStack
5161
docker-compose down
5262

53-
destroy-aws: venv
63+
destroy-aws: venv ## Destroy the stack on AWS
5464
$(VENV_RUN); $(CLOUD_ENV) cdk destroy --require-approval never
5565

56-
run:
66+
test: ## Test the application on LocalStack
5767
$(VENV_RUN); $(LOCAL_ENV) python run.py
5868

59-
run-aws:
69+
test-aws: ## Test the application on AWS
6070
$(VENV_RUN); $(CLOUD_ENV) python run.py
71+
72+
logs: ## Show logs from LocalStack
73+
@docker logs -f localstack_main > logs.txt
74+
75+
.PHONY: usage install start deploy test logs destroy deploy-aws test-aws destroy-aws

app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from dms_sample.stack import DmsSampleStack
55

6-
STACK_NAME = os.getenv("STACK_NAME", "")
6+
STACK_NAME = os.getenv("STACK_NAME", "DMsSampleSetupStack")
77

88
app = cdk.App()
99
DmsSampleStack(app, STACK_NAME)

0 commit comments

Comments
 (0)