Skip to content

Commit

Permalink
style: modify cicd config module name
Browse files Browse the repository at this point in the history
  • Loading branch information
maksyuki committed Feb 22, 2024
1 parent 3a9ee6b commit 590c0aa
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 75 deletions.
25 changes: 14 additions & 11 deletions src/add_soc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import re
from typing import List
import cicd_config
import config
from data_type import CoreInfo


Expand All @@ -16,11 +16,14 @@ def clear(self):
self.submit_list.clear()
self.core_list.clear()

# 1. pattern: ysyx_([0-9]{6})
# 2. in id list
# 1. pattern: ysyx_([0-9]{8})
# 2. pattern: ysyx_([0-9]{6})
# 3. in id list
def check_valid(self, val: str) -> str:
if re.match('ysyx_[0-9]{8}', val) is not None:
return val
elif re.match('ysyx_[0-9]{6}', val) is not None:
return val
else:
return ''

Expand All @@ -32,21 +35,21 @@ def handle_err(self, val: str):
print(f'ID: error format, the err val: {val}')

def add(self):
with open(cicd_config.SUBMIT_LIST_PATH, 'r+', encoding='utf-8') as fp:
with open(config.SUBMIT_LIST_PATH, 'r+', encoding='utf-8') as fp:
for v in fp.readlines():
tmp = v.split()
# print(tmp[1])
print(tmp[1])
if self.check_valid(tmp[1]) != '':
self.fill_data(tmp)
else:
self.handle_err(tmp)

# update the core list
def update(self):
os.chdir(cicd_config.SUBMIT_DIR)
# os.system('git checkout ' + cicd_config.CUR_BRAN)
print(f'git checkout {cicd_config.CUR_BRAN}')
with open(cicd_config.CORE_LIST_PATH, 'r+', encoding='utf-8') as fp:
os.chdir(config.SUBMIT_DIR)
# os.system('git checkout ' + config.CUR_BRAN)
print(f'git checkout {config.CUR_BRAN}')
with open(config.CORE_LIST_PATH, 'r+', encoding='utf-8') as fp:
for v in fp.readlines():
tmp = v.split()
# print('id: ' + val)
Expand All @@ -67,15 +70,15 @@ def update(self):
break

if is_find is False:
os.system(f'git clone {va.url} submit/{va.sid}')
# os.system(f'git clone {va.url} submit/{va.sid}')
print(f'git clone {va.url} submit/{va.sid}')
new_id.append(CoreInfo('', va.sid, 'F'))

print(f'new core num: {len(new_id)}')
self.core_list += new_id
self.core_list.sort(key=lambda v: v.sid)
# print(self.core_list)
with open(cicd_config.CORE_LIST_PATH, 'w+', encoding='utf-8') as fp:
with open(config.CORE_LIST_PATH, 'w+', encoding='utf-8') as fp:
for v in self.core_list:
fp.write(v.sid + ' ' + v.flag + '\n')

Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions src/config_parse.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from typing import Any, Dict, Tuple
import tomli
import cicd_config
import config
from data_type import IvConfig, VerConfig, VcsConfig, DcConfig


Expand All @@ -17,21 +17,21 @@ def clear(self):
pass

def check_config(self, sid) -> Tuple[bool, str]:
core_dir = cicd_config.SUB_DIR + '/' + sid
core_dir = config.SUB_DIR + '/' + sid
core_config_file = core_dir + '/def_config.toml'
# core_config_file = 'def_config.toml'
if os.path.isfile(core_config_file):
with open(core_config_file, 'rb') as fp:
res = tomli.load(fp)
print(res)

cmd = f'git log origin/{cicd_config.BRANCH_NAME_DEV}'
cmd = f'git log origin/{config.BRANCH_NAME_DEV}'
cmd += ' --pretty=format:"%s" -1'
# print(cmd)
os.chdir(core_dir)
self.commit_info = cicd_config.exec_cmd(cmd)
self.commit_info = config.exec_cmd(cmd)
print(self.commit_info)
os.chdir(cicd_config.HOME_DIR)
os.chdir(config.HOME_DIR)
# self.commit_info = 'vcs'
# print(res.keys())
std_config_keys = ['iv_config', 'ver_config', 'vcs_config']
Expand Down
12 changes: 6 additions & 6 deletions src/dc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
# import argparse
import time
# import datetime
import cicd_config
import config

freqlist = ['100']
for freq in freqlist:
with open(cicd_config.DC_HOME_DIR + '/asic_top/ysyx_229998.tcl',
with open(config.DC_HOME_DIR + '/asic_top/ysyx_229998.tcl',
encoding='utf-8') as fp:
message = ''
for line in fp:
line = re.sub('u0_rcg/u0_pll/CLK_OUT (\d+)',
'u0_rcg/u0_pll/CLK_OUT {freq_p}'.format(freq_p=freq),
line)
message += line
with open(cicd_config.DC_HOME_DIR + '/asic_top/ysyx_229998.tcl',
with open(config.DC_HOME_DIR + '/asic_top/ysyx_229998.tcl',
'w',
encoding='utf-8') as fp:
fp.write(message)
Expand All @@ -39,7 +39,7 @@
.format(corner_p=corner, track_p=track, vt_p=vt, user_p=user))
# os.system(
# './report_filter -d ysyx_229998 -u {user_p}'.format(user_p=user))
os.chdir(cicd_config.DC_LOG_DIR)
os.chdir(config.DC_LOG_DIR)
print(f'Current working directory: {0}'.format(os.getcwd()))

user_name = top_name + '_' + user
Expand Down Expand Up @@ -167,7 +167,7 @@
i - 1, j - 1)
fp.write(tmp)

os.chdir(cicd_config.DC_RPT_DIR)
os.chdir(config.DC_RPT_DIR)
print(f'Current working directory: {0}'.format(os.getcwd()))

rpt_name = user_name + '/' + top_name + '.statistics.rpt'
Expand Down Expand Up @@ -202,7 +202,7 @@
else:
fp.write('\n\nf=100Mhz FAIL!!!')

os.chdir(cicd_config.DC_HOME_DIR)
os.chdir(config.DC_HOME_DIR)

with open(result_name, 'a', encoding='utf-8') as fp:
txt = '\n\n================AREA REPORT================\n\n'
Expand Down
6 changes: 3 additions & 3 deletions src/dispatch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/python

import os
import cicd_config
import config
import config_parse
import iv_test
import ver_test
Expand All @@ -10,14 +10,14 @@


def create_dir(sid: str):
core_rpt_dir = cicd_config.RPT_DIR + '/' + sid
core_rpt_dir = config.RPT_DIR + '/' + sid
os.system(f'mkdir -p {core_rpt_dir}')
os.system(f'echo state: under test > {core_rpt_dir}/state')


def main():
# extract one file from queue_list
with open(cicd_config.QUEUE_LIST_PATH, 'r+', encoding='utf-8') as fp:
with open(config.QUEUE_LIST_PATH, 'r+', encoding='utf-8') as fp:
cores = fp.readlines()
if cores != []:
tmp = cores[0].split()
Expand Down
48 changes: 24 additions & 24 deletions src/repo_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from datetime import datetime
from typing import Tuple
import cicd_config
import config
from data_type import CoreInfo, QueueInfo


Expand All @@ -16,44 +16,44 @@ def clear(self):
def sw_branch(self, bran_name: str):
cmd = 'git symbolic-ref --short HEAD'
# check if already in this branch
cur_bran = cicd_config.exec_cmd(cmd)
cur_bran = config.exec_cmd(cmd)
if cur_bran == (bran_name + '\n'):
return
else:
# switch to branch
print('switch to branch: ' + bran_name)
cmd = f'git checkout {bran_name}'
ret = cicd_config.exec_cmd(cmd)
ret = config.exec_cmd(cmd)
print(ret)

# return: (state: Bool, submod_name: str, std_date: str)
# state: if submod repo has new commit
def check_remote_update(self, submod_name: str) -> (Tuple[bool, str]):
os.chdir(cicd_config.SUB_DIR + '/' + submod_name)
os.chdir(config.SUB_DIR + '/' + submod_name)
cmd = 'git rev-parse HEAD'
local_rev = cicd_config.exec_cmd(cmd)
local_rev = config.exec_cmd(cmd)

self.sw_branch(cicd_config.BRANCH_NAME_DEV)
self.sw_branch(config.BRANCH_NAME_DEV)
cmd = 'git remote -v update'
cicd_config.exec_cmd(cmd)
config.exec_cmd(cmd)

cmd = 'git rev-parse origin/HEAD'
remote_rev = cicd_config.exec_cmd(cmd)
remote_rev = config.exec_cmd(cmd)

cmd = f'git log origin/{cicd_config.BRANCH_NAME_DEV}'
cmd = f'git log origin/{config.BRANCH_NAME_DEV}'
cmd += ' --pretty=format:"%s" -1'
# print(cmd)
title_rev = cicd_config.exec_cmd(cmd)
title_rev = config.exec_cmd(cmd)

cmd = f'git log origin/{cicd_config.BRANCH_NAME_DEV}'
cmd = f'git log origin/{config.BRANCH_NAME_DEV}'
cmd += ' --pretty=format:"%ad" -1'
# print(date_rev)
date_rev = cicd_config.exec_cmd(cmd)
date_rev = config.exec_cmd(cmd)

std_date = datetime.strptime(
date_rev, cicd_config.GMT_FORMAT).strftime(cicd_config.STD_FOMRAT)
date_rev, config.GMT_FORMAT).strftime(config.STD_FOMRAT)

os.chdir(cicd_config.HOME_DIR)
os.chdir(config.HOME_DIR)
print(submod_name + ':')
print(f'local is: {local_rev}'.rstrip('\n'))
print(f'remote is: {remote_rev}'.rstrip('\n'))
Expand All @@ -62,14 +62,14 @@ def check_remote_update(self, submod_name: str) -> (Tuple[bool, str]):
return (local_rev != remote_rev, std_date)

def pull_repo(self, submod_name: str):
os.chdir(cicd_config.SUB_DIR + '/' + submod_name)
self.sw_branch(cicd_config.BRANCH_NAME_DEV)
os.chdir(config.SUB_DIR + '/' + submod_name)
self.sw_branch(config.BRANCH_NAME_DEV)

cmd = 'git pull --progress -v --no-rebase "origin" '
cmd += cicd_config.BRANCH_NAME_DEV
ret = cicd_config.exec_cmd(cmd)
cmd += config.BRANCH_NAME_DEV
ret = config.exec_cmd(cmd)
print(ret)
os.chdir(cicd_config.HOME_DIR)
os.chdir(config.HOME_DIR)

def check_repo(self, core_info: CoreInfo):
ret = self.check_remote_update(core_info.sid)
Expand All @@ -86,21 +86,21 @@ def check_repo(self, core_info: CoreInfo):
else:
print(f'[{core_info.sid}] not changed')

# os.chdir(cicd_config.HOME_DIR)
# os.chdir(config.HOME_DIR)
# check if cores have been added to the cicd database
def check_id(self):
with open(cicd_config.CORE_LIST_PATH, 'r+', encoding='utf-8') as fp:
with open(config.CORE_LIST_PATH, 'r+', encoding='utf-8') as fp:
for v in fp.readlines():
tmp = v.split()
self.check_repo(CoreInfo('', tmp[0], tmp[1]))

def update_queue(self):
# cicd_config.git_commit(cicd_config.SUB_DIR, '[bot] update repo')
# config.git_commit(config.SUB_DIR, '[bot] update repo')
# self.val_list = [('ysyx_23050153', '2022-08-18 09:05:40'),
# ('ysyx_23050340', '2022-08-18 09:00:38'),
# ('ysyx_23050171', '2022-08-18 09:05:47')]
self.val_list.sort(key=lambda v: v.date)
with open(cicd_config.QUEUE_LIST_PATH, 'r+', encoding='utf-8') as fp:
with open(config.QUEUE_LIST_PATH, 'r+', encoding='utf-8') as fp:
fp_cores = fp.readlines()
# print(fp_cores)
# print(self.val_list)
Expand Down Expand Up @@ -129,7 +129,7 @@ def update_queue(self):


def main():
os.system(f'mkdir -p {cicd_config.DATA_DIR}')
os.system(f'mkdir -p {config.DATA_DIR}')
print('[repo update]')
core_queue.clear()
core_queue.check_id()
Expand Down
Loading

0 comments on commit 590c0aa

Please sign in to comment.