Skip to content

Commit 748f276

Browse files
authored
Merge pull request #205 from tuna/test/ci
Fix unit tests in CI
2 parents 181fddb + 0ebfc58 commit 748f276

File tree

9 files changed

+54
-372
lines changed

9 files changed

+54
-372
lines changed

Diff for: .github/workflows/tunasync.yml

+18-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: tunasync
22

3-
on: [push, pull_request, workflow_dispatch]
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
workflow_dispatch:
49

510
jobs:
611

@@ -71,7 +76,7 @@ jobs:
7176
run: |
7277
make build-test-worker
7378
sudo mkdir /sys/fs/cgroup/tunasync
74-
sudo ./worker.test -test.v=true -test.coverprofile profile2.cov -test.run TestCgroup
79+
sudo ./worker.test -test.v=true -test.coverprofile profile2.gcov -test.run TestCgroup
7580
sudo rmdir /sys/fs/cgroup/tunasync
7681
touch /tmp/dummy_exec
7782
chmod +x /tmp/dummy_exec
@@ -80,7 +85,7 @@ jobs:
8085
shift
8186
argv0="$1"
8287
shift
83-
(TESTREEXEC="$case" TERM=xterm-256color exec -a "$argv0" ./worker.test -test.v=true -test.coverprofile "profile5_$case.cov" -test.run TestReexec -- "$@")
88+
(TESTREEXEC="$case" TERM=xterm-256color exec -a "$argv0" ./worker.test -test.v=true -test.coverprofile "profile5_$case.gcov" -test.run TestReexec -- "$@")
8489
}
8590
run_test_reexec 1 tunasync-exec __dummy__
8691
run_test_reexec 2 tunasync-exec /tmp/dummy_exec
@@ -190,13 +195,14 @@ jobs:
190195
run: |
191196
CUSER="$(id --user --name)"
192197
sudo rsh 254.255.255.2 bash --noprofile --norc -eo pipefail << EOF
198+
exec 2>&1
193199
cd "/home/${CUSER}"
194200
lssubsys -am
195201
cgcreate -a "$CUSER" -t "$CUSER" -g cpu:tunasync
196202
cgcreate -a "$CUSER" -t "$CUSER" -g memory:tunasync
197203
TERM=xterm-256color ./worker.test -test.v=true -test.coverprofile \
198-
profile3.cov -test.run TestCgroup
199-
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"
204+
profile3.gcov -test.run TestCgroup
205+
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"
200206
EOF
201207
202208
- name: Stop Uml
@@ -221,15 +227,17 @@ jobs:
221227
- name: Combine coverage files
222228
run : |
223229
CUSER="$(id --user --name)"
224-
"${HOME}/go/bin/gocovmerge" profile.cov profile2.cov \
225-
"umlrootfs/home/${CUSER}/profile3.cov" \
226-
"umlrootfs/home/${CUSER}/profile4.cov" \
227-
profile5_*.cov > profile-all.cov
230+
"${HOME}/go/bin/gocovmerge" profile.gcov profile2.gcov \
231+
"umlrootfs/home/${CUSER}/profile3.gcov" \
232+
"umlrootfs/home/${CUSER}/profile4.gcov" \
233+
profile5_*.gcov > merged.gcov
234+
# remove cmdline tools from coverage statistics
235+
grep -v "cmd/.*\.go" merged.gcov > profile-all.gcov
228236
229237
- name: Convert coverage to lcov
230238
uses: jandelgado/gcov2lcov-action@v1
231239
with:
232-
infile: profile-all.cov
240+
infile: profile-all.gcov
233241
outfile: coverage.lcov
234242

235243
- name: Coveralls

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
/build
22
/build-*
3+
worker.test
4+
profile*

Diff for: Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ $(BUILDBIN): % : build-$(ARCH) build-$(ARCH)/%
1414

1515
$(BUILDBIN:%=build-$(ARCH)/%) : build-$(ARCH)/% : cmd/%
1616
GOOS=$(GOOS) GOARCH=$(GOARCH) go get ./$<
17-
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $@ -ldflags ${LDFLAGS} github.com/tuna/tunasync/$<
17+
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -o $@ -ldflags ${LDFLAGS} github.com/tuna/tunasync/$<
1818

1919
test:
20-
go test -v -covermode=count -coverprofile=profile.cov ./...
20+
go test -v -covermode=count -coverprofile=profile.gcov ./...
2121

2222
build-test-worker:
23-
go test -c -covermode=count ./worker
23+
CGO_ENABLED=0 go test -c -covermode=count github.com/tuna/tunasync/worker
2424

2525
clean:
2626
rm -rf build-$(ARCH)

Diff for: go.mod

+3-84
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be
1111
github.com/boltdb/bolt v1.3.1
1212
github.com/codeskyblue/go-sh v0.0.0-20200712050446-30169cf553fe
13-
github.com/containerd/cgroups v1.1.0
13+
github.com/containerd/cgroups/v3 v3.0.5
1414
github.com/dennwc/btrfs v0.0.0-20241002142654-12ae127e0bf6
1515
github.com/dgraph-io/badger/v2 v2.2007.4
1616
github.com/docker/go-units v0.5.0
@@ -32,138 +32,57 @@ require (
3232
replace github.com/boltdb/bolt v1.3.1 => go.etcd.io/bbolt v1.3.11
3333

3434
require (
35-
github.com/DataDog/zstd v1.5.6 // indirect
36-
github.com/OneOfOne/xxhash v1.2.2 // indirect
3735
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a // indirect
38-
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6 // indirect
3936
github.com/bytedance/sonic v1.12.7 // indirect
4037
github.com/bytedance/sonic/loader v0.2.2 // indirect
4138
github.com/cespare/xxhash v1.1.0 // indirect
4239
github.com/cespare/xxhash/v2 v2.3.0 // indirect
43-
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
44-
github.com/chenzhuoyu/iasm v0.9.0 // indirect
45-
github.com/chzyer/logex v1.2.1 // indirect
46-
github.com/chzyer/readline v1.5.1 // indirect
47-
github.com/chzyer/test v1.0.0 // indirect
4840
github.com/cilium/ebpf v0.17.1 // indirect
4941
github.com/cloudwego/base64x v0.1.4 // indirect
50-
github.com/cloudwego/iasm v0.2.0 // indirect
5142
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 // indirect
52-
github.com/coreos/etcd v3.3.10+incompatible // indirect
53-
github.com/coreos/go-etcd v2.0.0+incompatible // indirect
54-
github.com/coreos/go-semver v0.2.0 // indirect
43+
github.com/containerd/log v0.1.0 // indirect
5544
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
56-
github.com/cpuguy83/go-md2man v1.0.10 // indirect
5745
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
58-
github.com/creack/pty v1.1.9 // indirect
59-
github.com/davecgh/go-spew v1.1.1 // indirect
6046
github.com/dennwc/ioctl v1.0.0 // indirect
6147
github.com/dgraph-io/ristretto v0.2.0 // indirect
6248
github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da // indirect
6349
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
6450
github.com/dustin/go-humanize v1.0.1 // indirect
6551
github.com/felixge/fgprof v0.9.5 // indirect
66-
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect
67-
github.com/frankban/quicktest v1.14.5 // indirect
68-
github.com/fsnotify/fsnotify v1.4.9 // indirect
6952
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
7053
github.com/gin-contrib/sse v1.0.0 // indirect
71-
github.com/go-logr/logr v1.4.2 // indirect
72-
github.com/go-logr/stdr v1.2.2 // indirect
73-
github.com/go-playground/assert/v2 v2.2.0 // indirect
7454
github.com/go-playground/locales v0.14.1 // indirect
7555
github.com/go-playground/universal-translator v0.18.1 // indirect
7656
github.com/go-playground/validator/v10 v10.23.0 // indirect
77-
github.com/go-quicktest/qt v1.101.0 // indirect
78-
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
7957
github.com/goccy/go-json v0.10.4 // indirect
8058
github.com/godbus/dbus/v5 v5.1.0 // indirect
81-
github.com/gogo/protobuf v1.3.2 // indirect
8259
github.com/golang/protobuf v1.5.4 // indirect
8360
github.com/golang/snappy v0.0.4 // indirect
8461
github.com/gomodule/redigo v1.8.2 // indirect
85-
github.com/google/go-cmp v0.6.0 // indirect
86-
github.com/google/gofuzz v1.0.0 // indirect
8762
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
8863
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
89-
github.com/hashicorp/hcl v1.0.0 // indirect
90-
github.com/hpcloud/tail v1.0.0 // indirect
91-
github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465 // indirect
92-
github.com/inconshreveable/mousetrap v1.0.0 // indirect
93-
github.com/josharian/native v1.1.0 // indirect
94-
github.com/jsimonetti/rtnetlink/v2 v2.0.1 // indirect
9564
github.com/json-iterator/go v1.1.12 // indirect
9665
github.com/jtolds/gls v4.20.0+incompatible // indirect
97-
github.com/kisielk/errcheck v1.5.0 // indirect
98-
github.com/kisielk/gotool v1.0.0 // indirect
9966
github.com/klauspost/compress v1.17.11 // indirect
10067
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
101-
github.com/knz/go-libedit v1.10.1 // indirect
102-
github.com/kr/pretty v0.3.1 // indirect
103-
github.com/kr/pty v1.1.1 // indirect
104-
github.com/kr/text v0.2.0 // indirect
10568
github.com/leodido/go-urn v1.4.0 // indirect
106-
github.com/magiconair/properties v1.8.0 // indirect
10769
github.com/mattn/go-isatty v0.0.20 // indirect
108-
github.com/mdlayher/netlink v1.7.2 // indirect
109-
github.com/mdlayher/socket v0.4.1 // indirect
110-
github.com/mitchellh/go-homedir v1.1.0 // indirect
111-
github.com/mitchellh/mapstructure v1.1.2 // indirect
70+
github.com/moby/sys/userns v0.1.0 // indirect
11271
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
11372
github.com/modern-go/reflect2 v1.0.2 // indirect
114-
github.com/nxadm/tail v1.4.8 // indirect
115-
github.com/onsi/ginkgo v1.16.5 // indirect
116-
github.com/onsi/ginkgo/v2 v2.0.0 // indirect
117-
github.com/onsi/gomega v1.18.1 // indirect
118-
github.com/pelletier/go-toml v1.2.0 // indirect
11973
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
120-
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e // indirect
121-
github.com/pmezard/go-difflib v1.0.0 // indirect
12274
github.com/rogpeppe/go-internal v1.13.1 // indirect
123-
github.com/russross/blackfriday v1.5.2 // indirect
12475
github.com/russross/blackfriday/v2 v2.1.0 // indirect
125-
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
12676
github.com/sirupsen/logrus v1.9.3 // indirect
12777
github.com/smartystreets/assertions v1.2.0 // indirect
128-
github.com/spaolacci/murmur3 v1.1.0 // indirect
129-
github.com/spf13/afero v1.1.2 // indirect
130-
github.com/spf13/cast v1.3.0 // indirect
131-
github.com/spf13/cobra v0.0.5 // indirect
132-
github.com/spf13/jwalterweatherman v1.0.0 // indirect
133-
github.com/spf13/pflag v1.0.3 // indirect
134-
github.com/spf13/viper v1.3.2 // indirect
135-
github.com/stretchr/objx v0.5.2 // indirect
136-
github.com/stretchr/testify v1.10.0 // indirect
13778
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
13879
github.com/ugorji/go/codec v1.2.12 // indirect
139-
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77 // indirect
140-
github.com/yuin/goldmark v1.4.13 // indirect
14180
github.com/yuin/gopher-lua v0.0.0-20191220021717-ab39c6098bdb // indirect
142-
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
143-
go.opentelemetry.io/otel v1.33.0 // indirect
144-
go.opentelemetry.io/otel/metric v1.33.0 // indirect
145-
go.opentelemetry.io/otel/trace v1.33.0 // indirect
146-
go.uber.org/goleak v1.1.12 // indirect
14781
golang.org/x/arch v0.13.0 // indirect
14882
golang.org/x/crypto v0.32.0 // indirect
149-
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 // indirect
150-
golang.org/x/lint v0.0.0-20190930215403-16217165b5de // indirect
151-
golang.org/x/mod v0.18.0 // indirect
15283
golang.org/x/net v0.34.0 // indirect
153-
golang.org/x/sync v0.10.0 // indirect
154-
golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457 // indirect
155-
golang.org/x/term v0.28.0 // indirect
15684
golang.org/x/text v0.21.0 // indirect
157-
golang.org/x/tools v0.22.0 // indirect
158-
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
15985
google.golang.org/protobuf v1.36.2 // indirect
16086
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
161-
gopkg.in/errgo.v2 v2.1.0 // indirect
162-
gopkg.in/fsnotify.v1 v1.4.7 // indirect
163-
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
164-
gopkg.in/yaml.v2 v2.4.0 // indirect
16587
gopkg.in/yaml.v3 v3.0.1 // indirect
166-
gotest.tools/v3 v3.0.3 // indirect
167-
nullprogram.com/x/optparse v1.0.0 // indirect
168-
rsc.io/pdf v0.1.1 // indirect
16988
)

0 commit comments

Comments
 (0)