forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code coverage tracking (vitessio#11)
* added code coverage using sonar and codecov Signed-off-by: Arindam Nayak <[email protected]> Signed-off-by: Arindam Nayak <[email protected]>
- Loading branch information
1 parent
a577182
commit 9350629
Showing
23 changed files
with
401 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: sonar_analysis | ||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.13 | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y mysql-server mysql-client make unzip g++ etcd curl git wget eatmydata | ||
sudo service mysql stop | ||
sudo service etcd stop | ||
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ | ||
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld | ||
go mod download | ||
- name: Execute unit test and cluster endtoend test | ||
run: | | ||
eatmydata -- ./tools/all_test_for_coverage.sh | ||
mkdir report | ||
cp /tmp/*.out ./report/. | ||
- name: Analyse sonar | ||
run: | | ||
export SONAR_SCANNER_VERSION=4.2.0.1873 | ||
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux | ||
rm -rf $SONAR_SCANNER_HOME | ||
mkdir -p $SONAR_SCANNER_HOME | ||
curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip | ||
unzip $HOME/.sonar/sonar-sct Analysisanner.zip -d $HOME/.sonar/ | ||
rm $HOME/.sonar/sonar-scanner.zip | ||
export PATH=$SONAR_SCANNER_HOME/bin:$PATH | ||
export SONAR_SCANNER_OPTS="-server" | ||
sonar-scanner \ | ||
-Dsonar.projectKey=vitessio \ | ||
-Dsonar.organization=vitess \ | ||
-Dsonar.host.url=https://sonarcloud.io \ | ||
-Dsonar.login=${SONAR_TOKEN} \ | ||
-Dsonar.go.coverage.reportPaths=report/*.out | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
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 |
---|---|---|
|
@@ -85,3 +85,6 @@ releases | |
/vthook/ | ||
/bin/ | ||
/vtdataroot/ | ||
|
||
.scannerwork | ||
report |
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
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
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,12 @@ | ||
sonar.projectKey=vitessio | ||
sonar.projectName=vitessio | ||
sonar.sources=go | ||
sonar.exclusions=**/*_test.go,**/vendor/**,**/java/**,go/test/endtoend/**,**/*.pb.go | ||
sonar.tests=. | ||
sonar.test.inclusions=**/*_test.go | ||
sonar.test.exclusions=**/vendor/** | ||
|
||
|
||
# Change the host.url to point to the | ||
# sonarqube server (default localhost) | ||
sonar.host.url=http://localhost:9000 |
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,69 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2019 The Vitess Authors. | ||
# | ||
# 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. | ||
|
||
# These test uses excutables and launch them as process | ||
# After that all tests run, here we are testing those | ||
|
||
# All Go packages with test files. | ||
# Output per line: <full Go package name> <all _test.go files in the package>* | ||
|
||
|
||
### Execute unit testcase ### | ||
source build.env | ||
make tools | ||
make build | ||
echo "--------- executing unit testcases ---------" | ||
packages_with_all_tests=$(go list -f '{{if len .TestGoFiles}}{{.ImportPath}} {{join .TestGoFiles " "}}{{end}}' ./go/... | sort) | ||
all_except_endtoend_tests=$(echo "$packages_with_all_tests" | grep -v "endtoend" | cut -d" " -f1 ) | ||
|
||
counter=0 | ||
for pkg in $all_except_endtoend_tests | ||
do | ||
go test -coverpkg=vitess.io/vitess/go/... -coverprofile "/tmp/unit_$counter.out" $pkg -v -p=1 || : | ||
counter=$((counter+1)) | ||
done | ||
|
||
## Copy the test files to get instrumented binaries ### | ||
cp ./tools/coverage-go/vtctl_test.go ./go/cmd/vtctl/vtctl_test.go | ||
cp ./tools/coverage-go/vtctld_test.go ./go/cmd/vtctld/vtctld_test.go | ||
cp ./tools/coverage-go/mysqlctl_test.go ./go/cmd/mysqlctl/mysqlctl_test.go | ||
cp ./tools/coverage-go/vtctlclient_test.go ./go/cmd/vtctlclient/vtctlclient_test.go | ||
cp ./tools/coverage-go/vttablet_test.go ./go/cmd/vttablet/vttablet_test.go | ||
cp ./tools/coverage-go/vtgate_test.go ./go/cmd/vtgate/vtgate_test.go | ||
cp ./tools/coverage-go/vtworker_test.go ./go/cmd/vtworker/vtworker_test.go | ||
cp ./tools/coverage-go/vtworkerclient_test.go ./go/cmd/vtworkerclient/vtworkerclient_test.go | ||
|
||
go test -coverpkg=vitess.io/vitess/go/... -c vitess.io/vitess/go/cmd/vtctl -o ./bin/vtctl | ||
go test -coverpkg=vitess.io/vitess/go/... -c vitess.io/vitess/go/cmd/vtctld -o ./bin/vtctld | ||
go test -coverpkg=vitess.io/vitess/go/... -c vitess.io/vitess/go/cmd/mysqlctl -o ./bin/mysqlctl | ||
go test -coverpkg=vitess.io/vitess/go/... -c vitess.io/vitess/go/cmd/vtctlclient -o ./bin/vtctlclient | ||
go test -coverpkg=vitess.io/vitess/go/... -c vitess.io/vitess/go/cmd/vttablet -o ./bin/vttablet | ||
go test -coverpkg=vitess.io/vitess/go/... -c vitess.io/vitess/go/cmd/vtgate -o ./bin/vtgate | ||
go test -coverpkg=vitess.io/vitess/go/... -c vitess.io/vitess/go/cmd/vtworker -o ./bin/vtworker | ||
go test -coverpkg=vitess.io/vitess/go/... -c vitess.io/vitess/go/cmd/vtworkerclient -o ./bin/vtworkerclient | ||
|
||
### Execute go/test/endtoend testcase ### | ||
echo "--------- executing endtoend testcases ---------" | ||
cluster_tests=$(echo "$packages_with_all_tests" | grep -E "go/test/endtoend" | cut -d" " -f1) | ||
|
||
|
||
# Run cluster test sequentially | ||
for i in $cluster_tests | ||
do | ||
echo "starting test for $i" | ||
go test $i -v -p=1 -is-coverage=true || : | ||
done | ||
|
Oops, something went wrong.