23
23
branches : [ master ]
24
24
pull_request :
25
25
branches : " *"
26
+ types : [opened, synchronize, reopened] # 明确指定 PR 事件类型
26
27
27
28
permissions :
28
29
contents : read
@@ -61,15 +62,32 @@ jobs:
61
62
restore-keys : |
62
63
${{ runner.os }}-go-
63
64
65
+ # add Unit Test
66
+ - name : " Run Unit Tests"
67
+ run : |
68
+ echo "Running unit tests..."
69
+ go test -v ./... -coverprofile=coverage.txt -covermode=atomic
70
+ if [ $? -ne 0 ]; then
71
+ echo "Unit tests failed"
72
+ exit 1
73
+ fi
74
+ echo "Unit tests completed successfully"
75
+
76
+ # Upload Coverage
77
+ - name : " Upload Coverage"
78
+ uses : codecov/codecov-action@v3
79
+ with :
80
+ file : ./coverage.txt
81
+ flags : unittests
82
+
64
83
# This step only runs when the event type is a pull_request
65
- # - name: Integrate Test
66
- # if: ${{ github.event_name == 'pull_request' }}
67
- # run: |
68
- # 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}}
69
- #
70
- # # This step only runs when the event type is a push
71
- # - name: Integrate Test
72
- # if: ${{ github.event_name == 'push' }}
73
- # run: |
74
- # chmod +x integrate_test.sh && ./integrate_test.sh $GITHUB_REPOSITORY $GITHUB_SHA $GITHUB_BASE_REF
75
- #
84
+ - name : Integrate Test
85
+ if : ${{ github.event_name == 'pull_request' }}
86
+ run : |
87
+ 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}}
88
+
89
+ # This step only runs when the event type is a push
90
+ - name : Integrate Test
91
+ if : ${{ github.event_name == 'push' }}
92
+ run : |
93
+ chmod +x integrate_test.sh && ./integrate_test.sh $GITHUB_REPOSITORY $GITHUB_SHA $GITHUB_BASE_REF
0 commit comments