浏览代码

chore: update Go versions in CI (#7346)

Joe Chen 2 年之前
父节点
当前提交
3e3d6eda12
共有 4 个文件被更改,包括 25 次插入17 次删除
  1. 2 2
      .github/pull_request_template.md
  2. 5 5
      .github/workflows/go.yml
  3. 5 0
      .github/workflows/lsif.yml
  4. 13 10
      internal/testutil/exec.go

+ 2 - 2
.github/pull_request_template.md

@@ -8,8 +8,8 @@ Link to the issue: <!-- paste the issue link here, or put "n/a" if not applicabl
 
 - [ ] I agree to follow the [Code of Conduct](https://go.dev/conduct) by submitting this pull request.
 - [ ] I have read and acknowledge the [Contributing guide](https://github.com/gogs/gogs/blob/main/.github/CONTRIBUTING.md).
-- [ ] I have added test cases to cover the new code.
+- [ ] I have added test cases to cover the new code or have provided the test plan.
 
 ## Test plan
 
-If no test cases added, please provide your test plan here.
+<!-- Please provide concrete but concise steps to proof things are working as stated, see an example in https://github.com/gogs/gogs/pull/7345 -->

+ 5 - 5
.github/workflows/go.yml

@@ -57,7 +57,7 @@ jobs:
     name: Test
     strategy:
       matrix:
-        go-version: [ 1.18.x, 1.19.x ]
+        go-version: [ 1.19.x, 1.20.x ]
         platform: [ ubuntu-latest, macos-latest ]
     runs-on: ${{ matrix.platform }}
     steps:
@@ -97,7 +97,7 @@ jobs:
     name: Test
     strategy:
       matrix:
-        go-version: [ 1.18.x, 1.19.x ]
+        go-version: [ 1.19.x, 1.20.x ]
         platform: [ windows-latest ]
     runs-on: ${{ matrix.platform }}
     steps:
@@ -135,7 +135,7 @@ jobs:
     name: Postgres
     strategy:
       matrix:
-        go-version: [ 1.18.x, 1.19.x ]
+        go-version: [ 1.19.x, 1.20.x ]
         platform: [ ubuntu-latest ]
     runs-on: ${{ matrix.platform }}
     services:
@@ -171,7 +171,7 @@ jobs:
     name: MySQL
     strategy:
       matrix:
-        go-version: [ 1.18.x, 1.19.x ]
+        go-version: [ 1.19.x, 1.20.x ]
         platform: [ ubuntu-18.04 ]
     runs-on: ${{ matrix.platform }}
     steps:
@@ -196,7 +196,7 @@ jobs:
     name: SQLite - Go
     strategy:
       matrix:
-        go-version: [ 1.18.x, 1.19.x ]
+        go-version: [ 1.19.x, 1.20.x ]
         platform: [ ubuntu-latest ]
     runs-on: ${{ matrix.platform }}
     steps:

+ 5 - 0
.github/workflows/lsif.yml

@@ -21,6 +21,11 @@ jobs:
         uses: docker://sourcegraph/src-cli:latest
         with:
           args: lsif upload -github-token=${{ secrets.GITHUB_TOKEN }}
+      - name: Upload LSIF data to S2
+        continue-on-error: true
+        uses: docker://sourcegraph/src-cli:latest
+        with:
+          args: -endpoint=https://sourcegraph.sourcegraph.com lsif upload -github-token=${{ secrets.GITHUB_TOKEN }}
       - name: Upload LSIF data to cs.unknwon.dev
         continue-on-error: true
         uses: docker://sourcegraph/src-cli:latest

+ 13 - 10
internal/testutil/exec.go

@@ -20,24 +20,27 @@ import (
 //  2. Call fmt.Fprintln(os.Stdout, ...) to print results for the main test to collect.
 func Exec(helper string, envs ...string) (string, error) {
 	cmd := exec.Command(os.Args[0], "-test.run="+helper, "--")
-	cmd.Env = []string{"GO_WANT_HELPER_PROCESS=1"}
+	cmd.Env = []string{
+		"GO_WANT_HELPER_PROCESS=1",
+		"GOCOVERDIR=" + os.TempDir(),
+	}
 	cmd.Env = append(cmd.Env, envs...)
 	out, err := cmd.CombinedOutput()
 	str := string(out)
-	if err != nil {
-		return "", fmt.Errorf("%v - %s", err, str)
-	}
 
+	// The error is quite confusing even when tests passed, so let's check whether
+	// it is passed first.
 	if strings.Contains(str, "no tests to run") {
 		return "", errors.New("no tests to run")
-	} else if !strings.Contains(str, "PASS") {
-		return "", errors.New(str)
+	} else if i := strings.Index(str, "PASS"); i >= 0 {
+		// Collect helper result
+		return strings.TrimSpace(str[:i]), nil
 	}
 
-	// Collect helper result
-	result := str[:strings.Index(str, "PASS")]
-	result = strings.TrimSpace(result)
-	return result, nil
+	if err != nil {
+		return "", fmt.Errorf("%v - %s", err, str)
+	}
+	return "", errors.New(str)
 }
 
 // WantHelperProcess returns true if current process is in helper mode.