2018-09-20 04:11:54 -04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
# internal use only
|
|
|
|
# check if expire time is set for all artifacts
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
import yaml
|
|
|
|
|
2019-06-28 10:36:20 -04:00
|
|
|
try:
|
|
|
|
from yaml import CLoader as Loader
|
|
|
|
except ImportError:
|
|
|
|
from yaml import Loader as Loader
|
|
|
|
|
2021-01-25 21:49:01 -05:00
|
|
|
IDF_PATH = os.getenv('IDF_PATH')
|
2018-09-20 04:11:54 -04:00
|
|
|
if not IDF_PATH:
|
2021-01-25 21:49:01 -05:00
|
|
|
print('Please set IDF_PATH before running this script')
|
2018-09-20 04:11:54 -04:00
|
|
|
raise SystemExit(-1)
|
|
|
|
|
2021-01-25 21:49:01 -05:00
|
|
|
GITLAB_CONFIG_FILE = os.path.join(os.getenv('IDF_PATH'), '.gitlab-ci.yml')
|
2018-09-20 04:11:54 -04:00
|
|
|
|
|
|
|
|
|
|
|
def check_artifacts_expire_time():
|
2021-01-25 21:49:01 -05:00
|
|
|
with open(GITLAB_CONFIG_FILE, 'r') as f:
|
2019-06-28 10:36:20 -04:00
|
|
|
config = yaml.load(f, Loader=Loader)
|
2018-09-20 04:11:54 -04:00
|
|
|
|
|
|
|
errors = []
|
|
|
|
|
2021-01-25 21:49:01 -05:00
|
|
|
print('expire time for jobs:')
|
2018-09-20 04:11:54 -04:00
|
|
|
|
2018-10-10 07:19:31 -04:00
|
|
|
job_names = list(config.keys())
|
2018-09-20 04:11:54 -04:00
|
|
|
job_names.sort()
|
|
|
|
|
|
|
|
for job_name in job_names:
|
|
|
|
|
2021-01-25 21:49:01 -05:00
|
|
|
if job_name.startswith('.'):
|
2018-09-20 04:11:54 -04:00
|
|
|
# skip ignored jobs
|
|
|
|
continue
|
|
|
|
|
|
|
|
try:
|
2021-01-25 21:49:01 -05:00
|
|
|
if 'expire_in' not in config[job_name]['artifacts']:
|
2018-09-20 04:11:54 -04:00
|
|
|
errors.append(job_name)
|
|
|
|
else:
|
2021-01-25 21:49:01 -05:00
|
|
|
print('{}: {}'.format(job_name, config[job_name]['artifacts']['expire_in']))
|
2018-09-20 04:11:54 -04:00
|
|
|
except (KeyError, TypeError):
|
|
|
|
# this is not job, or the job does not have artifacts
|
|
|
|
pass
|
|
|
|
|
|
|
|
if errors:
|
2021-01-25 21:49:01 -05:00
|
|
|
print('\n\nThe following jobs did not set expire time for its artifacts')
|
2018-09-20 04:11:54 -04:00
|
|
|
for error in errors:
|
|
|
|
print(error)
|
|
|
|
raise SystemExit(-2)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
check_artifacts_expire_time()
|