Skip to content

Commit f7f2282

Browse files
Merge pull request #44 from Jalen-Stephens/features/CICD-Workflow
Features/cicd workflow
2 parents b227c16 + 337ba3b commit f7f2282

24 files changed

Lines changed: 2837 additions & 44 deletions

.github/workflows/ci-reports.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: CI Reports
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- 'features/**'
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
ci-reports:
14+
runs-on: ubuntu-latest
15+
env:
16+
RUN_LIVE_E2E: "false"
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up JDK 17
23+
uses: actions/setup-java@v4
24+
with:
25+
java-version: '17'
26+
distribution: 'temurin'
27+
cache: 'maven'
28+
29+
# ===== TESTING =====
30+
- name: Run unit tests from module root
31+
run: ./mvnw -B -ntp clean test
32+
working-directory: .
33+
34+
# ===== CODE COVERAGE =====
35+
- name: Generate JaCoCo coverage report
36+
run: ./mvnw -B -ntp jacoco:report
37+
38+
# ===== STATIC ANALYSIS =====
39+
- name: Generate PMD HTML report
40+
run: ./mvnw -B -ntp pmd:pmd -Dpmd.failOnViolation=false
41+
42+
- name: Run Checkstyle
43+
run: ./mvnw -B -ntp checkstyle:checkstyle
44+
45+
# ===== OPTIONAL LIVE E2E (requires LIVE_E2E env + external deps) =====
46+
- name: Run live E2E (opt-in)
47+
if: env.RUN_LIVE_E2E == 'true'
48+
env:
49+
LIVE_E2E: "true"
50+
run: ./mvnw -B -ntp -Dtest=dev.coms4156.project.metadetect.e2e.ClientServiceLiveE2eTest test
51+
52+
# ===== CONVERT TO PNG =====
53+
- name: Install wkhtmltopdf for report conversion
54+
run: |
55+
sudo apt-get update
56+
sudo apt-get install -y wkhtmltopdf
57+
58+
- name: Make conversion script executable
59+
run: chmod +x scripts/html_to_png.sh
60+
61+
- name: Convert HTML reports to PNG
62+
run: bash scripts/html_to_png.sh
63+
64+
- name: Collect additional raw artifacts into /reports
65+
if: always()
66+
run: |
67+
mkdir -p reports/test-results reports/raw
68+
if [ -d "target/surefire-reports" ]; then
69+
cp -R target/surefire-reports/. reports/test-results/
70+
fi
71+
if [ -f "target/pmd.xml" ]; then
72+
cp target/pmd.xml reports/raw/pmd.xml
73+
fi
74+
if [ -f "target/checkstyle-result.xml" ]; then
75+
cp target/checkstyle-result.xml reports/raw/checkstyle-result.xml
76+
fi
77+
if [ -f "target/site/jacoco/jacoco.xml" ]; then
78+
cp target/site/jacoco/jacoco.xml reports/raw/jacoco.xml
79+
fi
80+
81+
# ===== QUALITY GATES =====
82+
- name: Enforce PMD violations
83+
run: ./mvnw -B -ntp pmd:check
84+
85+
# ===== UPLOAD ARTIFACTS =====
86+
- name: Upload CI reports (HTML, PNG, XML)
87+
uses: actions/upload-artifact@v4
88+
if: always()
89+
with:
90+
name: ci-reports
91+
path: |
92+
reports/
93+
target/surefire-reports/
94+
retention-days: 30
95+
96+
# ===== SUMMARY =====
97+
- name: Generate CI Summary
98+
if: always()
99+
run: |
100+
echo "## 📊 CI Report Summary" >> $GITHUB_STEP_SUMMARY
101+
echo "" >> $GITHUB_STEP_SUMMARY
102+
echo "### Test Results" >> $GITHUB_STEP_SUMMARY
103+
if [ -d "target/surefire-reports" ]; then
104+
TESTS=$(find target/surefire-reports -name "TEST-*.xml" | wc -l)
105+
echo "- Test suites executed: $TESTS" >> $GITHUB_STEP_SUMMARY
106+
fi
107+
echo "" >> $GITHUB_STEP_SUMMARY
108+
echo "### Available Reports" >> $GITHUB_STEP_SUMMARY
109+
echo "- ✅ JaCoCo coverage (HTML + PNG snapshot)" >> $GITHUB_STEP_SUMMARY
110+
echo "- ✅ PMD static analysis (HTML + PNG snapshot)" >> $GITHUB_STEP_SUMMARY
111+
echo "- ✅ Unit test XML results" >> $GITHUB_STEP_SUMMARY
112+
echo "" >> $GITHUB_STEP_SUMMARY
113+
echo "### 📥 Download Artifacts" >> $GITHUB_STEP_SUMMARY
114+
echo "All consolidated under the 'ci-reports' artifact (reports/ + surefire XML)." >> $GITHUB_STEP_SUMMARY

.github/workflows/maven-main.yml

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,53 @@
1-
name: main Branch
1+
name: Build and Test
22

33
on:
44
push:
55
branches:
66
- 'main'
7+
- 'features/**'
8+
pull_request:
9+
branches:
10+
- main
711

812
jobs:
9-
10-
test:
11-
name: Test - Units & Integrations
13+
build:
14+
name: Build and Test
1215
runs-on: ubuntu-latest
1316

1417
steps:
15-
- uses: actions/checkout@v4
16-
- name: Set up JDK 4
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up JDK 17
1722
uses: actions/setup-java@v4
1823
with:
1924
distribution: 'temurin'
20-
java-version: '18'
21-
- name: Maven Package
22-
run: mvn -B -f IndividualProject/pom.xml clean package -DskipTests
23-
- name: Maven Verify
24-
run: mvn -B -f IndividualProject/pom.xml clean verify -Pintegration-test
25+
java-version: '17'
26+
27+
- name: Cache Maven dependencies
28+
uses: actions/cache@v4
29+
with:
30+
path: ~/.m2
31+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
32+
restore-keys: ${{ runner.os }}-m2
33+
34+
- name: Build with Maven
35+
run: ./mvnw -B clean compile
36+
37+
- name: Run unit tests
38+
run: ./mvnw -B test
39+
40+
- name: Package application
41+
run: ./mvnw -B package -DskipTests
42+
43+
- name: Verify build artifacts
44+
run: |
45+
echo "Checking build output..."
46+
ls -lh target/*.jar
47+
48+
- name: Upload build artifact
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: application-jar
52+
path: target/*.jar
53+
retention-days: 7

0 commit comments

Comments
 (0)