Skip to content

Commit 88ebc14

Browse files
committed
ci: add CI Pipeline workflow
1 parent 8db9c89 commit 88ebc14

1 file changed

Lines changed: 13 additions & 95 deletions

File tree

  • OtmTodoApp-master/OtmTodoApp-master/.github/workflows
Lines changed: 13 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,29 @@
1-
name: CI Pipeline
1+
name: CI Pipeline
22

3-
on:
3+
on:
44
push:
5-
branches: [ main, master, develop ]
5+
branches: [ "main" ]
66
pull_request:
7-
branches: [ main, master, develop ]
7+
branches: [ "main" ]
88

99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
12-
1312
steps:
14-
- name: Checkout code
15-
uses: actions/checkout@v4
16-
13+
- uses: actions/checkout@v4
14+
1715
- name: Set up JDK 17
1816
uses: actions/setup-java@v4
1917
with:
2018
java-version: '17'
2119
distribution: 'temurin'
2220
cache: maven
23-
24-
- name: Cache Maven dependencies
25-
uses: actions/cache@v3
26-
with:
27-
path: ~/.m2
28-
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
29-
restore-keys: ${{ runner.os }}-m2
30-
31-
- name: Build with Maven
32-
run: mvn clean compile
33-
working-directory: OtmTodoApp-master/OtmTodoApp-master
34-
35-
- name: Run Tests
36-
run: mvn test
37-
working-directory: OtmTodoApp-master/OtmTodoApp-master
38-
39-
- name: Generate Coverage Report
40-
run: mvn jacoco:report
41-
working-directory: OtmTodoApp-master/OtmTodoApp-master
42-
43-
- name: Package Application
44-
run: mvn package
45-
working-directory: OtmTodoApp-master/OtmTodoApp-master
46-
47-
- name: Build Docker image
48-
run: docker build -t todoapp:${{ github.sha }} .
21+
22+
- name: Build + Test + Package
4923
working-directory: OtmTodoApp-master/OtmTodoApp-master
50-
51-
- name: Test Docker image
52-
run: |
53-
docker run --rm todoapp:${{ github.sha }} --version || echo "Docker image built successfully"
54-
55-
- name: Upload Test Results
56-
uses: actions/upload-artifact@v3
57-
if: always()
58-
with:
59-
name: test-results
60-
path: OtmTodoApp-master/OtmTodoApp-master/target/surefire-reports/
61-
62-
- name: Upload Coverage Reports
63-
uses: actions/upload-artifact@v3
64-
if: always()
65-
with:
66-
name: coverage-reports
67-
path: OtmTodoApp-master/OtmTodoApp-master/target/site/jacoco/
68-
69-
- name: Upload JAR Artifacts
70-
uses: actions/upload-artifact@v3
71-
with:
72-
name: jar-artifacts
73-
path: OtmTodoApp-master/OtmTodoApp-master/target/*.jar
74-
75-
- name: Comment PR with Test Results
76-
if: github.event_name == 'pull_request'
77-
uses: actions/github-script@v6
24+
run: mvn -B clean test jacoco:report package
25+
26+
- name: Update dependency graph (optional)
27+
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
7828
with:
79-
script: |
80-
const fs = require('fs');
81-
const path = require('path');
82-
83-
// Read test results if available
84-
let testSummary = '## 🧪 Test Results\n\n';
85-
try {
86-
const surefireDir = 'OtmTodoApp-master/OtmTodoApp-master/target/surefire-reports';
87-
if (fs.existsSync(surefireDir)) {
88-
const files = fs.readdirSync(surefireDir).filter(f => f.endsWith('.txt'));
89-
if (files.length > 0) {
90-
testSummary += '✅ All tests passed successfully!\n\n';
91-
testSummary += '**Test Summary:**\n';
92-
files.forEach(file => {
93-
const content = fs.readFileSync(path.join(surefireDir, file), 'utf8');
94-
const lines = content.split('\n');
95-
const testCount = lines.filter(line => line.includes('Tests run:')).length;
96-
if (testCount > 0) {
97-
testSummary += `- ${file.replace('.txt', '')}: ${lines.find(line => line.includes('Tests run:'))}\n`;
98-
}
99-
});
100-
}
101-
}
102-
} catch (error) {
103-
testSummary += '⚠️ Could not read test results\n';
104-
}
105-
106-
github.rest.issues.createComment({
107-
issue_number: context.issue.number,
108-
owner: context.repo.owner,
109-
repo: context.repo.repo,
110-
body: testSummary
111-
});
29+
directory: OtmTodoApp-master/OtmTodoApp-master

0 commit comments

Comments
 (0)