mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 15:36:41 -05:00
CI: refine codecov (#1064)
This commit is contained in:
parent
4d768b575d
commit
b275548a80
35
.github/workflows/coverage.yml
vendored
35
.github/workflows/coverage.yml
vendored
@ -1,35 +0,0 @@
|
||||
name: Coverage
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- v*
|
||||
paths:
|
||||
- "**/*.go"
|
||||
|
||||
jobs:
|
||||
coverage:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up Go 1.x
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ^1.16.4
|
||||
|
||||
- name: Checkout codebase
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Get dependencies
|
||||
run: go get -v -t -d ./...
|
||||
|
||||
- name: Run coverage
|
||||
run: |
|
||||
chmod u+x ./testing/coverage/coverall.sh
|
||||
./testing/coverage/coverall.sh
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
file: ./coverage.txt
|
||||
fail_ci_if_error: true
|
12
.github/workflows/test.yml
vendored
12
.github/workflows/test.yml
vendored
@ -34,6 +34,16 @@ jobs:
|
||||
|
||||
- name: Checkout codebase
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Test
|
||||
run: go test -v -timeout 1h ./...
|
||||
run: |
|
||||
export PATH=$(go env GOPATH)/bin:${PATH}
|
||||
go install -v github.com/ory/go-acc@latest
|
||||
go-acc --covermode=atomic -o=coverage.txt ./...
|
||||
shell: bash
|
||||
|
||||
- name: Upload codecov
|
||||
run: bash <(curl -s https://codecov.io/bash)
|
||||
shell: bash
|
||||
|
@ -1,39 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
COVERAGE_FILE=${PWD}/coverage.txt
|
||||
COV_SORTED=${PWD}/coverallsorted.out
|
||||
|
||||
touch "$COVERAGE_FILE"
|
||||
|
||||
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=${RND_NAME}.out
|
||||
go test -coverprofile="$COV_PROFILE" -coverpkg="$DEP" "$DIR" || return
|
||||
}
|
||||
|
||||
TEST_FILES=(./*_test.go)
|
||||
if [ -f "${TEST_FILES[0]}" ]; then
|
||||
test_package ""
|
||||
fi
|
||||
|
||||
for DIR in $(find ./* -type d ! -path "*.git*"); do
|
||||
TEST_FILES=("$DIR"/*_test.go)
|
||||
if [ -f "${TEST_FILES[0]}" ]; then
|
||||
test_package "/$DIR"
|
||||
fi
|
||||
done
|
||||
|
||||
# merge out
|
||||
while IFS= read -r -d '' OUT_FILE
|
||||
do
|
||||
echo "Merging file ${OUT_FILE}"
|
||||
< "${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" > "$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