Przeglądaj źródła

[CI] refactor ci code

Andy Li 11 lat temu
rodzic
commit
40ef585cdb
4 zmienionych plików z 201 dodań i 160 usunięć
  1. 2 2
      .travis.yml
  2. 10 5
      appveyor.yml
  3. 187 151
      tests/RunCi.hx
  4. 2 2
      tests/unit/src/unit/Test.hx

+ 2 - 2
.travis.yml

@@ -44,8 +44,8 @@ script:
   - mkdir ~/haxelib && haxelib setup ~/haxelib
   - haxelib git hx-yaml https://github.com/mikestead/hx-yaml master src
   - haxe -version
-  - haxe -neko RunTravis.n -main RunTravis -lib hx-yaml
-  - neko RunTravis.n
+  - haxe -neko RunCi.n -main RunCi -lib hx-yaml
+  - neko RunCi.n
 
 notifications:
   webhooks:

+ 10 - 5
appveyor.yml

@@ -10,6 +10,7 @@ clone_folder: C:/projects/haxe
 environment:
     global:
         NEKO_ROOT: C:/projects/neko
+        HAXELIB_ROOT: C:/projects/haxelib
     matrix:
         -   CYG_ARCH: x86
             CYG_ROOT: C:/cygwin
@@ -49,12 +50,16 @@ install:
 
 build_script:
     - 'cd %APPVEYOR_BUILD_FOLDER%'
-    - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -f Makefile.win WODI=wodi%WODI_ARCH%"'
     - 'set PATH=%PATH%;%APPVEYOR_BUILD_FOLDER%'
+    - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -f Makefile.win WODI=wodi%WODI_ARCH%"'
+    - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && make -f Makefile.win WODI=wodi%WODI_ARCH% tools"'
+    - cd %APPVEYOR_BUILD_FOLDER%/tests/
+    - mkdir "%HAXELIB_ROOT%"
+    - haxelib setup "%HAXELIB_ROOT%"
+    - haxelib git hx-yaml https://github.com/mikestead/hx-yaml master src
 
 test_script:
+    - cd %APPVEYOR_BUILD_FOLDER%/tests/
     - haxe -version
-    - cd tests/unit
-    - haxe compile-macro.hxml
-    - haxe compile-neko.hxml
-    - neko bin/unit.n
+    - haxe -neko RunCi.n -main RunCi -lib hx-yaml
+    - neko RunCi.n

+ 187 - 151
tests/RunTravis.hx → tests/RunCi.hx

@@ -29,11 +29,23 @@ private typedef TravisConfig = {
     var ThirdParty = "third-party";
 }
 
+enum Ci {
+	TravisCI;
+	AppVeyor;
+}
+
 /**
-	Will be run by TravisCI.
-	See ".travis.yml" at project root for TravisCI settings.
+	Will be run by CI services, currently TravisCI and AppVeyor.
+
+	TravisCI:
+	Setting file: ".travis.yml".
+	Build result: https://travis-ci.org/HaxeFoundation/haxe
+
+	AppVeyor:
+	Setting file: "appveyor.yml".
+	Build result: https://ci.appveyor.com/project/Simn/haxe
 */
-class RunTravis {
+class RunCi {
 	static function successMsg(msg:String):Void {
 		Sys.println('\x1b[32m' + msg + '\x1b[0m');
 	}
@@ -364,10 +376,16 @@ class RunTravis {
 		runCommand("python3", ["-V"]);
 	}
 
-	static var test(default, never):TEST = Sys.getEnv("TEST");
+	static var ci(default, never):Null<Ci> =
+		if (Sys.getEnv("TRAVIS") == "true")
+			TravisCI;
+		else if (Sys.getEnv("APPVEYOR") == "True")
+			AppVeyor;
+		else
+			null;
 	static var systemName(default, never) = Sys.systemName();
-	static var repoDir(default, never) = Sys.getEnv("TRAVIS_BUILD_DIR");
 	static var cwd(default, never) = Sys.getCwd();
+	static var repoDir(default, never) = FileSystem.fullPath("..") + "/";
 	static var unitDir(default, never) = cwd + "unit/";
 	static var sysDir(default, never) = cwd + "sys/";
 	static var optDir(default, never) = cwd + "optimization/";
@@ -379,155 +397,173 @@ class RunTravis {
 
 		var args = ["foo", "12", "a b c\\ &<>[\"]#{}|"];
 
-		switch (test) {
-			case Macro, null:
-				runCommand("haxe", ["compile-macro.hxml","-D","travis"]);
-
-				changeDirectory(miscDir);
-				runCommand("haxe", ["compile.hxml"]);
-
-				//generate documentation
-				haxelibInstallGit("Simn", "hxparse", "development", "src", true);
-				haxelibInstallGit("Simn", "hxtemplo", true);
-				haxelibInstallGit("Simn", "hxargs", true);
-				haxelibInstallGit("dpeek", "haxe-markdown", "master", "src", true, "markdown");
-
-				haxelibInstallGit("HaxeFoundation", "hxcpp", true);
-				haxelibInstallGit("HaxeFoundation", "hxjava", true);
-				haxelibInstallGit("HaxeFoundation", "hxcs", true);
-
-				haxelibInstallGit("dpeek", "dox", true);
-				changeDirectory(getHaxelibPath("dox"));
-				runCommand("haxe", ["run.hxml"]);
-				runCommand("haxe", ["gen.hxml"]);
-				haxelibRun(["dox", "-o", "bin/api.zip", "-i", "bin/xml"]);
-
-				//BYTECODE
-				// disabled until https://github.com/HaxeFoundation/haxe/issues/3184 is resolved
-				if (Sys.getEnv("TRAVIS") == "true") {
-					changeDirectory(repoDir);
-					runCommand("make", ["BYTECODE=1"]);
-					runCommand("sudo", ["make", "install"]);
-					changeDirectory(unitDir);
+		var tests:Array<TEST> = switch (ci) {
+			case null:
+				[Sys.getEnv("TEST") == null ? Macro : Sys.getEnv("TEST")];
+			case TravisCI:
+				[Sys.getEnv("TEST")];
+			case AppVeyor:
+				[Macro];
+		}
+
+		for (test in tests) {
+			switch (test) {
+				case Macro:
 					runCommand("haxe", ["compile-macro.hxml"]);
-				}
-			case Neko:
-				runCommand("haxe", ["compile-neko.hxml","-D","travis"]);
-				runCommand("neko", ["bin/unit.n"]);
-
-				changeDirectory(sysDir);
-				runCommand("haxe", ["compile-neko.hxml","-D","travis"]);
-				changeDirectory("bin/neko");
-				runCommand("neko", ["sys.n"].concat(args));
-			case Php:
-				getPhpDependencies();
-				runCommand("haxe", ["compile-php.hxml","-D","travis"]);
-				runCommand("php", ["bin/php/index.php"]);
-			case Python:
-				getPythonDependencies();
-				runCommand("haxe", ["compile-python.hxml","-D","travis"]);
-				runCommand("python3", ["bin/unit.py"]);
-
-				changeDirectory(sysDir);
-				runCommand("haxe", ["compile-python.hxml","-D","travis"]);
-				changeDirectory("bin/python");
-				runCommand("python3", ["sys.py"].concat(args));
-
-				changeDirectory(miscDir + "pythonImport");
-				runCommand("haxe", ["compile.hxml"]);
-				runCommand("python3", ["test.py"]);
-			case Cpp:
-				getCppDependencies();
-				runCommand("haxe", ["compile-cpp.hxml","-D","travis"]);
-				runCommand("./bin/cpp/Test-debug", []);
-
-				runCommand("rm", ["-rf", "cpp"]);
-
-				runCommand("haxe", ["compile-cpp.hxml", "-D", "HXCPP_M64","-D","travis"]);
-				runCommand("./bin/cpp/Test-debug", []);
-
-				changeDirectory(sysDir);
-				runCommand("haxe", ["compile-cpp.hxml","-D","travis"]);
-				changeDirectory("bin/cpp");
-				runCommand("./Main-debug", args);
-			case Js:
-				getJSDependencies();
-
-				for (flatten in [true, false]) {
-					runCommand("haxe", ["compile-js.hxml","-D","travis"].concat(flatten ? ["-D", "js-flatten"] : []));
-					runCommand("node", ["-e", "var unit = require('./bin/unit.js').unit; unit.Test.main(); process.exit(unit.Test.success ? 0 : 1);"]);
-				}
 
-				if (Sys.getEnv("TRAVIS_SECURE_ENV_VARS") == "true" && systemName == "Linux") {
-					//https://saucelabs.com/opensource/travis
-					runCommand("npm", ["install", "wd"], true);
-					runCommand("wget", ["-nv", "https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh"], true);
-					runCommand("chmod", ["a+x", "sauce_connect_setup.sh"]);
-					runCommand("./sauce_connect_setup.sh", []);
-					haxelibInstallGit("dionjwa", "nodejs-std", "master", "src", true, "nodejs");
-					runCommand("haxe", ["compile-saucelabs-runner.hxml"]);
-					var server = new Process("nekotools", ["server"]);
-					runCommand("node", ["bin/RunSauceLabs.js"]);
-					server.close();
-				}
+					changeDirectory(miscDir);
+					runCommand("haxe", ["compile.hxml"]);
+
+					//generate documentation
+					haxelibInstallGit("Simn", "hxparse", "development", "src", true);
+					haxelibInstallGit("Simn", "hxtemplo", true);
+					haxelibInstallGit("Simn", "hxargs", true);
+					haxelibInstallGit("dpeek", "haxe-markdown", "master", "src", true, "markdown");
+
+					haxelibInstallGit("HaxeFoundation", "hxcpp", true);
+					haxelibInstallGit("HaxeFoundation", "hxjava", true);
+					haxelibInstallGit("HaxeFoundation", "hxcs", true);
+
+					haxelibInstallGit("dpeek", "dox", true);
+					changeDirectory(getHaxelibPath("dox"));
+					runCommand("haxe", ["run.hxml"]);
+					runCommand("haxe", ["gen.hxml"]);
+					haxelibRun(["dox", "-o", "bin/api.zip", "-i", "bin/xml"]);
+
+					//BYTECODE
+					switch (ci) {
+						case null:
+							//pass
+						case TravisCI:
+							changeDirectory(repoDir);
+							runCommand("make", ["BYTECODE=1"]);
+							runCommand("sudo", ["make", "install"]);
+							changeDirectory(unitDir);
+							runCommand("haxe", ["compile-macro.hxml"]);
+						case AppVeyor:
+							changeDirectory(repoDir);
+							runCommand(Sys.getEnv("CYG_ROOT") + "/bin/bash", ["-lc", 'cd \"$$OLDPWD\" && make -f Makefile.win WODI=wodi${Sys.getEnv("WODI_ARCH")} BYTECODE=1']);
+							changeDirectory(unitDir);
+							runCommand("haxe", ["compile-macro.hxml"]);
+					}
+				case Neko:
+					runCommand("haxe", ["compile-neko.hxml"]);
+					runCommand("neko", ["bin/unit.n"]);
+
+					changeDirectory(sysDir);
+					runCommand("haxe", ["compile-neko.hxml"]);
+					changeDirectory("bin/neko");
+					runCommand("neko", ["sys.n"].concat(args));
+				case Php:
+					getPhpDependencies();
+					runCommand("haxe", ["compile-php.hxml"]);
+					runCommand("php", ["bin/php/index.php"]);
+				case Python:
+					getPythonDependencies();
+					runCommand("haxe", ["compile-python.hxml"]);
+					runCommand("python3", ["bin/unit.py"]);
+
+					changeDirectory(sysDir);
+					runCommand("haxe", ["compile-python.hxml"]);
+					changeDirectory("bin/python");
+					runCommand("python3", ["sys.py"].concat(args));
+
+					changeDirectory(miscDir + "pythonImport");
+					runCommand("haxe", ["compile.hxml"]);
+					runCommand("python3", ["test.py"]);
+				case Cpp:
+					getCppDependencies();
+					runCommand("haxe", ["compile-cpp.hxml"]);
+					runCommand("./bin/cpp/Test-debug", []);
+
+					runCommand("rm", ["-rf", "cpp"]);
+
+					runCommand("haxe", ["compile-cpp.hxml", "-D", "HXCPP_M64"]);
+					runCommand("./bin/cpp/Test-debug", []);
+
+					changeDirectory(sysDir);
+					runCommand("haxe", ["compile-cpp.hxml"]);
+					changeDirectory("bin/cpp");
+					runCommand("./Main-debug", args);
+				case Js:
+					getJSDependencies();
+
+					for (flatten in [true, false]) {
+						runCommand("haxe", ["compile-js.hxml"].concat(flatten ? ["-D", "js-flatten"] : []));
+						runCommand("node", ["-e", "var unit = require('./bin/unit.js').unit; unit.Test.main(); process.exit(unit.Test.success ? 0 : 1);"]);
+					}
 
-				infoMsg("Test optimization:");
-				changeDirectory(optDir);
-				runCommand("haxe", ["run.hxml"]);
-			case Java:
-				getJavaDependencies();
-				runCommand("haxe", ["compile-java.hxml","-D","travis"]);
-				runCommand("java", ["-jar", "bin/java/Test-Debug.jar"]);
-			case Cs:
-				getCsDependencies();
-
-				runCommand("haxe", ["compile-cs.hxml","-D","travis"]);
-				runCommand("mono", ["bin/cs/bin/Test-Debug.exe"]);
-
-				runCommand("haxe", ["compile-cs-unsafe.hxml","-D","travis"]);
-				runCommand("mono", ["bin/cs_unsafe/bin/Test-Debug.exe"]);
-			case Flash9:
-				setupFlashPlayerDebugger();
-				runCommand("haxe", ["compile-flash9.hxml", "-D", "fdb","-D","travis"]);
-				runFlash("bin/unit9.swf");
-			case Flash8:
-				setupFlashPlayerDebugger();
-				runCommand("haxe", ["compile-flash8.hxml", "-D", "fdb","-D","travis"]);
-				runFlash("bin/unit8.swf");
-			case As3:
-				setupFlashPlayerDebugger();
-
-				//setup flex sdk
-				var flexVersion = "4.13.0";
-				runCommand("wget", ['http://mirror.cc.columbia.edu/pub/software/apache/flex/${flexVersion}/binaries/apache-flex-sdk-${flexVersion}-bin.tar.gz'], true);
-				runCommand("tar", ["-xf", 'apache-flex-sdk-${flexVersion}-bin.tar.gz', "-C", Sys.getEnv("HOME")]);
-				var flexsdkPath = Sys.getEnv("HOME") + '/apache-flex-sdk-${flexVersion}-bin';
-				Sys.putEnv("PATH", Sys.getEnv("PATH") + ":" + flexsdkPath + "/bin");
-				var playerglobalswcFolder = flexsdkPath + "/player";
-				FileSystem.createDirectory(playerglobalswcFolder + "/11.1");
-				runCommand("wget", ["-nv", "http://download.macromedia.com/get/flashplayer/updaters/11/playerglobal11_1.swc", "-O", playerglobalswcFolder + "/11.1/playerglobal.swc"], true);
-				File.saveContent(flexsdkPath + "/env.properties", 'env.PLAYERGLOBAL_HOME=$playerglobalswcFolder');
-				runCommand("mxmlc", ["--version"]);
-
-				runCommand("haxe", ["compile-as3.hxml", "-D", "fdb","-D","travis"]);
-				runFlash("bin/unit9_as3.swf");
-			case ThirdParty:
-				getPhpDependencies();
-				getJavaDependencies();
-				getJSDependencies();
-				getCsDependencies();
-				getPythonDependencies();
-				getCppDependencies();
-				//getOpenFLDependencies();
-
-				testPolygonalDs();
-				if (systemName == "Linux") testFlambe();
-				testHxTemplo();
-				testMUnit();
-				//testOpenflSamples();
-				//testFlixelDemos();
-			case t:
-				throw "unknown target: " + t;
+					if (Sys.getEnv("TRAVIS_SECURE_ENV_VARS") == "true" && systemName == "Linux") {
+						//https://saucelabs.com/opensource/travis
+						runCommand("npm", ["install", "wd"], true);
+						runCommand("wget", ["-nv", "https://gist.github.com/santiycr/5139565/raw/sauce_connect_setup.sh"], true);
+						runCommand("chmod", ["a+x", "sauce_connect_setup.sh"]);
+						runCommand("./sauce_connect_setup.sh", []);
+						haxelibInstallGit("dionjwa", "nodejs-std", "master", "src", true, "nodejs");
+						runCommand("haxe", ["compile-saucelabs-runner.hxml"]);
+						var server = new Process("nekotools", ["server"]);
+						runCommand("node", ["bin/RunSauceLabs.js"]);
+						server.close();
+					}
+
+					infoMsg("Test optimization:");
+					changeDirectory(optDir);
+					runCommand("haxe", ["run.hxml"]);
+				case Java:
+					getJavaDependencies();
+					runCommand("haxe", ["compile-java.hxml"]);
+					runCommand("java", ["-jar", "bin/java/Test-Debug.jar"]);
+				case Cs:
+					getCsDependencies();
+
+					runCommand("haxe", ["compile-cs.hxml"]);
+					runCommand("mono", ["bin/cs/bin/Test-Debug.exe"]);
+
+					runCommand("haxe", ["compile-cs-unsafe.hxml"]);
+					runCommand("mono", ["bin/cs_unsafe/bin/Test-Debug.exe"]);
+				case Flash9:
+					setupFlashPlayerDebugger();
+					runCommand("haxe", ["compile-flash9.hxml", "-D", "fdb"]);
+					runFlash("bin/unit9.swf");
+				case Flash8:
+					setupFlashPlayerDebugger();
+					runCommand("haxe", ["compile-flash8.hxml", "-D", "fdb"]);
+					runFlash("bin/unit8.swf");
+				case As3:
+					setupFlashPlayerDebugger();
+
+					//setup flex sdk
+					var flexVersion = "4.13.0";
+					runCommand("wget", ['http://mirror.cc.columbia.edu/pub/software/apache/flex/${flexVersion}/binaries/apache-flex-sdk-${flexVersion}-bin.tar.gz'], true);
+					runCommand("tar", ["-xf", 'apache-flex-sdk-${flexVersion}-bin.tar.gz', "-C", Sys.getEnv("HOME")]);
+					var flexsdkPath = Sys.getEnv("HOME") + '/apache-flex-sdk-${flexVersion}-bin';
+					Sys.putEnv("PATH", Sys.getEnv("PATH") + ":" + flexsdkPath + "/bin");
+					var playerglobalswcFolder = flexsdkPath + "/player";
+					FileSystem.createDirectory(playerglobalswcFolder + "/11.1");
+					runCommand("wget", ["-nv", "http://download.macromedia.com/get/flashplayer/updaters/11/playerglobal11_1.swc", "-O", playerglobalswcFolder + "/11.1/playerglobal.swc"], true);
+					File.saveContent(flexsdkPath + "/env.properties", 'env.PLAYERGLOBAL_HOME=$playerglobalswcFolder');
+					runCommand("mxmlc", ["--version"]);
+
+					runCommand("haxe", ["compile-as3.hxml", "-D", "fdb"]);
+					runFlash("bin/unit9_as3.swf");
+				case ThirdParty:
+					getPhpDependencies();
+					getJavaDependencies();
+					getJSDependencies();
+					getCsDependencies();
+					getPythonDependencies();
+					getCppDependencies();
+					//getOpenFLDependencies();
+
+					testPolygonalDs();
+					if (systemName == "Linux") testFlambe();
+					testHxTemplo();
+					testMUnit();
+					//testOpenflSamples();
+					//testFlixelDemos();
+				case t:
+					throw "unknown target: " + t;
+			}
 		}
 	}
 

+ 2 - 2
tests/unit/src/unit/Test.hx

@@ -301,8 +301,8 @@ class Test #if swf_mark implements mt.Protect #end {
 		];
 		// SPOD tests
 		#if ( (neko || php || java || cpp) && !macro && !interp)
-		#if (travis && !cpp)
-		if (Sys.systemName() != "Mac")
+		#if !cpp
+		if (Sys.getEnv("CI") != null && Sys.systemName() == "Linux")
 		{
 			classes.push(new TestSpod(sys.db.Mysql.connect({
 				host : "localhost",