-
Notifications
You must be signed in to change notification settings - Fork 0
201 lines (166 loc) · 4.74 KB
/
go.yml
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
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go
on:
push:
branches: [ "master", "v2" ]
pull_request:
branches: [ "master", "v2" ]
jobs:
test-root:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.22.x' ]
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.0'
- name: Install dependencies
run: go mod download
- name: Build
run: go build -v ./...
- name: Clear cache
run: go clean -testcache
- name: Test
run: go test -cover ./...
- name: Remove temp file
run: rm -rf middleware/logger/logs common/exception/logs
test-redis:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.22.x' ]
# Service containers to run with `container-job`
services:
# Label used to access the service container
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps port 6379 on service container to the host
- 6379:6379
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.0'
- name: Test Redis
run: cd microservices/redis; go test -cover ./...
test-nats:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.22.x' ]
# Service containers to run with `container-job`
services:
# Label used to access the service container
nats:
# Docker Hub image
image: nats:latest
ports:
# Maps port 6379 on service container to the host
- 4222:4222
steps:
# Checkout code
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.0'
# Verify NATS Server is Running
- name: Verify NATS Server
run: |
echo "Checking if NATS server is running on port 4222..."
nc -zv 127.0.0.1 4222
- name: Test NATS
run: cd microservices/nats; go test -cover ./...
test-rabbitmq:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.22.x' ]
services:
rabbitmq:
image: rabbitmq:3.8
env:
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest
ports:
- 5672:5672 # RabbitMQ default port
- 15672:15672 # RabbitMQ Management Plugin
options: >-
--health-cmd "rabbitmqctl status"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
# Checkout code
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.0'
- name: Wait for RabbitMQ to be ready
run: |
for i in {1..10}; do
if nc -z localhost 5672; then
echo "RabbitMQ is up and running"
break
fi
echo "Waiting for RabbitMQ..."
sleep 5
done
- name: Test RabbitMQ
run: cd microservices/amqlib; go test -cover ./...
# test-kafka:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# go-version: [ '1.22.x' ]
# services:
# zookeeper:
# image: confluentinc/cp-zookeeper:7.5.0
# ports:
# - 2181:2181
# options: >-
# --env ZOOKEEPER_CLIENT_PORT=2181
# --env ZOOKEEPER_TICK_TIME=2000
# kafka:
# image: confluentinc/cp-kafka:7.5.0
# ports:
# - 9092:9092
# options: >-
# --env KAFKA_BROKER_ID=1
# --env KAFKA_ZOOKEEPER_CONNECT=127.0.0.1:2181
# --env KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9092
# --env KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092
# --env KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1
# steps:
# # Checkout code
# - uses: actions/checkout@v4
# - name: Set up Go
# uses: actions/setup-go@v4
# with:
# go-version: '1.22.0'
# - name: Wait for Kafka to be ready
# run: |
# for i in {1..10}; do
# if nc -z localhost 9092; then
# echo "Kafka is up and running"
# break
# fi
# echo "Waiting for Kafka..."
# sleep 5
# done
# - name: Test Kafka
# run: cd microservices/kafka; go test -cover ./...