def test_jenkins_ext(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") srv = JenkinsExt( "http://localhost:8080/", "user", "password", mock=True) github = "https://github.com/sdpython/" if not sys.platform.startswith("win"): # not yet implemented return conf = srv.create_job_template("pyquickhelper", git_repo=github + "%s/" % "pyquickhelper", upstreams=None, location=r"/home/username/jenkins/", dependencies={ "myversion": "/home/username/mymodule/src/", }, platform="win32") assert "MYVERSION=/home/username/mymodule/src/" in conf assert "auto_unittest_setup_help.bat" in conf conf = srv.create_job_template("pyquickhelper", git_repo=github + "%s/" % "pyquickhelper", upstreams=None, location=r"/home/username/jenkins/", dependencies={ "myversion": "/home/username/mymodule/src/", }, scheduler="H H(13-14) * * *", platform="win32") assert "H H(13-14) * * *" in conf try: conf = srv.create_job_template("pyquickhelper", git_repo=github + "%s/" % "pyquickhelper", upstreams=["pyquickhelper"], location=r"/home/username/jenkins/", dependencies={ "myversion": "/home/username/mymodule/src/", }, scheduler="H H(13-14) * * *", platform="win32") raise Exception("should not happen") except JenkinsExtException: pass conf = srv.create_job_template("pyquickhelper", git_repo=github + "%s/" % "pyquickhelper", upstreams=["pyquickhelper"], location=r"/home/username/jenkins/", dependencies={ "myversion": "/home/username/mymodule/src/", }, scheduler=None, platform="win32") assert "pyquickhelper" in conf
def zz_st_jenkins_job_verif(self, platform): engines_default = dict(anaconda2="c:\\Anaconda", anaconda3="c:\\Anaconda3", py35="c:\\Python35_x64", default="c:\\Python34_x64", winpython="c:\\APythonENSAE\\python") srv = JenkinsExt( "http://localhost:8080/", "user", "password", mock=True, fLOG=fLOG, engines=engines_default, platform=platform) if platform == "win": job = "standalone [conda_update] [anaconda3]" cmd = srv.get_cmd_standalone(job) assert "Anaconda3" in cmd if platform == "win": job = "pyrsslocal [py35] <-- pyquickhelper, pyensae" cmd = "\n".join(srv.get_jenkins_script(job)) assert "Python34" not in cmd else: try: job = "pyrsslocal [py35] <-- pyquickhelper, pyensae" except NotImplementedError: fLOG("OK FOR", platform)
def test_jenkins_ext(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") srv = JenkinsExt( "http://localhost:8080/", "user", "password", mock=True, fLOG=fLOG, platform="win") github = "https://github.com/sdpython/" conf = srv.create_job_template("pyquickhelper", git_repo=github + "%s/" % "pyquickhelper", upstreams=None, location=r"/home/username/jenkins/") assert "auto_unittest_setup_help.bat" in conf conf = srv.create_job_template("pyquickhelper", git_repo=github + "%s/" % "pyquickhelper", upstreams=None, location=r"/home/username/jenkins/", scheduler="H H(13-14) * * *") assert "H H(13-14) * * *" in conf try: conf = srv.create_job_template("pyquickhelper", git_repo=github + "%s/" % "pyquickhelper", upstreams=["pyquickhelper"], location=r"/home/username/jenkins/", scheduler="H H(13-14) * * *") raise Exception("should not happen") except JenkinsExtException: pass conf = srv.create_job_template("pyquickhelper", git_repo=github + "%s/" % "pyquickhelper", upstreams=["pyquickhelper"], location=r"/home/username/jenkins/", scheduler=None) assert "pyquickhelper" in conf
def test_jenkins_ext_setup_server(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") srv = JenkinsExt( "http://localhost:8080/", "user", "password", mock=True) github = "https://github.com/sdpython/" if sys.platform.startswith("win"): modules = [ # update anaconda ("standalone [conda_update]", "H H(8-9) * * 0"), "standalone [conda_update27]", "standalone [local_pypi]", # pyquickhelper, ("pyquickhelper", "H H(10-11) * * 0"), ("pymyinstall", None, dict(success_only=True)), ["pyquickhelper [anaconda]", "pyquickhelper [winpython]", "pyquickhelper [27] [anaconda2]"], ["pyensae", ], ["pymmails", "pysqllike", "pyrsslocal", "pymyinstall [27] [anaconda2]", "python3_module_template", "pyensae [anaconda]", "pyensae [winpython]"], ["pymmails [anaconda]", "pysqllike [anaconda]", "pyrsslocal [anaconda]", "python3_module_template [anaconda]", "python3_module_template [27] [anaconda2]", "pymyinstall [LONG]"], # actuariat [("actuariat_python", "H H(12-13) * * 0")], ["actuariat_python [winpython]", "actuariat_python [anaconda]"], # code_beatrix ("code_beatrix", "H H(14-15) * * 0"), "code_beatrix [winpython]", "code_beatrix [anaconda]", # teachings ("ensae_teaching_cs", "H H(15-16) * * 0"), ["ensae_teaching_cs [winpython]", "ensae_teaching_cs [anaconda]"], "ensae_teaching_cs [custom_left]", "ensae_teaching_cs [winpython] [custom_left]", "ensae_teaching_cs [anaconda] [custom_left]", # documentation ("pyquickhelper [doc]", "H H(3-4) * * 1"), ["pymyinstall [doc]", "pysqllike [doc]", "pymmails [doc]", "pyrsslocal [doc]", "pyensae [doc]"], ["actuariat_python [doc]", "code_beatrix [doc]"], ("ensae_teachings_cs [doc]", None, dict(pre="rem pre", post="rem post")), ("custom [any_name]", "H H(3-4) * * 1", dict(script="any_script.bat")), ] else: modules = [ # update anaconda ("standalone [conda_update]", "H H(8-9) * * 0"), "standalone [conda_update27]", "standalone [local_pypi]", # pyquickhelper, ("pyquickhelper", "H H(10-11) * * 0"), ("pymyinstall", None, dict(success_only=True)), ["pyquickhelper [anaconda]", "pyquickhelper [winpython]", "pyquickhelper [27] [anaconda2]"], ["pyensae", ], ["pymmails", "pysqllike", "pyrsslocal", "pymyinstall [27] [anaconda2]", "python3_module_template", "pyensae [anaconda]"], ["pymmails [anaconda]", "pysqllike [anaconda]", "pyrsslocal [anaconda]", "python3_module_template [anaconda]", "python3_module_template [27] [anaconda2]", "pymyinstall [LONG]"], # actuariat [("actuariat_python", "H H(12-13) * * 0")], ["actuariat_python [anaconda]"], # code_beatrix ("code_beatrix", "H H(14-15) * * 0"), ["code_beatrix [anaconda]"], # teachings ("ensae_teaching_cs", "H H(15-16) * * 0"), ["ensae_teaching_cs [anaconda]"], "ensae_teaching_cs [custom_left]", ["ensae_teaching_cs [anaconda] [custom_left]", ], # documentation ("pyquickhelper [doc]", "H H(3-4) * * 1"), ["pymyinstall [doc]", "pysqllike [doc]", "pymmails [doc]", "pyrsslocal [doc]", "pyensae [doc]"], ["actuariat_python [doc]", "code_beatrix [doc]"], "ensae_teachings_cs [doc]", ] pythonexe = os.path.dirname(sys.executable) location = None dependencies = {'pymyinstall': ['pyquickhelper'], 'pyensae': ['pyquickhelper'], 'python3_module_template': ['pyquickhelper'], 'ensae_teaching_cs': ['pyquickhelper', 'pyensae', 'pyrsslocal', 'pymmails'], 'actuariat_python': ['pyquickhelper', 'pyensae', 'pyrsslocal', 'pymmails'], 'code_beatrix': ['pyquickhelper', 'pyensae', 'pyrsslocal', 'pymmails'], } if not sys.platform.startswith("win"): # not yet implemented return res = srv.setup_jenkins_server(github=github, modules=modules, pythonexe=pythonexe, overwrite=True, fLOG=fLOG, dependencies=dependencies, location="anything/") df_ = 0 reg = re.compile("<description>(.*)</description>") for i, r in enumerate(res): conf = r[-1] if "DF_" in conf: df_ += 1 if not conf.startswith("<?xml version='1.0' encoding='UTF-8'?>"): raise Exception(conf) search = reg.search(conf) if not search: raise Exception(conf) fLOG(search.groups()[0], r[0], r[1]) if "__" in conf and "pyquickhelper_vir" not in conf: raise Exception(conf) if "notebook" in conf: raise Exception(conf) if "pymyinstall" in r[0] and "[" not in r[0]: if "FAILURE" in conf: raise Exception(conf) if "SUCCESS" not in conf: raise Exception(conf) if i == 0: if "conda update" not in conf: raise Exception(conf) if "H H(8-9) * * 0" not in conf: raise Exception(conf) if "A0101" not in conf: raise Exception(conf) if "github" in conf: raise Exception(conf) if i == 3: if "pyquickhelper" not in conf: raise Exception(conf) if "H H(10-11) * * 0" not in conf: raise Exception(conf) if "B0101" not in conf: raise Exception(conf) if "github" not in conf: raise Exception(conf) if "python3_module_template [27]" in r[0]: if "PYQUICKHELPER27=" not in conf: raise Exception(conf) if "PYQUICKHELPER=" not in conf: raise Exception(conf) if "PYQUICKHELPER27=a" not in conf: raise Exception(conf) if "dist_module27" not in conf: raise Exception(conf) if "Anaconda3" in conf: raise Exception(conf) if "[27]" not in r[0] and "update" not in conf: if "PYQUICKHELPER27=a" in conf: raise Exception(conf) if "dist_module27" in conf: raise Exception(conf) if "_LONG" in conf and "build_script" not in conf: raise Exception(conf) if "custom_left" in conf: if "auto_cmd_any_setup_command.bat custom_left" not in conf: raise Exception(conf) if ">F0" in conf: if "auto_cmd_any_setup_command.bat build_sphinx" not in conf: raise Exception(conf) if "ensae_teachings_cs [doc]" in conf: if "rem pre" not in conf or "rem post" not in conf: raise Exception(conf) assert i > 0 assert df_ > 0
def test_jenkins_ext_setup_server(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") github = "https://github.com/sdpython/" modules = [ # update anaconda ("standalone [conda_update] [Anaconda3]", "H H(8-9) * * 0"), "standalone [conda_update] [Anaconda2]", "standalone [local_pypi]", "standalone [update] [Anaconda3]", "standalone [update] [WinPython]", "standalone [update]", "standalone [install] [Anaconda2]", # pyquickhelper, ("pyquickhelper", "H H(10-11) * * 0"), ("pymyinstall <-- pyquickhelper", None, dict(success_only=True)), ["pyquickhelper [Anaconda3]", "pyquickhelper [WinPython]", "pyquickhelper [27] [Anaconda2]", "pyquickhelper [py35]"], ["pyensae <-- pyquickhelper <---- qgrid"], ["pymmails <-- pyquickhelper", "pysqllike <-- pyquickhelper", "pyrsslocal <-- pyquickhelper, pyensae", "pymyinstall [27] [Anaconda2] <-- pyquickhelper <---- qgrid", "python3_module_template <-- pyquickhelper", "pyensae [Anaconda3] <-- pyquickhelper", "pyensae [WinPython] <-- pyquickhelper"], ["pymmails [Anaconda3] <-- pyquickhelper", "pysqllike [Anaconda3] <-- pyquickhelper", "pyrsslocal [Anaconda3] <-- pyquickhelper, pensae", "python3_module_template [Anaconda3] <-- pyquickhelper", "python3_module_template [27] [Anaconda2] <-- pyquickhelper", "pymyinstall [LONG] <-- pyquickhelper"], # update ("pymyinstall [update_modules] <-- pyquickhelper", "H H(10-11) * * 5"), # actuariat [("actuariat_python <-- pyquickhelper, pyensae, pymmails, pyrsslocal, pymyinstall", "H H(12-13) * * 0")], ["actuariat_python [WinPython] <-- pyquickhelper, pyensae, pymmails, pyrsslocal, pymyinstall", "actuariat_python [Anaconda3] <-- pyquickhelper, pyensae, pymmails, pyrsslocal, pymyinstall"], # code_beatrix ("code_beatrix <-- pyquickhelper, pyensae, pymmails, pyrsslocal, pymyinstall", "H H(14-15) * * 0"), "code_beatrix [WinPython] <-- pyquickhelper, pyensae, pymmails, pyrsslocal, pymyinstall", "code_beatrix [Anaconda3] <-- pyquickhelper, pyensae, pymmails, pyrsslocal, pymyinstall", # teachings ("ensae_teaching_cs <-- pyquickhelper, pyensae, pymmails, pyrsslocal, pymyinstall", "H H(15-16) * * 0", dict(timeout=4799)), [("ensae_teaching_cs [WinPython] <-- pyquickhelper, pyensae, pymmails, pyrsslocal, pymyinstall", None, dict(timeout=4800)), ("ensae_teaching_cs [Anaconda3] <-- pyquickhelper, pyensae, pymmails, pyrsslocal, pymyinstall", None, dict(timeout=4801))], ("ensae_teaching_cs [custom_left] <-- pyquickhelper, pyensae, pymmails, pyrsslocal, pymyinstall", None, dict(timeout=4802)), ("ensae_teaching_cs [WinPython] [custom_left] <-- pyquickhelper, pyensae, pymmails, pyrsslocal, pymyinstall", None, dict(timeout=4803)), ("ensae_teaching_cs [Anaconda3] [custom_left] <-- pyquickhelper, pyensae, pymmails, pyrsslocal, pymyinstall", None, dict(timeout=4804)), # documentation ("pyquickhelper [doc] <-- pyquickhelper", "H H(3-4) * * 1"), ["pymyinstall [doc] <-- pyquickhelper", "pysqllike [doc] <-- pyquickhelper", "pymmails [doc] <-- pyquickhelper", "pyrsslocal [doc] <-- pyquickhelper", "pyensae [doc] <-- pyquickhelper"], ["actuariat_python [doc] <-- pyquickhelper, pyensae, pymmails, pyrsslocal, pymyinstall", "code_beatrix [doc] <-- pyquickhelper, pyensae, pymmails, pyrsslocal, pymyinstall"], ("ensae_teachings_cs [doc] <-- pyquickhelper, pyensae, pymmails, pyrsslocal, pymyinstall", None, dict(pre="rem pre", post="rem post", timeout=4805)), ("custom [any_name]", "H H(3-4) * * 1", dict(script="any_script.bat")), ["pyensae [UT] {-d_10} <-- pyquickhelper <---- qgrid"], ] engines = dict(Anaconda2="C:\\Anaconda2", Anaconda3="C:\\Anaconda3", WinPython="C:\\WinPython\\Python", default="c:\\Python34_x64", py35="c:\\Python35_x64") srv = JenkinsExt( "http://localhost:8080/", "user", "password", mock=True, platform="win", engines=engines, fLOG=fLOG) fLOG("---------------------") res = srv.setup_jenkins_server(github=github, modules=modules, overwrite=True, location="anything/") reg = re.compile("<description>(.*)</description>") for i, r in enumerate(res): conf = r[-1] if not conf.startswith("<?xml version='1.0' encoding='UTF-8'?>"): raise Exception(conf) search = reg.search(conf) if not search: raise Exception(conf) job = r[0] fLOG(search.groups()[0], "--", job, "--", r[1]) if "PYQUICKHELPER27" in conf: raise Exception(conf) if "notebook" in conf: raise Exception(conf) if "pymyinstall" in r[0].split("<--")[0] and "[" not in r[0]: if "FAILURE" in conf: raise Exception("{0}\n----\n{1}".format(r[0], conf)) if "SUCCESS" not in conf: raise Exception(conf) if "[UT]" in job: if "-d 10" not in conf: raise Exception("{0}\n-----------\n{1}".format(job, conf)) if "%1" in conf: raise Exception("{0}\n-----------\n{1}".format(job, conf)) if " -d 10" not in conf: raise Exception("{0}\n-----------\n{1}".format(job, conf)) if i == 0: if "conda update" not in conf: raise Exception(conf) if "H H(8-9) * * 0" not in conf: raise Exception(conf) if "A0101" not in conf: raise Exception(conf) if "github" in conf: raise Exception(conf) if i == 7: if "pyquickhelper" not in conf: raise Exception(conf) if "H H(10-11) * * 0" not in conf: raise Exception(conf) if "B0101" not in conf: raise Exception(conf) if "github" not in conf: raise Exception(conf) if "python3_module_template [27]" in r[0]: if "PYQUICKHELPER27=" in conf: raise Exception(conf) if "PYQUICKHELPER=" in conf: raise Exception(conf) if "PYQUICKHELPER27=a" in conf: raise Exception(conf) if "dist_module27" not in conf: raise Exception(conf) if "Anaconda3" in conf: raise Exception(conf) if "[27]" not in r[0] and "update" not in conf: if "PYQUICKHELPER27=a" in conf: raise Exception(conf) if "dist_module27" in conf: raise Exception(conf) if "_LONG" in conf and "build_script" not in conf: raise Exception(conf) if "custom_left" in conf: if "auto_cmd_any_setup_command.bat %jenkinspythonexe% default_87E5_87E5 custom_left" not in conf and \ "auto_cmd_any_setup_command.bat %jenkinspythonexe% WinPython_0640_0640 custom_left" not in conf and \ "auto_cmd_any_setup_command.bat %jenkinspythonexe% Anaconda3_3279_3279 custom_left" not in conf: raise Exception(conf) if ">G0" in conf: exp = re.compile( "auto_cmd_any_setup_command.bat %jenkinspythonexe% default_([A-Z0-9_]+) build_sphinx") ser = exp.search(conf) if not ser: raise Exception(conf) if "ensae_teachings_cs [doc]" in conf: if "rem pre" not in conf or "rem post" not in conf: raise Exception(conf) if "[Anaconda3]" in job: if "C:\\Anaconda3" not in conf: raise Exception(conf) if "[Anaconda2]" in job: if "C:\\Anaconda2" not in conf: raise Exception(conf) if "[py35]" in job: if "c:\\Python35_x64" not in conf: raise Exception(conf) if "pymyinstall" in job and "[27]" in job: if sys.version_info[:2] == (3, 5): s1 = '''%jenkinspythonexe% -u -c "import pip;pip.main('install --no-cache-dir''' + \ ''' --index http://localhost:8067/simple/ pyquickhelper'.split())"''' s2 = '''%jenkinspythonexe% -u -c "import pip;pip.main('install qgrid'.split())"''' if s1 not in conf: raise Exception(conf) if s2 not in conf: raise Exception(conf) else: if "%jenkinspythonpip% install --no-cache-dir --index http://localhost:8067/simple/ pyquickhelper" not in conf: raise Exception(conf) if "%jenkinspythonpip% install qgrid" not in conf: raise Exception(conf) if "ensae_teaching" in job: if "<timeoutSecondsString>4799" not in conf and "<timeoutSecondsString>480" not in conf: raise Exception(conf) if "[doc]" in job: if "%jenkinspythonexe% -u setup.py build_script" not in conf: raise Exception(conf) assert i > 0
def private_tst_jenkins_ext_setup_server_yaml(self, disable_schedule, credentials): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") this = os.path.abspath(os.path.dirname(__file__)) yml = os.path.abspath(os.path.join( this, "..", "..", ".local.jenkins.win.yml")) yml_url = "https://raw.githubusercontent.com/sdpython/python3_module_template/master/.local.jenkins.win.yml" github = "https://github.com/sdpython/" modules = [("yml", yml, "H H(10-11) * * 0"), ("yml", yml_url, "H H(10-11) * * 0")] if sys.version_info[0] == 2: modules = modules[:1] warnings.warn( "We don't test the url way on Python 2.7, too annoying.") engines = dict(Python34="c:\\Python34_x64", Python35=os.path.dirname(sys.executable), Python36=os.path.dirname(sys.executable), Python27="c:\\Python27_x64", Anaconda3="c:\\Anaconda3", Anaconda2="c:\\Anaconda2", WinPython35="c:\\PythonENSAE", root_path="d:\\jenkins\\yml") srv = JenkinsExt( "http://localhost:8080/", "user", "password", mock=True, engines=engines, fLOG=fLOG, platform="win") if not sys.platform.startswith("win"): # not yet implemented return fLOG("---------------------") res = srv.setup_jenkins_server(github=github, modules=modules, overwrite=True, add_environ=False, location="anything", disable_schedule=disable_schedule, credentials=credentials) reg = re.compile("<description>(.*)</description>") nb = 0 sch = 0 desc = 0 to = 0 for i, r in enumerate(res): conf = r[-1] if not conf.startswith("<?xml version='1.0' encoding='UTF-8'?>"): raise Exception(conf) search = reg.search(conf) if not search: raise Exception(conf) job = r[0] fLOG(search.groups()[0], "--", job, "--", r[1]) if "PYQUICKHELPER27" in conf: raise Exception(conf) if "SET VERSION=" not in conf: raise Exception(conf) if "SET NAME=" not in conf: raise Exception(conf) if "SET DIST=" not in conf: raise Exception(conf) if "anything\\%NAME_JENKINS%" not in conf: raise Exception(conf) if "python3_module_template_UT_35_std" in conf: nb += 1 if "H H(20-21) * * 0" in conf: sch += 1 if "H H(16-17) * * 0" in conf: sch += 1 if "0101 - H H(20-21) * * 0" in conf: desc += 1 if "0101 - H H(16-17) * * 0" in conf: desc += 1 if "<timeoutSecondsString>900</timeoutSecondsString>" in conf: to += 1 if sys.version_info[0] != 2: assert i > 0 assert nb > 0 assert to > 0 if disable_schedule: self.assertEqual(sch, 0) self.assertEqual(desc, 0) else: self.assertEqual(sch, 2) self.assertEqual(desc, 2) fLOG(to) if credentials: if "credentialsId" not in conf: raise Exception(conf) else: if "<credentialsId>None" not in conf: raise Exception(conf) else: warnings.warn("disable the test on Python 2.7")