-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (124 loc) · 5.03 KB
/
test-reporting.yml
File metadata and controls
145 lines (124 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Test Reporting
on:
workflow_run:
workflows: ["Test Data Generation", "Parallel Testing"]
types: [completed]
jobs:
report:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:
- uses: actions/checkout@v3
- name: Download test data
uses: actions/download-artifact@v3
with:
name: test-data
path: test-data
- name: Download test results
uses: actions/download-artifact@v3
with:
name: test-results
path: test-results
- name: Install reporting tools
run: |
pip install pandas matplotlib seaborn jinja2
- name: Generate test report
run: |
python -c """
import json
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from datetime import datetime
# テストデータの読み込み
with open('test-data/test-data-summary.json') as f:
test_data = json.load(f)
# テスト結果の読み込み
results = []
for file in os.listdir('test-results'):
if file.endswith('.json'):
with open(f'test-results/{file}') as f:
results.append(json.load(f))
# データフレームの作成
df = pd.DataFrame(results)
# データの分析
summary = {
'total_tests': len(df),
'passed_tests': len(df[df['status'] == 'passed']),
'failed_tests': len(df[df['status'] == 'failed']),
'test_coverage': df['coverage'].mean(),
'execution_time': df['execution_time'].sum(),
'generation_date': datetime.now().isoformat()
}
# グラフの生成
plt.figure(figsize=(12, 6))
sns.barplot(x='test_type', y='execution_time', data=df)
plt.title('Test Execution Time by Type')
plt.savefig('test-results/execution_time.png')
# レポートの生成
with open('test-report.md', 'w') as f:
f.write("# Test Report\n\n")
f.write(f"Generated on: {summary['generation_date']}\n\n")
f.write("## Summary\n\n")
f.write(f"- Total Tests: {summary['total_tests']}\n")
f.write(f"- Passed: {summary['passed_tests']}\n")
f.write(f"- Failed: {summary['failed_tests']}\n")
f.write(f"- Average Coverage: {summary['test_coverage']:.2f}%\n")
f.write(f"- Total Execution Time: {summary['execution_time']:.2f}s\n\n")
f.write("")
"""
- name: Generate coverage report
run: |
python -c """
import json
from datetime import datetime
# カバレッジデータの読み込み
with open('test-results/coverage.xml') as f:
coverage_data = json.load(f)
# カバレッジレポートの生成
with open('coverage-report.md', 'w') as f:
f.write("# Coverage Report\n\n")
f.write(f"Generated on: {datetime.now().isoformat()}\n\n")
f.write("## Coverage Summary\n\n")
f.write(f"- Total Coverage: {coverage_data['total_coverage']:.2f}%\n")
f.write("\n## Coverage Details\n\n")
for file, data in coverage_data['files'].items():
f.write(f"### {file}\n")
f.write(f"- Statements: {data['statements']}\n")
f.write(f"- Missed: {data['missed']}\n")
f.write(f"- Coverage: {data['coverage']:.2f}%\n")
"""
- name: Generate performance metrics
run: |
python -c """
import json
from datetime import datetime
# パフォーマンスメトリクスの読み込み
with open('test-results/performance_metrics.json') as f:
metrics = json.load(f)
# パフォーマンスレポートの生成
with open('performance-report.md', 'w') as f:
f.write("# Performance Report\n\n")
f.write(f"Generated on: {datetime.now().isoformat()}\n\n")
f.write("## Performance Metrics\n\n")
for metric, value in metrics.items():
f.write(f"- {metric}: {value}\n")
"""
- name: Create GitHub PR comment
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const testReport = fs.readFileSync('test-report.md', 'utf8');
const coverageReport = fs.readFileSync('coverage-report.md', 'utf8');
const performanceReport = fs.readFileSync('performance-report.md', 'utf8');
const prNumber = context.payload.pull_request?.number;
if (prNumber) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: `# Test Results Summary\n\n${testReport}\n\n## Coverage Details\n\n${coverageReport}\n\n## Performance Metrics\n\n${performanceReport}`
});
}