1 # SPDX-License-Identifier: EPL-1.0
2 ##############################################################################
3 # Copyright (c) 2018 The Linux Foundation and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Eclipse Public License v1.0
7 # which accompanies this distribution, and is available at
8 # http://www.eclipse.org/legal/epl-v10.html
9 ##############################################################################
10 """Ensures that the jjb-version in tox and releng-jobs.yaml match."""
12 __author__ = 'Thanh Ha'
20 def check_jjb_version(tox_file, releng_jobs_file):
21 with open(tox_file, 'r') as _file:
22 for num, line in enumerate(_file, 1):
23 if re.search('env:JJB_VERSION:', line):
24 jjb_version_tox = line.rsplit(':', 1)[1].replace('}', '').strip()
27 with open(releng_jobs_file, 'r') as _file:
28 for num, line in enumerate(_file, 1):
29 if re.search('jjb-version: ', line):
30 jjb_version = line.rsplit(':', 1)[1].strip()
33 print('JJB version in jjb/releng-jobs.yaml: {}'.format(jjb_version))
34 print('JJB version in tox.ini: {}'.format(jjb_version_tox))
36 if jjb_version != jjb_version_tox:
37 print('ERROR: JJB version in jjb/releng-jobs.yaml and tox.ini MUST match.')
41 if __name__ == "__main__":
42 check_jjb_version('tox.ini', os.path.join('jjb', 'releng-jobs.yaml'))