Skip to content

benchmark_data_updated #175

benchmark_data_updated

benchmark_data_updated #175

name: Generate CSV Reports
on:
workflow_dispatch:
repository_dispatch:
types: [benchmark_data_updated]
push:
branches:
- main
jobs:
generate-reports:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pandas
- name: Generate CSV reports
run: |
echo "import os
import pandas as pd
import re
project_data = []
cloc_data = []
possible_technologies = ['CSV', 'Dockerfile', 'Gradle', 'Java', 'JSON', 'Maven', 'Properties', 'SQL', 'ECMAScript', 'XML', 'YAML', 'SUM']
for root, dirs, files in os.walk('.'):
for file in files:
if file == 'README.md' and 'model_re' in root:
with open(os.path.join(root, file), 'r') as f:
lines = f.readlines()
project = root.split('/')[1]
data = {
'#Components': '',
'#Source Files': '',
'Lines of Code': '',
'#Technologies': '',
'Abstraction': '',
'Execution Time [s]': ''
}
technologies = {tech: {'files': '0', 'blank': '0', 'comment': '0', 'code': '0'} for tech in possible_technologies}
for line in lines:
if '|' in line and '---' not in line:
parts = line.strip().split('|')
if len(parts) == 4:
key = parts[1].strip()
value = parts[2].strip()
if key == 'Execution Time [s]':
# only mean time without standard deviation
value = re.match(r'([\d.]+)', value).group(1)
data[key] = value
if len(parts) == 7:
values = {}
values['files'] = parts[2].replace('**', '').strip()
values['blank'] = parts[3].replace('**', '').strip()
values['comment'] = parts[4].replace('**', '').strip()
values['code'] = parts[5].replace('**', '').strip()
technology = parts[1].replace('**', '').replace(':', '').strip()
if technology in technologies:
technologies[technology] = values
project_data.append({
'project': project,
'components': data.get('#Components', ''),
'source_files': data.get('#Source Files', ''),
'lines_of_code': data.get('Lines of Code', ''),
'technologies': data.get('#Technologies', ''),
'abstraction': data.get('Abstraction', ''),
'execution_time': data.get('Execution Time [s]', '')
})
project_cloc = {'project': project}
for tech in possible_technologies:
project_cloc.update({
f'{tech}_files': technologies[tech]['files'],
f'{tech}_blank': technologies[tech]['blank'],
f'{tech}_comment': technologies[tech]['comment'],
f'{tech}_code': technologies[tech]['code']
})
cloc_data.append(project_cloc)
df_project = pd.DataFrame(project_data)
df_project = df_project[df_project['execution_time'] != ''].sort_values(by='project') # Filter and sort
df_project.to_csv('project_data.csv', index=False)
df_cloc = pd.DataFrame(cloc_data)
df_cloc = df_cloc[df_cloc['project'].isin(df_project['project'])].sort_values(by='project') # Filter and sort
df_cloc.to_csv('cloc_data.csv', index=False)" > generate_reports.py
python generate_reports.py
- name: Upload CSV reports
uses: actions/upload-artifact@v3
with:
name: reports
path: |
project_data.csv
cloc_data.csv