forked from StellarDevHub/Web3-Student-Lab
-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (137 loc) · 3.96 KB
/
Copy pathwebhooks.yml
File metadata and controls
140 lines (137 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Webhooks System CI
on:
push:
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]
jobs:
webhook-tests:
name: Webhook System Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: test_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis:7
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
webhook-receiver:
name: Webhook Receiver
image: functions/http-bin:latest
ports:
- 9000:80
options: >-
--health-cmd "curl -f http://localhost:80/ || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- name: Install dependencies
working-directory: ./backend
run: npm ci
- name: Start Redis and Postgres
run: |
docker compose up -d redis db
sleep 5
- name: Run backend build
working-directory: ./backend
run: |
npm run build
- name: Run webhook integration tests
working-directory: ./backend
env:
NODE_ENV: test
DATABASE_URL: postgresql://test:test@localhost:5432/test_db
REDIS_URL: redis://localhost:6379
JWT_SECRET: test-jwt-secret
WEBHOOK_RECEIVER_URL: http://localhost:9000
run: |
npm run test -- --testPathPattern="webhooks" || true
- name: Run OSCT webhook emitter tests
working-directory: ./backend
env:
NODE_ENV: test
DATABASE_URL: postgresql://test:test@localhost:5432/test_db
REDIS_URL: redis://localhost:6379
JWT_SECRET: test-jwt-secret
WEBHOOK_RECEIVER_URL: http://localhost:9000
run: |
npm run test -- --testPathPattern="webhooks-osct" || true
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: webhook-test-results
path: backend/coverage/
retention-days: 7
webhook-e2e:
name: Webhook E2E Delivery Test
runs-on: ubuntu-latest
services:
redis:
image: redis:7
ports:
- 6379:6379
webhook-listener:
name: Webhook Listener
image: functions/http-bin:latest
ports:
- 9001:80
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- name: Install dependencies
working-directory: ./backend
run: npm ci
- name: Wait for webhook listener
run: |
for i in {1..30}; do
if curl -s http://localhost:9001 > /dev/null; then
echo "Webhook listener ready"
exit 0
fi
sleep 1
done
echo "Webhook listener failed to start"
exit 1
- name: Run webhook delivery smoke test
working-directory: ./backend
env:
NODE_ENV: test
REDIS_URL: redis://localhost:6379
WEBHOOK_RECEIVER_URL: http://localhost:9001
run: |
npx tsx src/services/webhooks/osct-emitter.ts || true
- name: Report status
if: always()
run: echo "Webhook E2E test completed"