github.com/gogf/gf/v2@v2.7.4/.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 # ignore mssql tests as its docker service failed 11 # TODO remove this ignoring codes after the mssql docker service OK 12 if [ "mssql" = $(basename $dirpath) ]; then 13 continue 1 14 fi 15 16 if [[ $file =~ "/testdata/" ]]; then 17 echo "ignore testdata path $file" 18 continue 1 19 fi 20 21 # package kuhecm was moved to sub ci procedure. 22 if [ "kubecm" = $(basename $dirpath) ]; then 23 continue 1 24 fi 25 26 # package consul needs golang >= v1.19 27 if [ "consul" = $(basename $dirpath) ]; then 28 if ! go version|grep -qE "go1.19|go1.[2-9][0-9]"; then 29 echo "ignore consul as go version: $(go version)" 30 continue 1 31 fi 32 fi 33 34 # package etcd needs golang >= v1.19 35 if [ "etcd" = $(basename $dirpath) ]; then 36 if ! go version|grep -qE "go1.19|go1.[2-9][0-9]"; then 37 echo "ignore etcd as go version: $(go version)" 38 continue 1 39 fi 40 fi 41 42 # package polaris needs golang >= v1.19 43 if [ "polaris" = $(basename $dirpath) ]; then 44 if ! go version|grep -qE "go1.19|go1.[2-9][0-9]"; then 45 echo "ignore polaris as go version: $(go version)" 46 continue 1 47 fi 48 fi 49 50 # package example needs golang >= v1.20 51 if [ "example" = $(basename $dirpath) ]; then 52 if ! go version|grep -qE "go1.[2-9][0-9]"; then 53 echo "ignore example as go version: $(go version)" 54 continue 1 55 fi 56 echo "the example directory only needs to be built, not unit tests and coverage tests." 57 cd $dirpath 58 go mod tidy 59 go build ./... 60 cd - 61 continue 1 62 fi 63 64 # package otlpgrpc needs golang >= v1.20 65 if [ "otlpgrpc" = $(basename $dirpath) ]; then 66 if ! go version|grep -qE "go1.[2-9][0-9]"; then 67 echo "ignore otlpgrpc as go version: $(go version)" 68 continue 1 69 fi 70 fi 71 72 # package otlphttp needs golang >= v1.20 73 if [ "otlphttp" = $(basename $dirpath) ]; then 74 if ! go version|grep -qE "go1.[2-9][0-9]"; then 75 echo "ignore otlphttp as go version: $(go version)" 76 continue 1 77 fi 78 fi 79 80 # package otelmetric needs golang >= v1.20 81 if [ "otelmetric" = $(basename $dirpath) ]; then 82 if ! go version|grep -qE "go1.[2-9][0-9]"; then 83 echo "ignore otelmetric as go version: $(go version)" 84 continue 1 85 fi 86 fi 87 88 cd $dirpath 89 go mod tidy 90 go build ./... 91 # check coverage 92 if [ "${coverage}" = "coverage" ]; then 93 go test ./... -race -coverprofile=coverage.out -covermode=atomic -coverpkg=./...,github.com/gogf/gf/... || exit 1 94 95 if grep -q "/gogf/gf/.*/v2" go.mod; then 96 sed -i "s/gogf\/gf\(\/.*\)\/v2/gogf\/gf\/v2\1/g" coverage.out 97 fi 98 else 99 go test ./... -race || exit 1 100 fi 101 102 cd - 103 done