Skip to content

Commit

Permalink
prepare script
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin8105 committed May 30, 2024
1 parent 07cbed3 commit dbdef3c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 44 deletions.
23 changes: 11 additions & 12 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,17 @@ jobs:
- name: Coverage
run: |
go get -u github.com/wadey/gocovmerge
go get -u github.com/Konstantin8105/cs
go get -u golang.org/x/sys/unix
#TRAVIS=true ./scripts/test.sh
- name: Run Tests
run: |
echo "" > coverage.txt
go test -coverprofile=1.txt -covermode=atomic .
cat 1.txt > coverage.txt
go test -coverprofile=1.txt -covermode=atomic github.com/Konstantin8105/c4go/ast
cat 1.txt > coverage.txt
# go get -u github.com/wadey/gocovmerge
# go get -u github.com/Konstantin8105/cs
# go get -u golang.org/x/sys/unix
TRAVIS=true ./scripts/test.sh
# - name: Run Tests
# run: |
# echo "" > coverage.txt
# go test -coverprofile=1.txt -covermode=atomic .
# cat 1.txt > coverage.txt
# go test -coverprofile=1.txt -covermode=atomic github.com/Konstantin8105/c4go/ast
# cat 1.txt > coverage.txt
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
Expand Down
71 changes: 39 additions & 32 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
#!/bin/bash

set -e

echo "" > coverage.txt

mkdir -p ./testdata/

# Package list
export PKGS=$(go list ./... | grep -v c4go/testdata | grep -v c4go/examples | grep -v c4go/tests | grep -v /vendor/ | tr '\n' ' ')

# Make comma-separated.
export PKGS_DELIM=$(echo "$PKGS" | tr ' ' ',')

echo "PKGS : $PKGS"
echo "PKGS_DELIM : $PKGS_DELIM"

go test \
-cover \
-timeout=30m \
-coverpkg=$PKGS_DELIM \
-coverprofile=./testdata/pkg.coverprofile $PKGS

# Merge coverage profiles.
COVERAGE_FILES=`ls -1 ./testdata/*.coverprofile 2>/dev/null | wc -l`
if [ $COVERAGE_FILES != 0 ]; then
# check program `gocovmerge` is exist
if which gocovmerge >/dev/null 2>&1; then
export FILES=$(ls testdata/*.coverprofile | tr '\n' ' ')
echo "Combine next coverprofiles : $FILES"
gocovmerge $FILES > coverage.txt
fi
fi
go install github.com/ory/go-acc@latest

touch ./coverage.tmp
echo 'mode: atomic' > coverage.txt
go list ./... | grep -v /cmd | grep -v /vendor | xargs -n1 -I{} sh -c 'go test -covermode=atomic -coverprofile=coverage.tmp -coverpkg $(go list ./... | grep -v /vendor | tr "\n" ",") {} && tail -n +2 coverage.tmp >> coverage.txt || exit 255' && rm coverage.tmp


# set -e
#
# echo "" > coverage.txt
#
# mkdir -p ./testdata/
#
# # Package list
# export PKGS=$(go list ./... | grep -v c4go/testdata | grep -v c4go/examples | grep -v c4go/tests | grep -v /vendor/ | tr '\n' ' ')
#
# # Make comma-separated.
# export PKGS_DELIM=$(echo "$PKGS" | tr ' ' ',')
#
# echo "PKGS : $PKGS"
# echo "PKGS_DELIM : $PKGS_DELIM"
#
# go test \
# -cover \
# -timeout=30m \
# -coverpkg=$PKGS_DELIM \
# -coverprofile=./testdata/pkg.coverprofile $PKGS
#
# # Merge coverage profiles.
# COVERAGE_FILES=`ls -1 ./testdata/*.coverprofile 2>/dev/null | wc -l`
# if [ $COVERAGE_FILES != 0 ]; then
# # check program `gocovmerge` is exist
# if which gocovmerge >/dev/null 2>&1; then
# export FILES=$(ls testdata/*.coverprofile | tr '\n' ' ')
# echo "Combine next coverprofiles : $FILES"
# gocovmerge $FILES > coverage.txt
# fi
# fi

# echo "" > coverage.out
# for d in $(go list ./... | grep -v vendor); do
Expand All @@ -41,4 +48,4 @@ fi
# fi
# done

echo "End of coverage"
# echo "End of coverage"

0 comments on commit dbdef3c

Please sign in to comment.