Skip to content

Commit 4dd3a0d

Browse files
authored
revamp the makefile (#15)
* revamp the makefile * setup cdk and cdklocal
1 parent 26f24bd commit 4dd3a0d

File tree

3 files changed

+49
-20
lines changed

3 files changed

+49
-20
lines changed

.github/workflows/cloud-pods.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ jobs:
3131
run: |
3232
make install
3333
34+
- name: Install CDK
35+
run: |
36+
npm install -g aws-cdk-local aws-cdk
37+
cdklocal --version
38+
3439
- name: Start LocalStack
3540
uses: LocalStack/setup-localstack@main
3641
with:
@@ -47,8 +52,6 @@ jobs:
4752
AWS_SECRET_ACCESS_KEY: test
4853
AWS_DEFAULT_REGION: us-east-1
4954
run: |
50-
make build
51-
make bootstrap
5255
make deploy
5356
5457
- name: Create Cloud Pod

.github/workflows/main.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ jobs:
3232
run: |
3333
make install
3434
35+
- name: Install CDK
36+
run: |
37+
npm install -g aws-cdk-local aws-cdk
38+
cdklocal --version
39+
3540
- name: Start LocalStack
3641
uses: LocalStack/setup-localstack@v0.2.4
3742
with:
@@ -48,8 +53,6 @@ jobs:
4853
AWS_SECRET_ACCESS_KEY: test
4954
AWS_DEFAULT_REGION: us-east-1
5055
run: |
51-
make build
52-
make bootstrap
5356
make deploy
5457
5558
- name: Integration Tests

Makefile

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,63 @@ SHELL := /bin/bash
77
usage:
88
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
99

10+
## Check if all required prerequisites are installed
11+
check:
12+
@command -v docker > /dev/null 2>&1 || { echo "Docker is not installed. Please install Docker and try again."; exit 1; }
13+
@command -v node > /dev/null 2>&1 || { echo "Node.js is not installed. Please install Node.js and try again."; exit 1; }
14+
@command -v aws > /dev/null 2>&1 || { echo "AWS CLI is not installed. Please install AWS CLI and try again."; exit 1; }
15+
@command -v localstack > /dev/null 2>&1 || { echo "LocalStack is not installed. Please install LocalStack and try again."; exit 1; }
16+
@command -v cdk > /dev/null 2>&1 || { echo "CDK is not installed. Please install CDK and try again."; exit 1; }
17+
@command -v cdklocal > /dev/null 2>&1 || { echo "cdklocal is not installed. Please install cdklocal and try again."; exit 1; }
18+
@command -v aws > /dev/null 2>&1 || { echo "AWS CLI is not installed. Please install AWS CLI and try again."; exit 1; }
19+
@command -v awslocal > /dev/null 2>&1 || { echo "awslocal is not installed. Please install awslocal and try again."; exit 1; }
20+
@echo "All required prerequisites are available."
21+
1022
## Install dependencies
1123
install:
12-
@which localstack || pip install localstack
13-
@which awslocal || pip install awscli-local
14-
@which cdklocal || npm install -g aws-cdk-local aws-cdk
24+
@if [ ! -d "node_modules" ]; then \
25+
echo "node_modules not found. Running npm install..."; \
26+
npm install; \
27+
fi
28+
@if [ ! -d "demos/rds-query-fn-code/node_modules" ]; then \
29+
echo "demos/rds-query-fn-code/node_modules not found. Running npm install..."; \
30+
npm install --prefix demos/rds-query-fn-code; \
31+
fi
32+
@echo "All required dependencies are available."
1533

1634
## Deploy the infrastructure
17-
build:
18-
npm install && cd demos/rds-query-fn-code && npm install
19-
20-
## Bootstap the CDK sample
21-
bootstrap:
22-
cdklocal bootstrap
23-
24-
## Deploy the CDK sample
2535
deploy:
36+
@echo "Bootstrapping CDK..."
37+
cdklocal bootstrap
38+
@echo "Deploying CDK..."
2639
cdklocal deploy --require-approval never
40+
@echo "CDK deployed successfully."
41+
42+
## Run the tests
43+
test:
44+
@echo "Running tests..."
45+
npm test
46+
@echo "Tests completed successfully."
2747

2848
## Start LocalStack in detached mode
2949
start:
30-
RDS_MYSQL_DOCKER=1 localstack start -d
50+
@echo "Starting LocalStack..."
51+
@LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) localstack start -d
52+
@echo "LocalStack started successfully."
3153

3254
## Stop the Running LocalStack container
3355
stop:
34-
@echo
35-
localstack stop
56+
@echo "Stopping LocalStack..."
57+
@localstack stop
58+
@echo "LocalStack stopped successfully."
3659

3760
## Make sure the LocalStack container is up
3861
ready:
3962
@echo Waiting on the LocalStack container...
4063
@localstack wait -t 30 && echo LocalStack is ready to use! || (echo Gave up waiting on LocalStack, exiting. && exit 1)
4164

42-
## Save the logs in a separate file, since the LS container will only contain the logs of the last sample run.
65+
## Save the logs in a separate file
4366
logs:
4467
@localstack logs > logs.txt
4568

46-
.PHONY: usage install bootstrap build deploy deploy start stop ready logs
69+
.PHONY: usage check start ready install deploy test logs stop

0 commit comments

Comments
 (0)