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 """Check that JJB version matches in job cfg and tox.ini."""
22 with open(tox_file, "r") as _file:
23 for num, line in enumerate(_file, 1):
24 if re.search("env:JJB_VERSION:", line):
25 jjb_version_tox = line.rsplit(":", 1)[1].replace("}", "").strip()
28 with open(releng_jobs_file, "r") as _file:
29 for num, line in enumerate(_file, 1):
30 if re.search("jjb-version: ", line):
31 jjb_version = line.rsplit(":", 1)[1].strip()
34 print("JJB version in jjb/releng-jobs.yaml: {}".format(jjb_version))
35 print("JJB version in tox.ini: {}".format(jjb_version_tox))
37 if jjb_version != jjb_version_tox:
38 print("ERROR: JJB version in jjb/releng-jobs.yaml and tox.ini MUST match.")
42 if __name__ == "__main__":
43 check_jjb_version("tox.ini", os.path.join("jjb", "releng-jobs.yaml"))