@@ -2,9 +2,9 @@ name: Test Matrix
22
33on :
44 push :
5- branches : [ main, master, dove ]
5+ branches : [main, master, dove]
66 pull_request :
7- branches : [ main, master, dove ]
7+ branches : [main, master, dove]
88
99jobs :
1010 test :
@@ -18,48 +18,68 @@ jobs:
1818 name : Node ${{ matrix.node-version }} - ES ${{ matrix.elasticsearch-version }}
1919
2020 steps :
21- - uses : actions/checkout@v3
21+ - uses : actions/checkout@v3
2222
23- - name : Use Node.js ${{ matrix.node-version }}
24- uses : actions/setup-node@v3
25- with :
26- node-version : ${{ matrix.node-version }}
23+ - name : Use Node.js ${{ matrix.node-version }}
24+ uses : actions/setup-node@v3
25+ with :
26+ node-version : ${{ matrix.node-version }}
2727
28- - name : Start Elasticsearch ${{ matrix.elasticsearch-version }}
29- run : |
30- docker run -d \
31- --name elasticsearch \
32- -p 9200:9200 \
33- -e "discovery.type=single-node" \
34- -e "xpack.security.enabled=false" \
35- -e "xpack.security.enrollment.enabled=false" \
36- docker.elastic.co/elasticsearch/elasticsearch:${{ matrix.elasticsearch-version }}
28+ - name : Start Elasticsearch ${{ matrix.elasticsearch-version }}
29+ run : |
30+ docker run -d \
31+ --name elasticsearch \
32+ -p 9200:9200 \
33+ -e "discovery.type=single-node" \
34+ -e "xpack.security.enabled=false" \
35+ -e "xpack.security.enrollment.enabled=false" \
36+ docker.elastic.co/elasticsearch/elasticsearch:${{ matrix.elasticsearch-version }}
3737
38- - name : Wait for Elasticsearch
39- run : |
40- for i in {1..30}; do
41- if curl -s "http://localhost:9200/_cluster/health" > /dev/null 2>&1; then
42- echo "Elasticsearch is ready"
43- break
44- fi
45- echo "Waiting for Elasticsearch..."
46- sleep 5
47- done
38+ - name : Wait for Elasticsearch
39+ run : |
40+ echo "Waiting for Elasticsearch to be ready..."
41+ for i in {1..60}; do
42+ # Check cluster health status
43+ HEALTH=$(curl -s "http://localhost:9200/_cluster/health" 2>/dev/null || echo "")
44+ if [ ! -z "$HEALTH" ]; then
45+ STATUS=$(echo $HEALTH | grep -o '"status":"[^"]*"' | cut -d'"' -f4)
46+ echo "Attempt $i: Cluster status is '$STATUS'"
4847
49- - name : Install dependencies
50- run : npm ci
48+ # Wait for yellow or green status (yellow is ok for single-node)
49+ if [ "$STATUS" = "yellow" ] || [ "$STATUS" = "green" ]; then
50+ echo "Elasticsearch is ready!"
51+ # Give it a bit more time to fully stabilize
52+ sleep 5
53+ curl -s "http://localhost:9200/_cluster/health?pretty"
54+ break
55+ fi
56+ else
57+ echo "Attempt $i: Elasticsearch not responding yet..."
58+ fi
5159
52- - name : Build
53- run : npm run build
60+ if [ $i -eq 60 ]; then
61+ echo "ERROR: Elasticsearch failed to become ready after 5 minutes"
62+ docker logs elasticsearch
63+ exit 1
64+ fi
5465
55- - name : Run tests
56- run : |
57- ES_VERSION=${{ matrix.elasticsearch-version }} \
58- ELASTICSEARCH_URL=http://localhost:9200 \
59- npm run mocha
66+ sleep 5
67+ done
6068
61- - name : Upload coverage
62- if : matrix.node-version == '20' && matrix.elasticsearch-version == '8.15.0'
63- uses : codecov/codecov-action@v3
64- with :
65- file : ./coverage/lcov.info
69+ - name : Install dependencies
70+ run : npm ci
71+
72+ - name : Build
73+ run : npm run build
74+
75+ - name : Run tests
76+ run : |
77+ ES_VERSION=${{ matrix.elasticsearch-version }} \
78+ ELASTICSEARCH_URL=http://localhost:9200 \
79+ npm run mocha
80+
81+ - name : Upload coverage
82+ if : matrix.node-version == '20' && matrix.elasticsearch-version == '8.15.0'
83+ uses : codecov/codecov-action@v3
84+ with :
85+ file : ./coverage/lcov.info
0 commit comments