mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 09:36:34 -05:00
Refine coverall (#472)
This commit is contained in:
parent
cf11bf0498
commit
ff09993c8b
7
.github/workflows/coverage.yml
vendored
7
.github/workflows/coverage.yml
vendored
@ -32,11 +32,12 @@ jobs:
|
||||
|
||||
- name: Get dependencies
|
||||
if: steps.cache-gomodules.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
go get -v -t -d ./...
|
||||
run: go get -v -t -d ./...
|
||||
|
||||
- name: Run coverage
|
||||
run: ./testing/coverage/coverall2
|
||||
run: |
|
||||
chmod u+x ./testing/coverage/coverall.sh
|
||||
./testing/coverage/coverall.sh
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v1
|
||||
|
@ -1,48 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
FAIL=0
|
||||
|
||||
V2RAY_OUT=${PWD}/out/v2ray
|
||||
export V2RAY_COV=${V2RAY_OUT}/cov
|
||||
COVERAGE_FILE=${V2RAY_COV}/coverage.txt
|
||||
|
||||
function test_package {
|
||||
DIR=".$1"
|
||||
DEP=$(go list -f '{{ join .Deps "\n" }}' $DIR | grep v2ray | tr '\n' ',')
|
||||
DEP=${DEP}$DIR
|
||||
RND_NAME=$(openssl rand -hex 16)
|
||||
COV_PROFILE=${V2RAY_COV}/${RND_NAME}.out
|
||||
go test -tags "json coverage" -coverprofile=${COV_PROFILE} -coverpkg=$DEP $DIR || FAIL=1
|
||||
}
|
||||
|
||||
rm -rf ${V2RAY_OUT}
|
||||
mkdir -p ${V2RAY_COV}
|
||||
touch ${COVERAGE_FILE}
|
||||
|
||||
TEST_FILES=(./*_test.go)
|
||||
if [ -f ${TEST_FILES[0]} ]; then
|
||||
test_package ""
|
||||
fi
|
||||
|
||||
for DIR in $(find * -type d ! -path "*.git*" ! -path "*vendor*" ! -path "*external*"); do
|
||||
TEST_FILES=($DIR/*_test.go)
|
||||
if [ -f ${TEST_FILES[0]} ]; then
|
||||
test_package "/$DIR"
|
||||
fi
|
||||
done
|
||||
|
||||
for OUT_FILE in $(find ${V2RAY_COV} -name "*.out"); do
|
||||
echo "Merging file ${OUT_FILE}"
|
||||
cat ${OUT_FILE} | grep -v "mode: set" >> ${COVERAGE_FILE}
|
||||
done
|
||||
|
||||
COV_SORTED=${V2RAY_COV}/coverallsorted.out
|
||||
cat ${COVERAGE_FILE} | sort -t: -k1 | grep -vw "testing" | grep -v ".pb.go" | grep -vw "vendor" | grep -vw "external" > ${COV_SORTED}
|
||||
echo "mode: set" | cat - ${COV_SORTED} > ${COVERAGE_FILE}
|
||||
|
||||
if [ "$FAIL" -eq 0 ]; then
|
||||
echo "Uploading coverage datea to codecov."
|
||||
#bash <(curl -s https://codecov.io/bash) -f ${COVERAGE_FILE} -v || echo "Codecov did not collect coverage reports."
|
||||
fi
|
||||
|
||||
exit $FAIL
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
COVERAGE_FILE=${PWD}/coverage.txt
|
||||
COV_SORTED=${PWD}/coverallsorted.out
|
||||
@ -19,8 +19,7 @@ if [ -f "${TEST_FILES[0]}" ]; then
|
||||
test_package ""
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2044
|
||||
for DIR in $(find ./* -type d ! -path "*.git*" ! -path "*vendor*" ! -path "*external*"); do
|
||||
for DIR in $(find ./* -type d ! -path "*.git*"); do
|
||||
TEST_FILES=("$DIR"/*_test.go)
|
||||
if [ -f "${TEST_FILES[0]}" ]; then
|
||||
test_package "/$DIR"
|
||||
@ -34,7 +33,7 @@ do
|
||||
< "${OUT_FILE}" grep -v "mode: set" >> "$COVERAGE_FILE"
|
||||
done < <(find ./* -name "*.out" -print0)
|
||||
|
||||
< "$COVERAGE_FILE" sort -t: -k1 | grep -vw "testing" | grep -v ".pb.go" | grep -vw "vendor" | grep -vw "external" > "$COV_SORTED"
|
||||
< "$COVERAGE_FILE" sort -t: -k1 | grep -vw "testing" | grep -v ".pb.go" > "$COV_SORTED"
|
||||
echo "mode: set" | cat - "${COV_SORTED}" > "${COVERAGE_FILE}"
|
||||
|
||||
bash <(curl -s https://codecov.io/bash) || echo 'Codecov failed to upload'
|
Loading…
Reference in New Issue
Block a user