Skip to content

Commit eb25b2a

Browse files
authored
Create GitHub Actions CI pipeline for the samples (#134)
major rework of Makefiles and samples in the process
1 parent b04dfc5 commit eb25b2a

File tree

42 files changed

+662
-7875
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+662
-7875
lines changed

.github/workflows/makefile.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Makefile CI
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
schedule:
9+
- cron: '0 13 * * *' # 13:00 server time, meaning 14/15:00 our time. For regular commits in LS
10+
- cron: '0 17 * * *' # 17:00 server time, meaning 18/19:00 our time. For the "This needs to be done today" folks.
11+
- cron: '0 7 * * *' # 08:00 server time, meaning 09/10:00 our time. For the night owls and early birds.
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
19+
- name: Setup Nodejs
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: 12
23+
24+
- name: Install LocalStack
25+
run: pip install localstack awscli-local[ver1]
26+
27+
- name: Install Dependencies
28+
run: |
29+
pip install virtualenv
30+
npm install -g serverless
31+
32+
- name: Setup config
33+
run: |
34+
echo "Configuring git for codecommit sample"
35+
git config --global user.email "[email protected]"
36+
git config --global user.name "Localstack Pro-Samples"
37+
38+
- name: Pull the latest docker image
39+
run: docker pull localstack/localstack
40+
41+
- name: Execute tests
42+
env:
43+
LOCALSTACK_API_KEY: ${{ secrets.TEST_LOCALSTACK_API_KEY }}
44+
DNS_ADDRESS: 127.0.0.1
45+
DEBUG: 1
46+
run: make test-ci-all

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ node_modules/
44
.classpath
55
.project
66
.settings/
7+
.vscode/
78
target/
89

910
.idea/
@@ -27,3 +28,5 @@ testdata/
2728

2829
glacier-s3-select/*result.csv
2930
azure-functions/.python_packages/
31+
32+
*/logs.txt

.travis.yml

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

Makefile

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@ usage: ## Show this help
22
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
33

44
install: ## Install dependencies for all projects
5-
CMD='make install' make for-each-dir
5+
MAKE_TARGET='install' make for-each-dir
66

77
lint: ## Run code linter for all projects
8-
CMD='make lint' make for-each-dir
8+
MAKE_TARGET='lint' make for-each-dir
99

1010
start: ## Start LocalStack infrastructure
11-
nohup localstack start &
11+
localstack start -d
12+
13+
ready: ## Check if the LocalStack container is up and running.
14+
localstack wait -t 20 && echo "LocalStack is ready to use!"
15+
16+
stop: ## Stop LocalStack infrastructure
17+
localstack stop
1218

1319
for-each-dir:
14-
for d in $$(ls -d */); do echo "Running tests in $$d"; (cd $$d; $(CMD)) || exit 1; done
20+
./make-for-each.sh $$MAKE_TARGET $$CMD
1521

1622
test-ci-all:
17-
CMD='test ! -e Makefile || make test-ci' make for-each-dir
23+
MAKE_TARGET='test-ci' make for-each-dir
1824

19-
.PHONY: usage install lint start
25+
.PHONY: usage install lint start ready stop for-each-dir test-ci-all

apigw-custom-domain/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./sslcert/*

apigw-custom-domain/Makefile

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export AWS_ACCESS_KEY_ID ?= test
22
export AWS_SECRET_ACCESS_KEY ?= test
33
export AWS_DEFAULT_REGION ?= us-east-1
4-
export SERVICES ?= serverless,acm,route53
4+
55

66
usage: ## Show this help
77
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
@@ -11,7 +11,7 @@ install: ## Install dependencies
1111
@which serverless || npm install -g serverless
1212
@which localstack || pip install localstack
1313
@which awslocal || pip install awscli-local
14-
14+
1515
cert: ## Create test SSL certificate
1616
mkdir -p sslcert
1717
cd sslcert; \
@@ -22,7 +22,6 @@ cert: ## Create test SSL certificate
2222
openssl x509 -req -in ssl.csr -CAcreateserial -out server.crt -sha256 -CAkey rootCA.key -CA rootCA.pem
2323

2424
run: ## Deploy the app locally and run an API GW test invocation
25-
@make install; \
2625
echo "Generating and importing test SSL certificate to ACM for Route53 domain test.example.com"; \
2726
make cert; \
2827
echo "Importing local test certificate into ACM API ..."; \
@@ -33,11 +32,27 @@ run: ## Deploy the app locally and run an API GW test invocation
3332
SLS_DEBUG=1 npm run deploy && \
3433
echo "Serverless app successfully deployed. Now trying to invoke the API Gateway endpoints with custom domains." && \
3534
echo && echo "Invoking endpoint 1: http://test.example.com:4566/hello" && \
36-
curl -H 'Host: test.example.com' http://localhost:4566/hello && \
35+
response1=`curl -H 'Host: test.example.com' http://localhost:4566/hello` && \
36+
../assert "$$response1" = "hello world" && \
3737
echo && echo && echo "Invoking endpoint 2: http://test.example.com:4566/goodbye" && \
38-
curl -H 'Host: test.example.com' http://localhost:4566/goodbye
38+
response2=`curl -H 'Host: test.example.com' http://localhost:4566/goodbye` && \
39+
../assert "$$response2" = "goodbye"
40+
41+
start:
42+
localstack start -d
43+
44+
stop:
45+
@echo
46+
localstack stop
47+
ready:
48+
@echo Waiting on the LocalStack container...
49+
@localstack wait -t 30 && echo Localstack is ready to use! || (echo Gave up waiting on LocalStack, exiting. && exit 1)
50+
51+
logs:
52+
@localstack logs > logs.txt
3953

4054
test-ci:
41-
make install && make run || true
55+
make start install ready run; return_code=`echo $$?`;\
56+
make logs; make stop; exit $$return_code;
4257

43-
.PHONY: usage install run cert
58+
.PHONY: usage install run cert ready stop logs test-ci

0 commit comments

Comments
 (0)