You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by fl...@apache.org on 2026/10/15 08:47:58 UTC

(incubator-seata-go) branch master updated: ci: refactor and strengthen the core GitHub Actions CI (#1200)

This is an automated email from the ASF dual-hosted git repository.

ssshr-66 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-seata-go.git


The following commit(s) were added to refs/heads/master by this push:
     new 2f4edca8 ci: refactor and strengthen the core GitHub Actions CI (#1200)
2f4edca8 is described below

commit 2f4edca89211fea5791bb0ed7df6764e01890d39
Author: Cheyne Chen <ch...@outlook.com>
AuthorDate: Thu Oct 15 16:47:52 2026 +0800

    ci: refactor and strengthen the core GitHub Actions CI (#1200)
    
    * ci: refactor and strengthen the core GitHub Actions CI
    
    * ci: include testdata directory in unit-test workflow triggers
    
    ---------
    
    Co-authored-by: Cursor <cu...@cursor.com>
    Co-authored-by: ThunGuo <te...@apache.org>
---
 .github/workflows/build.yml          |  82 ++++++++++---------------
 .github/workflows/golangci-lint.yml  |  53 +++++++++-------
 .github/workflows/integrate-test.yml | 101 +++++++++++++++++++------------
 .github/workflows/unit-test.yml      | 113 +++++++++++++++++++++--------------
 4 files changed, 195 insertions(+), 154 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 89cc8c86..a64a3d80 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -15,81 +15,65 @@
 # limitations under the License.
 #
 
-# This is a workflow to help you test the unit case and show codecov
+# This is a workflow to build the project.
 
-name: "build and codecov"
+name: "build"
 
 on:
   push:
-    branches: [ master ]
+    branches: [master]
+    paths:
+      - "**.go"
+      - "go.mod"
+      - "go.sum"
+      - ".github/workflows/build.yml"
   pull_request:
     branches: ["*"]
+    paths:
+      - "**.go"
+      - "go.mod"
+      - "go.sum"
+      - ".github/workflows/build.yml"
+
+permissions:
+  contents: read
+  actions: write
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
 
 jobs:
   build:
     # The type of runner that the job will run on
     runs-on: ubuntu-latest
-    strategy:
-      matrix:
-        golang:
-          - 1.20
-
-    services:
-      mysql:
-        image: mysql:8.0
-        env:
-          # The MySQL docker container requires these environment variables to be set
-          # so we can create and migrate the test database.
-          # See: https://hub.docker.com/_/mysql
-          MYSQL_DATABASE: seata_go_test
-          MYSQL_ROOT_PASSWORD: seata_go
-          MYSQL_USER: seata_go
-          MYSQL_PASSWORD: seata_go
-        ports:
-          - 3306:3306
-        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
-
+    timeout-minutes: 15
     steps:
+      - name: "checkout ${{ github.ref }}"
+        uses: actions/checkout@v4
+
       - name: "set up go"
-        uses: actions/setup-go@v3
+        uses: actions/setup-go@v5
         with:
           go-version: 1.20.14
-
-
-      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
-      - name: "checkout ${{ github.ref }}"
-        uses: actions/checkout@v3
-        with:
-          fetch-depth: 2
+          cache: true
 
       - name: "run go build"
         run: go build -v ./...
 
-      - name: "run go test and out codecov"
-        run: go test -v ./... -race -coverprofile=coverage.out -covermode=atomic
-        env:
-          SEATA_GO_TEST_MYSQL_DSN: seata_go:seata_go@tcp(127.0.0.1:3306)/seata_go_test
-
-      - name: "upload coverage"
-        uses: codecov/codecov-action@v4.0.1
-        with:
-          token: ${{ secrets.CODECOV_TOKEN }}
-          version: v0.6.0
-        env:
-          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
-
   build-riscv:
     name: "build for RISC-V"
     runs-on: ubuntu-latest
-
+    timeout-minutes: 15
     steps:
+      - name: "checkout ${{ github.ref }}"
+        uses: actions/checkout@v4
+
       - name: "set up go"
-        uses: actions/setup-go@v3
+        uses: actions/setup-go@v5
         with:
           go-version: 1.20.14
-
-      - name: "checkout ${{ github.ref }}"
-        uses: actions/checkout@v3
+          cache: true
 
       - name: "build for RISC-V 64-bit"
         env:
diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml
index 8a3ee2e7..afa37c3a 100644
--- a/.github/workflows/golangci-lint.yml
+++ b/.github/workflows/golangci-lint.yml
@@ -15,7 +15,7 @@
 # limitations under the License.
 #
 
-# This is a basic workflow to help you get started with Actions
+# This is a workflow to run golangci-lint on the project.
 
 name: "golang ci lint"
 
@@ -23,39 +23,48 @@ name: "golang ci lint"
 on:
   # Triggers the workflow on push or pull request events but only for the master branch
   push:
-    branches: [ master ]
+    branches: [master]
+    paths:
+      - "**.go"
+      - "go.mod"
+      - "go.sum"
+      - ".golangci.yml"
+      - ".github/workflows/golangci-lint.yml"
   pull_request:
     branches: "*"
+    paths:
+      - "**.go"
+      - "go.mod"
+      - "go.sum"
+      - ".golangci.yml"
+      - ".github/workflows/golangci-lint.yml"
 
-  # Allows you to run this workflow manually from the Actions tab
-#  workflow_dispatch:
+permissions:
+  contents: read
+  actions: write
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
 
-# A workflow run is made up of one or more jobs that can run sequentially or in parallel
 jobs:
-  # This workflow contains a single job called "build"
-  build:
-    # The type of runner that the job will run on
+  lint:
+    name: lint
     runs-on: ubuntu-latest
-    strategy:
-      matrix:
-        golang:
-          - 1.20.0
-
-    # Steps represent a sequence of tasks that will be executed as part of the job
+    timeout-minutes: 15
     steps:
+      - name: "checkout ${{ github.ref }}"
+        uses: actions/checkout@v4
+
       - name: "set up go"
-        uses: actions/setup-go@v3
+        uses: actions/setup-go@v5
         with:
-          go-version: 1.20.0
-
-      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
-      - name: "checkout ${{ github.ref }}"
-        uses: actions/checkout@v3
+          go-version: 1.20.14
+          cache: true
 
       - name: "golang ci lint"
         uses: golangci/golangci-lint-action@v3.1.0
         with:
           version: v1.51.0
           args: --timeout=10m
-          skip-cache: true
-          skip-pkg-cache: true
\ No newline at end of file
+          skip-pkg-cache: true
diff --git a/.github/workflows/integrate-test.yml b/.github/workflows/integrate-test.yml
index 33c26218..1f18a6a9 100644
--- a/.github/workflows/integrate-test.yml
+++ b/.github/workflows/integrate-test.yml
@@ -15,60 +15,87 @@
 # limitations under the License.
 #
 
-name: "integrate-test"
+# This is a workflow to run integration tests via integrate_test.sh.
+
+name: "integrate test"
 
 on:
   # Triggers the workflow on push or pull request events but only for the master branch
   push:
-    branches: [ master ]
+    branches: [master]
+    paths:
+      - "**.go"
+      - "go.mod"
+      - "go.sum"
+      - "integrate_test.sh"
+      - ".github/workflows/integrate-test.yml"
   pull_request:
     branches: "*"
+    paths:
+      - "**.go"
+      - "go.mod"
+      - "go.sum"
+      - "integrate_test.sh"
+      - ".github/workflows/integrate-test.yml"
 
 permissions:
   contents: read
+  actions: write
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
 
-# A workflow run is made up of one or more jobs that can run sequentially or in parallel
 jobs:
-  # This workflow contains a single job called "build"
   test:
-    # The type of runner that the job will run on
     name: test
     runs-on: ubuntu-latest
-    strategy:
-      matrix:
-        golang:
-          - 1.20
-
+    timeout-minutes: 30
     steps:
+      - name: "checkout ${{ github.ref }}"
+        uses: actions/checkout@v4
+
+      - name: "set up go"
+        uses: actions/setup-go@v5
+        with:
+          go-version: 1.20.14
+          cache: true
+
+      - name: "set up docker"
+        uses: docker/setup-buildx-action@v3
 
-    - name: "set up go"
-      uses: actions/setup-go@v3
-      with:
-        go-version: 1.20.14
+      - name: "install docker compose"
+        run: |
+          curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
+          chmod +x /usr/local/bin/docker-compose
+          docker-compose --version
 
-    # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
-    - name: "checkout ${{ github.ref }}"
-      uses: actions/checkout@v3
+      - name: "run integrate test"
+        if: ${{ github.event_name == 'pull_request' }}
+        run: |
+          chmod +x integrate_test.sh && [[ -n "${{github.event.pull_request.head.repo.full_name}}" ]] && [[ -n "${{github.event.pull_request.head.sha}}" ]] && [[ -n "${{github.base_ref}}" ]] && ./integrate_test.sh ${{github.event.pull_request.head.repo.full_name}} ${{github.event.pull_request.head.sha}} ${{github.base_ref}}
 
-    - name: Cache dependencies
-      uses: actions/cache@v3
-      with:
-        # Cache
-        path: ~/go/pkg/mod
-        # Cache key
-        key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
-        # An ordered list of keys to use for restoring the cache if no cache hit occurred for key
-        restore-keys: |
-          ${{ runner.os }}-go-
+      - name: "run integrate test"
+        if: ${{ github.event_name == 'push' }}
+        run: |
+          chmod +x integrate_test.sh && ./integrate_test.sh $GITHUB_REPOSITORY $GITHUB_SHA $GITHUB_BASE_REF
 
-    # This step only runs when the event type is a pull_request
-    - name: Integrate Test
-      if: ${{ github.event_name == 'pull_request' }}
-      run: |
-        chmod +x integrate_test.sh && [[ -n "${{github.event.pull_request.head.repo.full_name}}" ]] && [[ -n "${{github.event.pull_request.head.sha}}" ]] && [[ -n "${{github.base_ref}}" ]] && ./integrate_test.sh ${{github.event.pull_request.head.repo.full_name}} ${{github.event.pull_request.head.sha}} ${{github.base_ref}}
+      - name: "collect service logs"
+        if: failure()
+        run: |
+          mkdir -p ci-logs
+          docker ps -a > ci-logs/docker-ps.txt 2>&1 || true
+          if [ -d samples ]; then
+            (cd samples && docker-compose logs --no-color > ../ci-logs/compose.log 2>&1) || true
+          else
+            docker-compose logs --no-color > ci-logs/compose.log 2>&1 || true
+          fi
 
-    # This step only runs when the event type is a push
-    - name: Integrate Test
-      if: ${{ github.event_name == 'push' }}
-      run: |
-        chmod +x integrate_test.sh && ./integrate_test.sh $GITHUB_REPOSITORY $GITHUB_SHA $GITHUB_BASE_REF
+      - name: "upload diagnostics"
+        if: failure()
+        uses: actions/upload-artifact@v4
+        with:
+          name: "integrate test diagnostics"
+          path: ci-logs/
+          if-no-files-found: warn
+          retention-days: 7
diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml
index 91d1bf39..20b00def 100644
--- a/.github/workflows/unit-test.yml
+++ b/.github/workflows/unit-test.yml
@@ -15,65 +15,86 @@
 # limitations under the License.
 #
 
-name: "Unit Test"
+# This is a workflow to run unit tests.
+
+name: "unit test"
 
 on:
   push:
-    branches: [ master ]
+    branches: [master]
+    paths:
+      - "**.go"
+      - "go.mod"
+      - "go.sum"
+      - "**/testdata/**"
+      - ".github/workflows/unit-test.yml"
   pull_request:
-    branches: [ "*" ]
-    types: [opened, synchronize, reopened]
+    branches: "*"
+    paths:
+      - "**.go"
+      - "go.mod"
+      - "go.sum"
+      - "**/testdata/**"
+      - ".github/workflows/unit-test.yml"
 
 permissions:
   contents: read
+  actions: write
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
 
 jobs:
   unit-test:
-    name: Unit Test
+    name: "unit test"
     runs-on: ubuntu-latest
-    timeout-minutes: 10
-    strategy:
-      matrix:
-        golang:
-          - 1.20.14
-
+    timeout-minutes: 20
+    services:
+      mysql:
+        image: mysql:8.0
+        env:
+          MYSQL_DATABASE: seata_go_test
+          MYSQL_ROOT_PASSWORD: seata_go
+          MYSQL_USER: seata_go
+          MYSQL_PASSWORD: seata_go
+        ports:
+          - 3306:3306
+        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
     steps:
-    - name: "Set up Go"
-      uses: actions/setup-go@v3
-      with:
-        go-version: ${{ matrix.golang }}
-
-    - name: "Checkout code"
-      uses: actions/checkout@v3
-      with:
-        submodules: true
-
-    - name: "Cache dependencies"
-      uses: actions/cache@v3
-      with:
-        path: ~/go/pkg/mod
-        key: "${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}"
-        restore-keys: |
-          "${{ runner.os }}-go-"
+      - name: "checkout ${{ github.ref }}"
+        uses: actions/checkout@v4
 
-    - name: Shutdown default mysql
-      run: sudo service mysql stop
+      - name: "set up go"
+        uses: actions/setup-go@v5
+        with:
+          go-version: "1.20.14"
+          cache: true
 
+      - name: "run unit tests"
+        env:
+          SEATA_GO_TEST_MYSQL_DSN: seata_go:seata_go@tcp(127.0.0.1:3306)/seata_go_test
+        run: |
+          set -o pipefail
+          go test -v ./... -race -coverprofile=coverage.out -covermode=atomic -timeout 10m 2>&1 | tee test-output.log
 
-    - name: "Run Unit Tests"
-      run: |
-        echo "=== Starting Unit Tests ==="
-        go test -v ./... -race -coverprofile=coverage.txt -covermode=atomic -timeout 10m
-        if [ $? -ne 0 ]; then
-          echo "❌ Unit tests failed"
-          exit 1
-        fi
-        echo "✅ Unit tests completed successfully"
+      - name: Upload coverage
+        if: success()
+        uses: codecov/codecov-action@v4.0.1
+        with:
+          token: ${{ secrets.CODECOV_TOKEN }}
+          files: coverage.out
+          version: v0.6.0
+        env:
+          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
 
-    - name: "Archive test results"
-      uses: actions/upload-artifact@v4
-      with:
-        name: test-results
-        path: coverage.txt
-        retention-days: 7
-        overwrite: true
+      - name: Upload diagnostics
+        if: always()
+        uses: actions/upload-artifact@v4
+        with:
+          name: unit-test-diagnostics
+          path: |
+            coverage.out
+            test-output.log
+          if-no-files-found: warn
+          retention-days: 7


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org