瀏覽代碼

properly handle GitHub Action env

Andy Li 3 年之前
父節點
當前提交
80da07c2a7
共有 5 個文件被更改,包括 27 次插入17 次删除
  1. 1 1
      .github/workflows/main.yml
  2. 22 1
      Earthfile
  3. 1 1
      extra/github-actions/workflows/main.yml
  4. 1 1
      tests/runci/Config.hx
  5. 2 13
      tests/runci/targets/Php.hx

+ 1 - 1
.github/workflows/main.yml

@@ -274,7 +274,7 @@ jobs:
           path: out/linux/amd64
 
       - name: Test
-        run: earthly --remote-cache=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]'):cache-test-${{github.ref_name}}-amd64 +test-all
+        run: earthly --remote-cache=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]'):cache-test-${{github.ref_name}}-amd64 +test-all --GITHUB_ACTIONS="$GITHUB_ACTIONS"
         env:
           EARTHLY_PUSH: "${{ github.event_name == 'push' }}"
 

+ 22 - 1
Earthfile

@@ -285,52 +285,73 @@ RUN_CI:
     RUN mkdir /haxelib && haxelib setup /haxelib
     WORKDIR tests
     ARG --required TEST
-    ENV GITHUB_WORKSPACE=true # emulate github environment, TODO: properly define a "Earthly" environment
     ENV TEST="$TEST"
     RUN haxe RunCi.hxml
 
 test-macro:
     FROM +test-environment
+    ARG GITHUB_ACTIONS
+    ENV GITHUB_ACTIONS=$GITHUB_ACTIONS
     DO +RUN_CI --TEST=macro
 
 test-neko:
     FROM +test-environment
+    ARG GITHUB_ACTIONS
+    ENV GITHUB_ACTIONS=$GITHUB_ACTIONS
     DO +RUN_CI --TEST=neko
 
 test-js:
     FROM +test-environment-js
+    ARG GITHUB_ACTIONS
+    ENV GITHUB_ACTIONS=$GITHUB_ACTIONS
     DO +RUN_CI --TEST=js
 
 test-hl:
     FROM +test-environment-hl
+    ARG GITHUB_ACTIONS
+    ENV GITHUB_ACTIONS=$GITHUB_ACTIONS
     DO +RUN_CI --TEST=hl
 
 test-cpp:
     FROM +test-environment-cpp
+    ARG GITHUB_ACTIONS
+    ENV GITHUB_ACTIONS=$GITHUB_ACTIONS
     DO +RUN_CI --TEST=cpp
 
 test-java:
     FROM +test-environment-java
+    ARG GITHUB_ACTIONS
+    ENV GITHUB_ACTIONS=$GITHUB_ACTIONS
     DO +RUN_CI --TEST=java
 
 test-jvm:
     FROM +test-environment-java
+    ARG GITHUB_ACTIONS
+    ENV GITHUB_ACTIONS=$GITHUB_ACTIONS
     DO +RUN_CI --TEST=jvm
 
 test-cs:
     FROM +test-environment-cs
+    ARG GITHUB_ACTIONS
+    ENV GITHUB_ACTIONS=$GITHUB_ACTIONS
     DO +RUN_CI --TEST=cs
 
 test-php:
     FROM +test-environment-php
+    ARG GITHUB_ACTIONS
+    ENV GITHUB_ACTIONS=$GITHUB_ACTIONS
     DO +RUN_CI --TEST=php
 
 test-python:
     FROM +test-environment-python
+    ARG GITHUB_ACTIONS
+    ENV GITHUB_ACTIONS=$GITHUB_ACTIONS
     DO +RUN_CI --TEST=python
 
 test-lua:
     FROM +test-environment-lua
+    ARG GITHUB_ACTIONS
+    ENV GITHUB_ACTIONS=$GITHUB_ACTIONS
     DO +RUN_CI --TEST=lua
 
 test-all:

+ 1 - 1
extra/github-actions/workflows/main.yml

@@ -97,7 +97,7 @@ jobs:
           path: out/linux/amd64
 
       - name: Test
-        run: earthly --remote-cache=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]'):cache-test-${{github.ref_name}}-amd64 +test-all
+        run: earthly --remote-cache=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]'):cache-test-${{github.ref_name}}-amd64 +test-all --GITHUB_ACTIONS="$GITHUB_ACTIONS"
         env:
           EARTHLY_PUSH: "${{ github.event_name == 'push' }}"
 

+ 1 - 1
tests/runci/Config.hx

@@ -21,7 +21,7 @@ class Config {
 	static public final threadsDir = cwd + "threads/";
 
 	static public final ci:Null<Ci> =
-		if (Sys.getEnv("GITHUB_WORKSPACE") != null)
+		if (Sys.getEnv("GITHUB_ACTIONS") == "true")
 			GithubActions;
 		else
 			null;

+ 2 - 13
tests/runci/targets/Php.hx

@@ -62,25 +62,14 @@ class Php {
 				deleteDirectoryRecursively(binDir);
 
 			runCommand("haxe", ["compile-php.hxml"].concat(prefix).concat(args));
-			runThroughPhpVersions(runCommand.bind(_, [binDir + "/index.php"]));
+			runCommand("php", [binDir + "/index.php"]);
 
 			changeDirectory(sysDir);
 			if(isCi())
 				deleteDirectoryRecursively(binDir);
 
 			runCommand("haxe", ["compile-php.hxml"].concat(prefix).concat(args));
-			runThroughPhpVersions(runSysTest.bind(_, ["bin/php/Main/index.php"]));
-		}
-	}
-
-	static function runThroughPhpVersions(fn:(phpCmd:String)->Void) {
-		switch [ci, systemName] {
-			case [GithubActions, "Linux"]:
-				for(version in ['7.4', '8.0']) {
-					fn('php$version');
-				}
-			case _:
-				fn('php');
+			runSysTest("php", ["bin/php/Main/index.php"]);
 		}
 	}
 }