Repository: cloudwego/hertz
Pull request #1168 (2024-08-08 11:44:38)

chore: update CI and optimze efficiency
#### What type of PR is this?
chore
<!--
Add one of the following kinds:

build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
docs: Documentation only changes
feat: A new feature
optimize: A new optimization
fix: A bug fix
perf: A code change that improves performance
refactor: A code change that neither fixes a bug nor adds a feature
style: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc)
test: Adding missing tests or correcting existing tests
chore: Changes to the build process or auxiliary tools and libraries such as documentation generation
-->

#### Check the PR title.
<!--
The description of the title will be attached in Release Notes, 
so please describe it from user-oriented, what this PR does / why we need it.
Please check your PR title with the below requirements:
-->
- [ ] This PR title match the format: \<type\>(optional scope): \<description\>
- [ ] The description of this PR title is user-oriented and clear enough for others to understand.
- [ ] Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. [User docs repo](https://github.com/cloudwego/cloudwego.github.io)


#### (Optional) Translate the PR title into Chinese.


#### (Optional) More detailed description for this PR(en: English/zh: Chinese).
<!--
Provide more detailed info for review(e.g., it's recommended to provide perf data if this is a perf type PR).
-->
en:
1. move lint check from tests to pr-check, lint only check once
2. In test, move 1.19 from unit-test to compat-test; hz-test uses stable version go
3. update actions/checkout to v4, actions/setup-go to v5
4. don't use cache for self-hosted runners

#### (Optional) Which issue(s) this PR fixes:
<!--
Automatically closes linked issue when PR is merged.
Eg: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->

#### (Optional) The PR that updates user documentation:
<!--
If the current PR requires user awareness at the usage level, please submit a PR to update user docs. [User docs repo](https://github.com/cloudwego/cloudwego.github.io)
-->


Patch:
diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml
index 16f214e..a9c318f 100644
--- a/.github/workflows/pr-check.yml
+++ b/.github/workflows/pr-check.yml
@@ -11,18 +11,21 @@ jobs:
       - name: Check License Header
         uses: apache/skywalking-eyes/header@v0.4.0
 
-      - name: typos-action
+      - name: Check Spell
         uses: crate-ci/typos@master
 
   staticcheck:
     runs-on: [ self-hosted, X64 ]
     steps:
-      - uses: actions/checkout@v3
-
+      - uses: actions/checkout@v4
       - name: Set up Go
-        uses: actions/setup-go@v3
+        uses: actions/setup-go@v5
         with:
-          go-version: 1.21
+          go-version: stable
+          # For self-hosted, the cache path is shared across projects
+          # and it works well without the cache of github actions
+          # Enable it if we're going to use Github only
+          cache: false
 
       - uses: reviewdog/action-staticcheck@v1
         with:
@@ -35,3 +38,19 @@ jobs:
           fail_on_error: true
           # Set staticcheck flags
           staticcheck_flags: -checks=inherit,-SA1029,-SA5008
+
+  lint:
+    runs-on: [ self-hosted, X64 ]
+    steps:
+      - uses: actions/checkout@v4
+      - name: Set up Go
+        uses: actions/setup-go@v5
+        with:
+          go-version: stable
+          cache: false # don't use cache for self-hosted runners
+
+      - name: Golangci Lint
+        # https://golangci-lint.run/
+        uses: golangci/golangci-lint-action@v6
+        with:
+          version: latest
\ No newline at end of file
diff --git a/.github/workflows/vulncheck.yml b/.github/workflows/vulncheck.yml
index 9b88498..6cbeff8 100644
--- a/.github/workflows/vulncheck.yml
+++ b/.github/workflows/vulncheck.yml
@@ -22,9 +22,9 @@ jobs:
         uses: actions/checkout@v4
 
       - name: Install Go
-        uses: actions/setup-go@v4
+        uses: actions/setup-go@v5
         with:
-          go-version: "stable"
+          go-version: stable
           check-latest: true
           cache: false
 


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 1098aa0..7c97b98 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -6,39 +6,33 @@ jobs:
   compat-test:
     strategy:
       matrix:
-        version: ["1.17", "1.18"]
+        version: ["1.17", "1.18", "1.19"]
     runs-on: [self-hosted, X64]
     steps:
-      - uses: actions/checkout@v3
-
+      - uses: actions/checkout@v4
       - name: Set up Go
-        uses: actions/setup-go@v3
+        uses: actions/setup-go@v5
         with:
           go-version: ${{ matrix.version }}
+          cache: false # don't use cache for self-hosted runners
 
       # Just build tests without running them
       - name: Build Test
         run: go test -run=nope ./...
 
-  lint-and-ut:
+  unit-test:
     strategy:
       matrix:
-        version: ["1.19", "1.20", "1.21", "1.22"]
+        version: ["1.20", "1.21", "1.22"]
     runs-on: [self-hosted, X64]
     steps:
-      - uses: actions/checkout@v3
-
+      - uses: actions/checkout@v4
       - name: Set up Go
-        uses: actions/setup-go@v3
+        uses: actions/setup-go@v5
         with:
           go-version: ${{ matrix.version }}
+          cache: false # don't use cache for self-hosted runners
 
-      - name: Golangci Lint
-        # https://golangci-lint.run/
-        uses: golangci/golangci-lint-action@v3
-        with:
-          version: latest
-          skip-cache: true
       - name: Unit Test
         run: go test -race -covermode=atomic -coverprofile=coverage.txt ./...
 
@@ -48,31 +42,28 @@ jobs:
   ut-windows:
     strategy:
       matrix:
-        version: ["1.19", "1.20", "1.21", "1.22"]
+        version: ["1.20", "1.21", "1.22"]
     runs-on: windows-latest
     steps:
-      - uses: actions/checkout@v3
-
+      - uses: actions/checkout@v4
       - name: Set up Go
-        uses: actions/setup-go@v3
+        uses: actions/setup-go@v5
         with:
           go-version: ${{ matrix.version }}
+          cache: false # don't use cache for self-hosted runners
 
       - name: Unit Test
         run: go test -race -covermode=atomic  ./...
 
   hz-test-unix:
-    strategy:
-      matrix:
-        version: [ '1.21' ]
     runs-on: [ self-hosted, X64 ]
     steps:
-      - uses: actions/checkout@v3
-
+      - uses: actions/checkout@v4
       - name: Set up Go
-        uses: actions/setup-go@v3
+        uses: actions/setup-go@v5
         with:
-          go-version: ${{ matrix.version }}
+          go-version: stable
+          cache: false # don't use cache for self-hosted runners
 
       - name: Setup Environment
         run: |
@@ -91,17 +82,13 @@ jobs:
 
 
   hz-test-windows:
-    strategy:
-      matrix:
-        version: [ '1.21']
     runs-on: windows-latest
     steps:
-      - uses: actions/checkout@v3
-
+      - uses: actions/checkout@v4
       - name: Set up Go
-        uses: actions/setup-go@v3
+        uses: actions/setup-go@v5
         with:
-          go-version: ${{ matrix.version }}
+          go-version: stable
 
       - name: Get changed files
         id: changed-files