-
Notifications
You must be signed in to change notification settings - Fork 0
162 lines (137 loc) · 5.22 KB
/
test-analysis-advanced.yml
File metadata and controls
162 lines (137 loc) · 5.22 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: Advanced Test Analysis
on:
workflow_run:
workflows: ["Advanced CI"]
types: [completed]
jobs:
analyze:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:
- uses: actions/checkout@v3
- name: Download test results
uses: actions/download-artifact@v3
with:
name: test-results
path: test-results
- name: Download test reports
uses: actions/download-artifact@v3
with:
name: test-reports
path: test-reports
- name: Install analysis tools
run: |
pip install pandas matplotlib seaborn jinja2
- name: Generate comprehensive analysis
run: |
python -c """
import json
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from datetime import datetime
import os
# テスト結果の読み込み
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)
# データの分析
analysis = {
'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('analysis/execution_time.png')
# 品質指標の分析
quality_metrics = {
'coverage_trend': df['coverage'].rolling(window=5).mean().tolist(),
'failure_rate': (df['status'] == 'failed').mean(),
'test_density': len(df) / df['execution_time'].sum()
}
# パフォーマンス指標の分析
performance_metrics = {
'avg_response_time': df['response_time'].mean(),
'max_response_time': df['response_time'].max(),
'95th_percentile': df['response_time'].quantile(0.95)
}
# 統計データの保存
with open('analysis/metrics.json', 'w') as f:
json.dump({
'analysis': analysis,
'quality_metrics': quality_metrics,
'performance_metrics': performance_metrics
}, f, indent=2)
"""
- name: Generate quality report
run: |
python -c """
import json
from datetime import datetime
# 品質レポートの生成
with open('analysis/metrics.json') as f:
metrics = json.load(f)
with open('quality-report.md', 'w') as f:
f.write("# Quality Report\n\n")
f.write(f"Generated on: {datetime.now().isoformat()}\n\n")
f.write("## Quality Metrics\n\n")
for metric, value in metrics['quality_metrics'].items():
f.write(f"- {metric}: {value}\n")
"""
- name: Generate performance report
run: |
python -c """
import json
from datetime import datetime
# パフォーマンスレポートの生成
with open('analysis/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['performance_metrics'].items():
f.write(f"- {metric}: {value}\n")
"""
- name: Generate trend analysis
run: |
python -c """
import json
from datetime import datetime
# トレンド分析の生成
with open('analysis/metrics.json') as f:
metrics = json.load(f)
with open('trend-analysis.md', 'w') as f:
f.write("# Trend Analysis\n\n")
f.write(f"Generated on: {datetime.now().isoformat()}\n\n")
f.write("## Coverage Trend\n\n")
f.write("\n")
"""
- name: Create GitHub PR comment
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const qualityReport = fs.readFileSync('quality-report.md', 'utf8');
const performanceReport = fs.readFileSync('performance-report.md', 'utf8');
const trendAnalysis = fs.readFileSync('trend-analysis.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 Analysis Summary\n\n${qualityReport}\n\n## Performance Metrics\n\n${performanceReport}\n\n## Trend Analysis\n\n${trendAnalysis}`
});
}