generated from MapColonies/ts-server-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
208 lines (174 loc) · 5.26 KB
/
pull_request.yaml
File metadata and controls
208 lines (174 loc) · 5.26 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
name: pull_request
on: [pull_request, workflow_dispatch]
jobs:
eslint:
name: Run eslint
runs-on: ubuntu-latest
strategy:
matrix:
node: [20.x, 22.x]
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: npm ci
- name: Run linters
uses: wearerequired/lint-action@v2
with:
github_token: ${{ secrets.github_token }}
# Enable linters
eslint: true
prettier: true
eslint_extensions: ts
integration-test:
name: Run Integration Tests
runs-on: ubuntu-latest
strategy:
matrix:
node: [20, 22]
container:
image: node:${{ matrix.node }}
services:
# Label used to access the service container
elasticsearch:
# Docker Hub image
image: elasticsearch:8.13.0
env:
discovery.type: single-node
xpack.security.enabled: false
xpack.security.enrollment.enabled: false
ES_JAVA_OPTS: '-Xms512m -Xmx512m'
ports:
- 9200:9200
# Set health checks to wait until elastic has started
options: >-
--health-cmd "curl -f http://localhost:9200/_cluster/health || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5
minio:
# Docker Hub image
image: minio/minio:edge-cicd
env:
MINIO_ROOT_USER: minio
MINIO_ROOT_PASSWORD: minio123
ports:
- 9000:9000
# Set health checks to wait until elastic has started
options: >-
--health-cmd "curl -f http://localhost:9000/minio/health/live || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Install Node.js dependencies
run: npm ci
- name: Wait for Elasticsearch
run: |
until curl -s http://elasticsearch:9200/_cluster/health | grep '"status":"green"'; do
echo "Waiting for Elasticsearch...";
sleep 5;
done
- name: Run integration tests
run: npm run test:integration
- uses: actions/upload-artifact@v4
with:
name: Integration Test Reporters (Node ${{ matrix.node }})
path: reports/**
unit-test:
name: Run Unit Tests
runs-on: ubuntu-latest
strategy:
matrix:
node: [20, 22]
container:
image: node:${{ matrix.node }}
services:
# Label used to access the service container
elasticsearch:
# Docker Hub image
image: elasticsearch:8.13.0
env:
discovery.type: single-node
xpack.security.enabled: false
xpack.security.enrollment.enabled: false
ES_JAVA_OPTS: '-Xms512m -Xmx512m'
ports:
- 9200:9200
# Set health checks to wait until elastic has started
options: >-
--health-cmd "curl -f http://localhost:9200/_cluster/health || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5
minio:
# Docker Hub image
image: minio/minio:edge-cicd
env:
MINIO_ROOT_USER: minio
MINIO_ROOT_PASSWORD: minio123
ports:
- 9000:9000
# Set health checks to wait until elastic has started
options: >-
--health-cmd "curl -f http://localhost:9000/minio/health/live || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Install Node.js dependencies
run: npm ci
- name: Wait for Elasticsearch
run: |
until curl -s http://elasticsearch:9200/_cluster/health | grep '"status":"green"'; do
echo "Waiting for Elasticsearch...";
sleep 5;
done
- name: Run unit tests
run: npm run test:unit
- uses: actions/upload-artifact@v4
with:
name: Unit Test Reporters (Node ${{ matrix.node }})
path: reports/**
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/node@master
continue-on-error: true
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
build_image:
name: Build Image
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: build Docker image
run: docker build -t test-build:latest .