forked from tikv/pd
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref tikv#4399 Signed-off-by: disksing <i@disksing.com>
- Loading branch information
Showing
7 changed files
with
112 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: PD Coverage | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
jobs: | ||
chunks: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
worker_id: [1, 2, 3, 4] | ||
outputs: | ||
job-total: 4 | ||
steps: | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17 | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Restore cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/go/pkg/mod | ||
~/.cache/go-build | ||
**/.tools | ||
**/.dashboard_download_cache | ||
key: ${{ runner.os }}-go-${{ matrix.worker_id }}-${{ hashFiles('**/go.sum') }} | ||
- name: Make Test | ||
env: | ||
WORKER_ID: ${{ matrix.worker_id }} | ||
WORKER_COUNT: 4 | ||
run: | | ||
make ci-cover-job JOB_COUNT=$WORKER_COUNT JOB_INDEX=$WORKER_ID | ||
mv covprofile covprofile_$WORKER_ID | ||
sed -i "/failpoint_binding/d" covprofile_$WORKER_ID | ||
- name: Upload coverage result ${{ matrix.worker_id }} | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: cover-reports | ||
path: covprofile_${{ matrix.worker_id }} | ||
report-coverage: | ||
needs: chunks | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Download chunk report | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: cover-reports | ||
- name: Merge | ||
env: | ||
TOTAL_JOBS: ${{needs.chunks.outputs.job-total}} | ||
run: for i in $(seq 1 $TOTAL_JOBS); do cat covprofile_$i >> covprofile; done | ||
- name: Send coverage | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
token: ${{ secrets.CODECOV }} | ||
file: ./covprofile | ||
flags: unittests | ||
name: codecov-umbrella |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
# ./ci-subtask.sh <TOTAL_TASK_N> <TASK_INDEX> | ||
|
||
packages=(`go list ./...`) | ||
dirs=(`find . -iname "*_test.go" -exec dirname {} \; | sort -u | sed -e "s/^\./github.com\/tikv\/pd/"`) | ||
tasks=($(comm -12 <(printf "%s\n" "${packages[@]}") <(printf "%s\n" "${dirs[@]}"))) | ||
|
||
weight () { | ||
if [[ $1 == "github.com/tikv/pd/server/api" ]]; then return 30; fi | ||
if [[ $1 == "github.com/tikv/pd/server/tso" ]]; then return 30; fi | ||
if [[ $1 == "github.com/tikv/pd/server/schedule" ]]; then return 30; fi | ||
if [[ $1 == "github.com/tikv/pd/tests/client" ]]; then return 30; fi | ||
if [[ $1 =~ "pd/tests" ]]; then return 5; fi | ||
return 1 | ||
} | ||
|
||
scores=(`seq "$1" | xargs -I{} echo 0`) | ||
|
||
res=() | ||
for t in ${tasks[@]}; do | ||
min_i=0 | ||
for i in ${!scores[@]}; do | ||
if [[ ${scores[i]} -lt ${scores[$min_i]} ]]; then min_i=$i; fi | ||
done | ||
weight $t | ||
scores[$min_i]=$((${scores[$min_i]} + $?)) | ||
if [[ $(($min_i+1)) -eq $2 ]]; then res+=($t); fi | ||
done | ||
|
||
printf "%s " "${res[@]}" |