-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (154 loc) · 5.45 KB
/
test.yml
File metadata and controls
177 lines (154 loc) · 5.45 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
name: Run Tests
on:
pull_request:
branches:
- main
- '*.*.*'
push:
branches:
- main
- '*.*.*'
jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Run unit tests with coverage
run: mvn clean test jacoco:report -Dspring.profiles.active=test
- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: unit-tests
parallel: false
continue-on-error: true
- name: Publish test results
if: always()
uses: dorny/test-reporter@v1
with:
name: Unit Test Results
path: target/surefire-reports/*.xml
reporter: java-junit
fail-on-error: false
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
# Docker service container for OpenSearch
services:
opensearch:
image: opensearchproject/opensearch:2.11.1
env:
discovery.type: single-node
plugins.security.disabled: 'true'
OPENSEARCH_JAVA_OPTS: '-Xms512m -Xmx512m'
ports:
- 9200:9200
- 9600:9600
options: >-
--health-cmd "curl -f http://localhost:9200/_cluster/health || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 10
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Wait for OpenSearch to be ready
run: |
echo "Waiting for OpenSearch..."
timeout 60 bash -c 'until curl -f http://localhost:9200/_cluster/health > /dev/null 2>&1; do sleep 2; done'
echo "OpenSearch is ready!"
- name: Verify OpenSearch health
run: |
echo "OpenSearch Status:"
curl -f http://localhost:9200/_cluster/health?pretty
- name: List integration test files
run: |
echo "Looking for integration test files..."
find src/test/java -name '*IntegrationTest.java' -o -name '*IT.java' || echo "No integration test files found"
- name: Run integration tests
run: |
echo "Running integration tests..."
mvn verify -Dspring.profiles.active=integration || echo "Tests completed with exit code $?"
echo ""
echo "Checking for test execution..."
if [ -d "target/failsafe-reports" ]; then
echo "Failsafe reports directory exists"
ls -la target/failsafe-reports/ || echo "Directory is empty"
else
echo "Failsafe reports directory does not exist"
fi
continue-on-error: true
env:
ES_HOST: localhost
ES_PORT: 9200
ES_SCHEME: http
- name: Check for integration test reports
id: check-reports
if: always()
run: |
echo "Checking for test reports..."
if [ -d "target/failsafe-reports" ]; then
echo "Directory exists, looking for XML files..."
find target/failsafe-reports -name '*.xml' || echo "No XML files found"
if [ -n "$(find target/failsafe-reports -name 'TEST-*.xml' 2>/dev/null)" ]; then
echo "reports_exist=true" >> $GITHUB_OUTPUT
echo "✓ Integration test reports found:"
ls -la target/failsafe-reports/TEST-*.xml
# Create a clean directory with only test reports (exclude summary)
mkdir -p target/test-reports
cp target/failsafe-reports/TEST-*.xml target/test-reports/ || true
echo "Copied test reports to target/test-reports/"
else
echo "reports_exist=false" >> $GITHUB_OUTPUT
echo "ℹ No XML reports found in failsafe-reports directory"
fi
else
echo "reports_exist=false" >> $GITHUB_OUTPUT
echo "ℹ No failsafe-reports directory found"
fi
- name: Publish integration test results
if: always() && steps.check-reports.outputs.reports_exist == 'true'
uses: dorny/test-reporter@v1
with:
name: Integration Test Results
path: target/test-reports/*.xml
reporter: java-junit
fail-on-error: false
- name: Integration tests summary
if: always()
run: |
if [ "${{ steps.check-reports.outputs.reports_exist }}" == "true" ]; then
echo "✓ Integration tests executed and reported"
else
echo "ℹ No integration tests found - skipping test report publishing"
echo "This is expected if you haven't created any *IntegrationTest.java files yet"
fi
- name: Upload test logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: integration-test-logs
path: |
target/surefire-reports/
target/failsafe-reports/
*.log