ci: rename all coverage files to .gcov, ignore them in git

Signed-off-by: Shengqi Chen <harry-chen@outlook.com>
This commit is contained in:
Shengqi Chen 2025-01-12 15:51:20 +08:00
parent f8d7ea1828
commit 559f5705f6
No known key found for this signature in database
3 changed files with 13 additions and 11 deletions

View File

@ -76,7 +76,7 @@ jobs:
run: | run: |
make build-test-worker make build-test-worker
sudo mkdir /sys/fs/cgroup/tunasync sudo mkdir /sys/fs/cgroup/tunasync
sudo ./worker.test -test.v=true -test.coverprofile profile2.cov -test.run TestCgroup sudo ./worker.test -test.v=true -test.coverprofile profile2.gcov -test.run TestCgroup
sudo rmdir /sys/fs/cgroup/tunasync sudo rmdir /sys/fs/cgroup/tunasync
touch /tmp/dummy_exec touch /tmp/dummy_exec
chmod +x /tmp/dummy_exec chmod +x /tmp/dummy_exec
@ -85,7 +85,7 @@ jobs:
shift shift
argv0="$1" argv0="$1"
shift shift
(TESTREEXEC="$case" TERM=xterm-256color exec -a "$argv0" ./worker.test -test.v=true -test.coverprofile "profile5_$case.cov" -test.run TestReexec -- "$@") (TESTREEXEC="$case" TERM=xterm-256color exec -a "$argv0" ./worker.test -test.v=true -test.coverprofile "profile5_$case.gcov" -test.run TestReexec -- "$@")
} }
run_test_reexec 1 tunasync-exec __dummy__ run_test_reexec 1 tunasync-exec __dummy__
run_test_reexec 2 tunasync-exec /tmp/dummy_exec run_test_reexec 2 tunasync-exec /tmp/dummy_exec
@ -201,8 +201,8 @@ jobs:
cgcreate -a "$CUSER" -t "$CUSER" -g cpu:tunasync cgcreate -a "$CUSER" -t "$CUSER" -g cpu:tunasync
cgcreate -a "$CUSER" -t "$CUSER" -g memory:tunasync cgcreate -a "$CUSER" -t "$CUSER" -g memory:tunasync
TERM=xterm-256color ./worker.test -test.v=true -test.coverprofile \ TERM=xterm-256color ./worker.test -test.v=true -test.coverprofile \
profile3.cov -test.run TestCgroup profile3.gcov -test.run TestCgroup
cgexec -g "*:/" bash -c "echo 0 > /sys/fs/cgroup/systemd/tasks; exec sudo -u $CUSER env USECURCGROUP=1 TERM=xterm-256color cgexec -g cpu,memory:tunasync ./worker.test -test.v=true -test.coverprofile profile4.cov -test.run TestCgroup" cgexec -g "*:/" bash -c "echo 0 > /sys/fs/cgroup/systemd/tasks; exec sudo -u $CUSER env USECURCGROUP=1 TERM=xterm-256color cgexec -g cpu,memory:tunasync ./worker.test -test.v=true -test.coverprofile profile4.gcov -test.run TestCgroup"
EOF EOF
- name: Stop Uml - name: Stop Uml
@ -227,15 +227,15 @@ jobs:
- name: Combine coverage files - name: Combine coverage files
run : | run : |
CUSER="$(id --user --name)" CUSER="$(id --user --name)"
"${HOME}/go/bin/gocovmerge" profile.cov profile2.cov \ "${HOME}/go/bin/gocovmerge" profile.cov profile2.gcov \
"umlrootfs/home/${CUSER}/profile3.cov" \ "umlrootfs/home/${CUSER}/profile3.gcov" \
"umlrootfs/home/${CUSER}/profile4.cov" \ "umlrootfs/home/${CUSER}/profile4.gcov" \
profile5_*.cov > profile-all.cov profile5_*.gcov > profile-all.gcov
- name: Convert coverage to lcov - name: Convert coverage to lcov
uses: jandelgado/gcov2lcov-action@v1 uses: jandelgado/gcov2lcov-action@v1
with: with:
infile: profile-all.cov infile: profile-all.gcov
outfile: coverage.lcov outfile: coverage.lcov
- name: Coveralls - name: Coveralls

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
/build /build
/build-* /build-*
worker.test
profile*

View File

@ -17,10 +17,10 @@ $(BUILDBIN:%=build-$(ARCH)/%) : build-$(ARCH)/% : cmd/%
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -o $@ -ldflags ${LDFLAGS} github.com/tuna/tunasync/$< GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -o $@ -ldflags ${LDFLAGS} github.com/tuna/tunasync/$<
test: test:
go test -v -covermode=count -coverprofile=profile.cov ./... go test -v -covermode=count -coverprofile=profile.gcov ./...
build-test-worker: build-test-worker:
CGO_ENABLED=0 go test -c -covermode=count ./worker CGO_ENABLED=0 go test -c -covermode=count github.com/tuna/tunasync/worker
clean: clean:
rm -rf build-$(ARCH) rm -rf build-$(ARCH)