mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-07-02 10:14:20 +08:00
避免go test执行两次 避免因push到codecov失败造成测试失败 1457 @@ -10576,5 +10576,33 @@ yunion.io/x/onecloud/pkg/webconsole/comm 1458 yunion.io/x/onecloud/pkg/webconsole/command/ssh_command.go:147: GetData 1459 yunion.io/x/onecloud/pkg/webconsole/command/ssh_command.go:164: ShowInf 1460 total: (statements) 1461 -Push /tmp/coverage.8mKa1lRFeG/profile.out to codecov.io^M 1462 -Exited with code 7 1463 \ No newline at end of file 1464 +Push /tmp/coverage.GrWO8OlTrX/profile.out to codecov.io^M 1465 +^M 1466 + _____ _^M 1467 + / ____| | |^M 1468 +| | ___ __| | ___ ___ _____ __^M 1469 +| | / _ \ / _` |/ _ \/ __/ _ \ \ / /^M 1470 +| |___| (_) | (_| | __/ (_| (_) \ V /^M 1471 + \_____\___/ \__,_|\___|\___\___/ \_/^M 1472 + Bash-8a28df4^M 1473 +^M 1474 +^M 1475 +==> Circle CI detected.^M 1476 + project root: .^M 1477 +--> token set from env^M 1478 + Yaml found at: vendor/github.com/gin-gonic/gin/codecov.yml^M 1479 + -> Found 1 reports^M 1480 +==> Detecting git/mercurial file structure^M 1481 +==> Reading reports^M 1482 + + /tmp/coverage.GrWO8OlTrX/profile.out bytes=2221509^M
56 lines
1.4 KiB
Bash
Executable File
56 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Copyright 2019 Yunion
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
set -o errexit
|
|
set -o pipefail
|
|
|
|
function push_to_codecov() {
|
|
if [ -z "$CODECOV_TOKEN" ]; then
|
|
echo "You must set CODECOV_TOKEN"
|
|
exit 1
|
|
fi
|
|
echo "Push $profile to codecov.io"
|
|
curl -s https://codecov.io/bash | bash -s -- -c -F aFlag -f "$profile"
|
|
}
|
|
|
|
|
|
covermode=${COVERMODE:-atomic}
|
|
coverdir=$(mktemp -d /tmp/coverage.XXXXXXXXXX)
|
|
profile="${coverdir}/profile.out"
|
|
if [ -z "$pkgs" ]; then
|
|
pkgs="$(go list -mod vendor ./... | grep -vE 'host-image|hostimage')"
|
|
fi
|
|
|
|
echo "mode: $covermode" >"$profile"
|
|
go test -v \
|
|
-coverprofile="$profile" \
|
|
-covermode="$covermode" \
|
|
-mod vendor \
|
|
-ldflags '-w' \
|
|
$pkgs
|
|
go tool cover -func "$profile"
|
|
|
|
case "${1-}" in
|
|
--html)
|
|
go tool cover -html "$profile"
|
|
;;
|
|
--codecov)
|
|
if ! push_to_codecov; then
|
|
echo "ignored: push to codecov failed" >&2
|
|
fi
|
|
;;
|
|
esac
|