Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable go cache for ci, coverage of ut testing is only available after merge of pr #3011

Merged
merged 10 commits into from
Oct 11, 2023
11 changes: 9 additions & 2 deletions .github/workflows/build_and_test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

coverage=$1

# find all path that contains go.mod.
for file in `find . -name go.mod`; do
dirpath=$(dirname $file)
Expand Down Expand Up @@ -54,10 +56,15 @@ for file in `find . -name go.mod`; do
cd $dirpath
go mod tidy
go build ./...
go test ./... -race -coverprofile=coverage.out -covermode=atomic -coverpkg=./...,github.com/gogf/gf/... || exit 1
# check coverage
if [ "${coverage}" = "coverage" ]; then
go test ./... -race -coverprofile=coverage.out -covermode=atomic -coverpkg=./...,github.com/gogf/gf/... || exit 1

if grep -q "/gogf/gf/.*/v2" go.mod; then
if grep -q "/gogf/gf/.*/v2" go.mod; then
sed -i "s/gogf\/gf\(\/.*\)\/v2/gogf\/gf\/v2\1/g" coverage.out
fi
else
go test ./... -race || exit 1
fi

cd -
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/gf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,18 @@ jobs:
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
cache: false
cache-dependency-path: '**/go.sum'
cache-dependency-path: '**/go.sum'

- name: Before Script
run: bash .github/workflows/before_script.sh

- name: Build & Test
run: bash .github/workflows/build_and_test.sh
if: ${{ (github.event_name == 'push' && github.ref != 'refs/heads/master') || github.event_name == 'pull_request' }}
run: bash .github/workflows/build_and_test.sh

- name: Build & Test & Coverage
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
run: bash .github/workflows/build_and_test.sh coverage

- name: Stop Redis Cluster Containers
run: docker-compose -f ".github/workflows/redis/docker-compose.yml" down
Expand All @@ -213,6 +217,6 @@ jobs:

- name: Report Coverage
uses: codecov/codecov-action@v3
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
with:
flags: go-${{ matrix.go-version }}-${{ matrix.goarch }}