github.com/wangyougui/gf/v2@v2.6.5/.github/workflows/ci-main.sh (about) 1 #!/usr/bin/env bash 2 3 coverage=$1 4 5 # find all path that contains go.mod. 6 for file in `find . -name go.mod`; do 7 dirpath=$(dirname $file) 8 echo $dirpath 9 10 if [[ $file =~ "/testdata/" ]]; then 11 echo "ignore testdata path $file" 12 continue 1 13 fi 14 15 # package kuhecm needs golang >= v1.19 16 if [ "kubecm" = $(basename $dirpath) ]; then 17 continue 1 18 if ! go version|grep -qE "go1.19|go1.[2-9][0-9]"; then 19 echo "ignore kubecm as go version: $(go version)" 20 continue 1 21 fi 22 fi 23 24 # package consul needs golang >= v1.19 25 if [ "consul" = $(basename $dirpath) ]; then 26 continue 1 27 if ! go version|grep -qE "go1.19|go1.[2-9][0-9]"; then 28 echo "ignore consul as go version: $(go version)" 29 continue 1 30 fi 31 fi 32 33 # package etcd needs golang >= v1.19 34 if [ "etcd" = $(basename $dirpath) ]; then 35 if ! go version|grep -qE "go1.19|go1.[2-9][0-9]"; then 36 echo "ignore etcd as go version: $(go version)" 37 continue 1 38 fi 39 fi 40 41 # package polaris needs golang >= v1.19 42 if [ "polaris" = $(basename $dirpath) ]; then 43 if ! go version|grep -qE "go1.19|go1.[2-9][0-9]"; then 44 echo "ignore polaris as go version: $(go version)" 45 continue 1 46 fi 47 fi 48 49 # package example needs golang >= v1.20 50 if [ "example" = $(basename $dirpath) ]; then 51 if ! go version|grep -qE "go1.[2-9][0-9]"; then 52 echo "ignore example as go version: $(go version)" 53 continue 1 54 fi 55 fi 56 57 # package otlpgrpc needs golang >= v1.20 58 if [ "otlpgrpc" = $(basename $dirpath) ]; then 59 if ! go version|grep -qE "go1.[2-9][0-9]"; then 60 echo "ignore otlpgrpc as go version: $(go version)" 61 continue 1 62 fi 63 fi 64 65 # package otlphttp needs golang >= v1.20 66 if [ "otlphttp" = $(basename $dirpath) ]; then 67 if ! go version|grep -qE "go1.[2-9][0-9]"; then 68 echo "ignore otlphttp as go version: $(go version)" 69 continue 1 70 fi 71 fi 72 73 cd $dirpath 74 go mod tidy 75 go build ./... 76 # check coverage 77 if [ "${coverage}" = "coverage" ]; then 78 go test ./... -race -coverprofile=coverage.out -covermode=atomic -coverpkg=./...,github.com/wangyougui/gf/... || exit 1 79 80 if grep -q "/gogf/gf/.*/v2" go.mod; then 81 sed -i "s/gogf\/gf\(\/.*\)\/v2/gogf\/gf\/v2\1/g" coverage.out 82 fi 83 else 84 go test ./... -race || exit 1 85 fi 86 87 cd - 88 done