Compare commits
2 Commits
1f53b3ec39
...
7cf0819b58
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7cf0819b58 | ||
|
|
764ae1ea84 |
@@ -63,8 +63,49 @@ jobs:
|
|||||||
- name: Compile code
|
- name: Compile code
|
||||||
run: ./mvnw compile
|
run: ./mvnw compile
|
||||||
|
|
||||||
|
- name: Check for test files
|
||||||
|
run: |
|
||||||
|
echo "Checking for test files in src/test/java/..."
|
||||||
|
if [ -d "src/test/java" ]; then
|
||||||
|
TEST_COUNT=$(find src/test/java -name "*Test*.java" -type f | wc -l)
|
||||||
|
echo "Found $TEST_COUNT test files"
|
||||||
|
if [ $TEST_COUNT -eq 0 ]; then
|
||||||
|
echo "⚠️ No test files found! Please add test files to src/test/java/"
|
||||||
|
echo "TEST_FILES_EXIST=false" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "✅ Test files found"
|
||||||
|
echo "TEST_FILES_EXIST=true" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "❌ No src/test/java directory found!"
|
||||||
|
echo "TEST_FILES_EXIST=false" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Fail if no test files exist
|
||||||
|
if: env.TEST_FILES_EXIST == 'false'
|
||||||
|
run: |
|
||||||
|
echo "❌ No test files found in src/test/java/"
|
||||||
|
echo "This pipeline requires test files to be present."
|
||||||
|
echo "Please add test files with names ending in 'Test.java' or 'Tests.java'"
|
||||||
|
echo "Example: src/test/java/com/labfusion/MyServiceTest.java"
|
||||||
|
exit 1
|
||||||
|
|
||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
run: ./mvnw test
|
run: |
|
||||||
|
echo "Running Maven tests..."
|
||||||
|
./mvnw test -X
|
||||||
|
echo "Maven test execution completed"
|
||||||
|
echo "Checking target directory structure..."
|
||||||
|
find target -name "*.xml" -type f 2>/dev/null || echo "No XML files found in target"
|
||||||
|
echo "Checking surefire-reports directory..."
|
||||||
|
if [ -d "target/surefire-reports" ]; then
|
||||||
|
echo "Contents of surefire-reports:"
|
||||||
|
ls -la target/surefire-reports/
|
||||||
|
else
|
||||||
|
echo "surefire-reports directory does not exist"
|
||||||
|
echo "Creating surefire-reports directory..."
|
||||||
|
mkdir -p target/surefire-reports
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Check test reports
|
- name: Check test reports
|
||||||
run: |
|
run: |
|
||||||
@@ -74,22 +115,36 @@ jobs:
|
|||||||
ls -la target/surefire-reports/
|
ls -la target/surefire-reports/
|
||||||
if [ -n "$(find target/surefire-reports -name '*.xml' -type f)" ]; then
|
if [ -n "$(find target/surefire-reports -name '*.xml' -type f)" ]; then
|
||||||
echo "✅ Found test report XML files"
|
echo "✅ Found test report XML files"
|
||||||
|
echo "TEST_REPORTS_EXIST=true" >> $GITHUB_ENV
|
||||||
else
|
else
|
||||||
echo "⚠️ No XML files found in surefire-reports"
|
echo "⚠️ No XML files found in surefire-reports"
|
||||||
|
echo "TEST_REPORTS_EXIST=false" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "❌ Surefire reports directory does not exist"
|
echo "❌ Surefire reports directory does not exist"
|
||||||
|
echo "TEST_REPORTS_EXIST=false" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Generate test report
|
- name: Generate test report
|
||||||
uses: dorny/test-reporter@v1
|
uses: dorny/test-reporter@v1
|
||||||
if: always() && (success() || failure())
|
if: env.TEST_REPORTS_EXIST == 'true'
|
||||||
continue-on-error: true
|
|
||||||
with:
|
with:
|
||||||
name: Maven Tests (Java ${{ matrix.java-version }})
|
name: Maven Tests (Java ${{ matrix.java-version }})
|
||||||
path: target/surefire-reports/*.xml
|
path: target/surefire-reports/*.xml
|
||||||
reporter: java-junit
|
reporter: java-junit
|
||||||
|
|
||||||
|
- name: Fail if no test reports found
|
||||||
|
if: env.TEST_REPORTS_EXIST == 'false'
|
||||||
|
run: |
|
||||||
|
echo "❌ No test reports were generated!"
|
||||||
|
echo "This indicates that either:"
|
||||||
|
echo "1. No test files were found in src/test/java/"
|
||||||
|
echo "2. Tests failed to execute properly"
|
||||||
|
echo "3. Maven Surefire plugin did not generate reports"
|
||||||
|
echo ""
|
||||||
|
echo "Please ensure you have test files and they are executing correctly."
|
||||||
|
exit 1
|
||||||
|
|
||||||
- name: Run code quality checks
|
- name: Run code quality checks
|
||||||
run: |
|
run: |
|
||||||
./mvnw spotbugs:check
|
./mvnw spotbugs:check
|
||||||
|
|||||||
@@ -115,6 +115,20 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Maven Surefire Plugin for Test Reports -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>3.1.2</version>
|
||||||
|
<configuration>
|
||||||
|
<includes>
|
||||||
|
<include>**/*Tests.java</include>
|
||||||
|
<include>**/*Test.java</include>
|
||||||
|
</includes>
|
||||||
|
<reportsDirectory>target/surefire-reports</reportsDirectory>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
Reference in New Issue
Block a user