Skip to content

Commit 9a4e5a3

Browse files
authored
revamp the ci workflows (#13)
* upgrade ci workflows to node 22 * add a keepalive workflow * create a cloud pods workflow * remove visibility flag * add npm caching * don't ignore package-lock * run cloud pods action only on push, cron and workflow dispatch * rename main workflow
1 parent b523198 commit 9a4e5a3

File tree

6 files changed

+8036
-24
lines changed

6 files changed

+8036
-24
lines changed

.github/workflows/cloud-pods.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Create and Test Cloud Pods
2+
3+
on:
4+
schedule:
5+
# At 00:00 on Saturday.
6+
- cron: "0 0 * * 6"
7+
push:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: write
14+
actions: read
15+
16+
jobs:
17+
create-cloud-pod:
18+
name: Create Cloud Pods
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout Code
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Nodejs
25+
uses: actions/setup-node@v3
26+
with:
27+
node-version: 22
28+
cache: 'npm'
29+
30+
- name: Install dependencies
31+
run: |
32+
make install
33+
34+
- name: Start LocalStack
35+
uses: LocalStack/setup-localstack@main
36+
with:
37+
image-tag: 'latest'
38+
use-pro: 'true'
39+
configuration: LS_LOG=trace
40+
install-awslocal: 'true'
41+
env:
42+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
43+
44+
- name: Deploy the application
45+
env:
46+
AWS_ACCESS_KEY_ID: test
47+
AWS_SECRET_ACCESS_KEY: test
48+
AWS_DEFAULT_REGION: us-east-1
49+
run: |
50+
make build
51+
make bootstrap
52+
make deploy
53+
54+
- name: Create Cloud Pod
55+
env:
56+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
57+
run: |
58+
message="Cloud Pod created: sample-cdk-rds on $(date) with workflow run id: ${{ github.run_id }}"
59+
localstack pod save sample-cdk-rds --message "$message"
60+
61+
- name: Show LocalStack Logs
62+
if: always()
63+
run: |
64+
localstack logs
65+
66+
test-cloud-pod:
67+
name: Test Cloud Pod
68+
needs: create-cloud-pod
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Checkout Code
72+
uses: actions/checkout@v4
73+
74+
- name: Setup Nodejs
75+
uses: actions/setup-node@v3
76+
with:
77+
node-version: 22
78+
cache: 'npm'
79+
80+
- name: Start LocalStack
81+
uses: LocalStack/setup-localstack@main
82+
with:
83+
use-pro: 'true'
84+
install-awslocal: 'true'
85+
env:
86+
DEBUG: 1
87+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
88+
89+
- name: Load Cloud Pod
90+
env:
91+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
92+
run: |
93+
localstack pod load sample-cdk-rds
94+
95+
- name: Install dependencies
96+
run: |
97+
npm install
98+
99+
- name: Run Integration Tests
100+
run: |
101+
npm test
102+
103+
- name: Show LocalStack Logs
104+
if: always()
105+
run: |
106+
localstack logs
107+
108+
- name: Send a Slack notification
109+
if: failure() || github.event_name != 'pull_request'
110+
uses: ravsamhq/notify-slack-action@v2
111+
with:
112+
status: ${{ job.status }}
113+
token: ${{ secrets.GITHUB_TOKEN }}
114+
notification_title: "{workflow} has {status_message}"
115+
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
116+
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Workflow run>"
117+
notify_when: "failure"
118+
env:
119+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
120+
121+
- name: Generate a Diagnostic Report
122+
if: failure()
123+
run: |
124+
curl -s localhost:4566/_localstack/diagnose | gzip -cf > diagnose.json.gz
125+
126+
- name: Upload the Diagnostic Report
127+
if: failure()
128+
uses: actions/upload-artifact@v4
129+
with:
130+
name: diagnose.json.gz
131+
path: ./diagnose.json.gz

.github/workflows/keepalive.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Keep Alive
2+
on:
3+
schedule:
4+
- cron: "0 0 * * *"
5+
jobs:
6+
main-job:
7+
name: Main Job
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
workflow-keepalive:
12+
if: github.event_name == 'schedule'
13+
runs-on: ubuntu-latest
14+
permissions:
15+
actions: write
16+
steps:
17+
- uses: liskin/gh-workflow-keepalive@v1

.github/workflows/main.yml

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy on LocalStack
1+
name: Deploy on LocalStack with CDK
22

33
on:
44
push:
@@ -15,41 +15,32 @@ on:
1515
workflow_dispatch:
1616

1717
jobs:
18-
smoke-test:
19-
name: Setup infrastructure
18+
integration-tests:
19+
name: Run Integration Tests
2020
runs-on: ubuntu-latest
2121
steps:
2222
- name: Checkout
23-
uses: actions/checkout@v3
24-
25-
- name: Setup Python
26-
uses: actions/setup-python@v4
27-
with:
28-
python-version: '3.9'
23+
uses: actions/checkout@v4
2924

3025
- name: Setup Nodejs
3126
uses: actions/setup-node@v3
3227
with:
33-
node-version: 16
28+
node-version: 22
29+
cache: 'npm'
3430

3531
- name: Install dependencies
3632
run: |
3733
make install
3834
3935
- name: Start LocalStack
36+
uses: LocalStack/setup-localstack@v0.2.4
37+
with:
38+
image-tag: 'latest'
39+
use-pro: 'true'
40+
configuration: LS_LOG=trace
41+
install-awslocal: 'true'
4042
env:
41-
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
42-
LOCALSTACK_VOLUME_DIR: ${{ github.workspace }}/ls_test
43-
run: |
44-
mkdir ls_test
45-
ls -la ls_test
46-
docker pull localstack/localstack-pro:latest
47-
# Start LocalStack in the background
48-
LS_LOG=trace localstack start -d
49-
# Wait 30 seconds for the LocalStack container to become ready before timing out
50-
echo "Waiting for LocalStack startup..."
51-
localstack wait -t 15
52-
echo "Startup complete"
43+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
5344

5445
- name: Deploy the application
5546
env:

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,3 @@ node_modules
99
cdk.out
1010

1111
.npmrc
12-
13-
package-lock.json

0 commit comments

Comments
 (0)