Skip to content

Commit

Permalink
feat:the ability to automatically run unit tests after creating a pul…
Browse files Browse the repository at this point in the history
…l request.
  • Loading branch information
AsterZephyr committed Jan 18, 2025
1 parent 73cf2a9 commit ac0af96
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
21 changes: 20 additions & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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

0 comments on commit ac0af96

Please sign in to comment.