1616jobs :
1717 build :
1818 timeout-minutes : 60
19+ runs-on : ubuntu-latest
20+
1921 strategy :
2022 matrix :
2123 node-version : [16, 18, 'lts/*']
22- os : [ubuntu-latest]
23- runs-on : ${{ matrix.os }}
24- services :
25- redis :
26- image : redis
27- options : >-
28- --health-cmd "redis-cli ping"
29- --health-interval 10s
30- --health-timeout 5s
31- --health-retries 5
32- ports :
33- - 6379:6379
34- rabbitmq :
35- image : rabbitmq:latest
36- ports :
37- - 5672:5672
38- options : >-
39- --health-cmd "rabbitmqctl node_health_check"
40- --health-interval 10s
41- --health-timeout 5s
42- --health-retries 5
43- zookeeper :
44- image : wurstmeister/zookeeper
45- ports :
46- - 2181:2181
47- env :
48- ALLOW_ANONYMOUS_LOGIN : yes
49- options : >-
50- --health-cmd "echo mntr | nc -w 2 -q 2 localhost 2181"
51- --health-interval 10s
52- --health-timeout 5s
53- --health-retries 5
54- kafka :
55- image : wurstmeister/kafka
56- ports :
57- - 9092:9092
58- options : >-
59- --health-cmd "kafka-broker-api-versions.sh --version"
60- --health-interval 10s
61- --health-timeout 5s
62- --health-retries 5
63- env :
64- KAFKA_LISTENERS : PLAINTEXT://0.0.0.0:9092
65- KAFKA_ADVERTISED_LISTENERS : PLAINTEXT://localhost:9092 # # 修改:宿主机IP
66- KAFKA_ZOOKEEPER_CONNECT : " zookeeper:2181"
67- KAFKA_ADVERTISED_PORT : 9092
68-
69- # postgres:
70- # image: postgres:alpine
71- # ports:
72- # - 5432:5432
73- # env:
74- # POSTGRES_DB: db_ci_test
75- # POSTGRES_USER: postgres
76- # POSTGRES_PASSWORD: postgres
77- # # needed because the postgres container does not provide a healthcheck
78- # options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
79-
80- etcd :
81- image : bitnami/etcd
82- options : >-
83- --name Etcd-server
84- --publish 2379:2379
85- --publish 2380:2380
86- --env ALLOW_NONE_AUTHENTICATION=yes
87- --env ETCD_ADVERTISE_CLIENT_URLS=http://etcd-server:2379
8824
8925 steps :
9026 - name : Git checkout
@@ -95,32 +31,22 @@ jobs:
9531 with :
9632 node-version : ${{ matrix.node-version }}
9733
98- - name : Start MongoDB
99- uses : supercharge/mongodb-github-action@1.12.0
100- with :
101- mongodb-version : 4.2
102-
103- - name : Start Mosquitto
104- uses : namoshek/mosquitto-github-action@v1
105- with :
106- version : ' latest'
107- ports : ' 1883:1883 8883:8883'
108- config : ${{ github.workspace }}/packages/mqtt/scripts/mosquitto.conf
109- container-name : ' mqtt'
34+ - name : Set up Docker Compose
35+ run : docker-compose -f docker-compose.ci.yml up -d
11036
111- - name : Wait for services to be ready
37+ - name : Wait for containers to be ready
11238 run : |
113- echo "Waiting for RabbitMQ..."
114- for i in {1..20}; do
115- nslookup rabbitmq && nc -z rabbitmq 5672 && break
116- echo "RabbitMQ not ready, waiting..."
117- sleep 3
118- done
39+ docker-compose ps
40+ sleep 20 # docker-compose 内部 DNS 很稳,简单 sleep 即可
41+
42+ - name : Install dependencies
43+ run : npm run install_npm && npm install && npm install codecov
11944
120- - run : npm run install_npm
121- - run : npm install && npm install codecov
122- - run : npm run build --if-present
123- - run : npm run cov
45+ - name : Build
46+ run : npm run build --if-present
47+
48+ - name : Run tests with coverage
49+ run : npm run cov
12450 env :
12551 RABBITMQ_URL : amqp://rabbitmq:5672
12652 ALI_SDK_OSS_REGION : ${{ secrets.ALI_SDK_OSS_REGION }}
@@ -132,23 +58,6 @@ jobs:
13258 ALI_SDK_STS_SECRET : ${{ secrets.ALI_SDK_STS_SECRET }}
13359 ALI_SDK_STS_BUCKET : ${{ secrets.ALI_SDK_STS_BUCKET }}
13460 ALI_SDK_STS_ROLE : ${{ secrets.ALI_SDK_STS_ROLE }}
61+
13562 - name : Upload coverage to Codecov
13663 uses : codecov/codecov-action@v4
137-
138- #
139- # build-windows:
140- # runs-on: windows-latest
141- #
142- # strategy:
143- # matrix:
144- # node-version: [12, 14.x]
145- #
146- # steps:
147- # - uses: actions/checkout@v2
148- # - name: Use Node.js ${{ matrix.node-version }}
149- # uses: actions/setup-node@v1
150- # with:
151- # node-version: ${{ matrix.node-version }}
152- # - run: npm install
153- # - run: npm run build --if-present
154- # - run: npm run cov
0 commit comments