From ac0af9606f113be8a12a8314e05ad2bf2ee387b2 Mon Sep 17 00:00:00 2001 From: HEXINGZE <2046084122@qq.com> Date: Sun, 19 Jan 2025 01:46:05 +0800 Subject: [PATCH] feat:the ability to automatically run unit tests after creating a pull request. --- .github/workflows/build.yml | 8 +------- .github/workflows/unit-test.yml | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d0f7b1f98..55b56d399 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ # This is a workflow to help you test the unit case and show codecov -name: "build and codecov" +name: "build" on: push: @@ -60,9 +60,3 @@ jobs: - 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 - - - name: "upload coverage" - uses: codecov/codecov-action@v3 diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 621947d26..28ec0d655 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -59,12 +59,31 @@ jobs: restore-keys: | "${{ runner.os }}-go-" + - name: Shutdown default mysql + run: sudo service mysql stop + + - name: Create mysql database auth + uses: mirromutth/mysql-action@v1.1 + with: + host port: 3306 + container port: 3306 + mysql version: '8.0' + mysql database: 'seata_go_test' + mysql root password: 'seata_go' + - name: "Run Unit Tests" run: | echo "=== Starting Unit Tests ===" - go test -v ./... -coverprofile=coverage.txt -covermode=atomic -timeout 10m + 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: "Archive test results" + uses: actions/upload-artifact@v3 + with: + name: test-results + path: coverage.txt + retention-days: 7