updated syntax checker #54
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Spring Boot Syntax Check and Test Reporting | |
on: [push, pull_request] | |
permissions: | |
checks: write | |
contents: read | |
jobs: | |
# 1. Compilation Check (blocks merge if compilation fails) | |
compile-check: | |
name: Compilation Check | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Cache Maven dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-maven- | |
- name: Compile the project (syntax check) | |
run: mvn clean compile -DskipTests | |
- name: Compile tests (syntax check for test files) | |
run: mvn test-compile -DskipTests | |
# 2. Test Check (does not block merge even if tests fail) | |
test-check: | |
name: Test Suite Check | |
runs-on: ubuntu-latest | |
needs: compile-check # Ensures tests run only if compilation succeeds | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Cache Maven dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-maven- | |
- name: Run test suite | |
run: mvn test || true # Prevent workflow failure if tests fail | |
- name: Publish Test Results | |
uses: dorny/test-reporter@v1 | |
if: always() # Always run this even if tests fail | |
with: | |
name: JUnit Tests | |
path: target/surefire-reports/*.xml | |
reporter: java-junit | |
fail-on-error: false # Allow merge even if tests fail | |
- name: Upload Test Reports | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-reports | |
path: target/surefire-reports/ |