Merge "Add gre type driver for dc-gw and tdd cases"
[releng/builder.git] / check_jjb_version.py
1 # SPDX-License-Identifier: EPL-1.0
2 ##############################################################################
3 # Copyright (c) 2018 The Linux Foundation and others.
4 #
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."""
11
12 __author__ = 'Thanh Ha'
13
14
15 import os
16 import re
17 import sys
18
19
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()
25                 break
26
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()
31                 break
32
33     print('JJB version in jjb/releng-jobs.yaml: {}'.format(jjb_version))
34     print('JJB version in tox.ini: {}'.format(jjb_version_tox))
35
36     if jjb_version != jjb_version_tox:
37         print('ERROR: JJB version in jjb/releng-jobs.yaml and tox.ini MUST match.')
38         sys.exit(1)
39
40
41 if __name__ == "__main__":
42     check_jjb_version('tox.ini', os.path.join('jjb', 'releng-jobs.yaml'))