Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions .github/workflows/ci-reports.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: CI Reports

on:
push:
branches:
- main
- 'features/**'
pull_request:
branches:
- main

jobs:
ci-reports:
runs-on: ubuntu-latest
env:
RUN_LIVE_E2E: "false"

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'

# ===== TESTING =====
- name: Run unit tests from module root
run: ./mvnw -B -ntp clean test
working-directory: .

# ===== CODE COVERAGE =====
- name: Generate JaCoCo coverage report
run: ./mvnw -B -ntp jacoco:report

# ===== STATIC ANALYSIS =====
- name: Generate PMD HTML report
run: ./mvnw -B -ntp pmd:pmd -Dpmd.failOnViolation=false

- name: Run Checkstyle
run: ./mvnw -B -ntp checkstyle:checkstyle

# ===== OPTIONAL LIVE E2E (requires LIVE_E2E env + external deps) =====
- name: Run live E2E (opt-in)
if: env.RUN_LIVE_E2E == 'true'
env:
LIVE_E2E: "true"
run: ./mvnw -B -ntp -Dtest=dev.coms4156.project.metadetect.e2e.ClientServiceLiveE2eTest test

# ===== CONVERT TO PNG =====
- name: Install wkhtmltopdf for report conversion
run: |
sudo apt-get update
sudo apt-get install -y wkhtmltopdf

- name: Make conversion script executable
run: chmod +x scripts/html_to_png.sh

- name: Convert HTML reports to PNG
run: bash scripts/html_to_png.sh

- name: Collect additional raw artifacts into /reports
if: always()
run: |
mkdir -p reports/test-results reports/raw
if [ -d "target/surefire-reports" ]; then
cp -R target/surefire-reports/. reports/test-results/
fi
if [ -f "target/pmd.xml" ]; then
cp target/pmd.xml reports/raw/pmd.xml
fi
if [ -f "target/checkstyle-result.xml" ]; then
cp target/checkstyle-result.xml reports/raw/checkstyle-result.xml
fi
if [ -f "target/site/jacoco/jacoco.xml" ]; then
cp target/site/jacoco/jacoco.xml reports/raw/jacoco.xml
fi

# ===== QUALITY GATES =====
- name: Enforce PMD violations
run: ./mvnw -B -ntp pmd:check

# ===== UPLOAD ARTIFACTS =====
- name: Upload CI reports (HTML, PNG, XML)
uses: actions/upload-artifact@v4
if: always()
with:
name: ci-reports
path: |
reports/
target/surefire-reports/
retention-days: 30

# ===== SUMMARY =====
- name: Generate CI Summary
if: always()
run: |
echo "## 📊 CI Report Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Test Results" >> $GITHUB_STEP_SUMMARY
if [ -d "target/surefire-reports" ]; then
TESTS=$(find target/surefire-reports -name "TEST-*.xml" | wc -l)
echo "- Test suites executed: $TESTS" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Available Reports" >> $GITHUB_STEP_SUMMARY
echo "- ✅ JaCoCo coverage (HTML + PNG snapshot)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ PMD static analysis (HTML + PNG snapshot)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Unit test XML results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📥 Download Artifacts" >> $GITHUB_STEP_SUMMARY
echo "All consolidated under the 'ci-reports' artifact (reports/ + surefire XML)." >> $GITHUB_STEP_SUMMARY
51 changes: 40 additions & 11 deletions .github/workflows/maven-main.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,53 @@
name: main Branch
name: Build and Test

on:
push:
branches:
- 'main'
- 'features/**'
pull_request:
branches:
- main

jobs:

test:
name: Test - Units & Integrations
build:
name: Build and Test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 4
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '18'
- name: Maven Package
run: mvn -B -f IndividualProject/pom.xml clean package -DskipTests
- name: Maven Verify
run: mvn -B -f IndividualProject/pom.xml clean verify -Pintegration-test
java-version: '17'

- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build with Maven
run: ./mvnw -B clean compile

- name: Run unit tests
run: ./mvnw -B test

- name: Package application
run: ./mvnw -B package -DskipTests

- name: Verify build artifacts
run: |
echo "Checking build output..."
ls -lh target/*.jar

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: application-jar
path: target/*.jar
retention-days: 7
Loading