-
Notifications
You must be signed in to change notification settings - Fork 39
65 lines (54 loc) · 2.88 KB
/
sonarcloud_for_pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Generate SonarCloud report for PR
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
generateCoverage:
name: Code Coverage
runs-on: ubuntu-latest
env:
COSMOS_CONNECTION_URL: ${{ secrets.COSMOS_CONNECTION_URL }}
COSMOS_KEY: ${{ secrets.COSMOS_KEY }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Run coverage commands
run: |
#!/bin/bash
TRACER_PATH=$(pwd)
echo $TRACER_PATH
mkdir coverage
echo "Starting Couchbase"
docker compose -f docker-compose-integration.yaml up -d
echo "Starting Postgres"
sudo systemctl start postgresql.service
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'mysecretpassword'"
echo "After starting Postgres"
echo "unit tests - core package"
go test -v -coverpkg=./... -cover -covermode atomic -coverprofile $TRACER_PATH/coverage/coverage.out ./... -json > $TRACER_PATH/coverage/coverage.json
echo "integration tests - core package"
INTEGRATION_TESTS_TAGS=("fargate" "gcr" "lambda" "azure" "generic_serverless" "azureContainerApps")
for str in ${INTEGRATION_TESTS_TAGS[@]}; do
go test -v -coverpkg=./... -cover -covermode atomic -coverprofile $TRACER_PATH/coverage/coverage_$(date +%s%N)_$RANDOM.out -tags="$str integration" ./... -run TestIntegration -json > $TRACER_PATH/coverage/coverage_$(date +%s%N)_$RANDOM.json
done
DEPRECATED_PKGS=".*instaamqp$"
LIB_LIST=$(find ./instrumentation -name go.mod -exec dirname {} \; | grep -E -v "$DEPRECATED_PKGS")
echo "unit tests - instrumentation packages"
for lib in $LIB_LIST
do echo "Generating test coverage for $lib" && cd "$lib" && go mod tidy && go test -v -coverpkg=./... -cover -covermode atomic -coverprofile $TRACER_PATH/coverage/coverage_$(date +%s%N)_$RANDOM.out ./... -json > $TRACER_PATH/coverage/coverage_$(date +%s%N)_$RANDOM.json && cd -;
done
echo "integration tests - instrumentation packages"
INTEGRATIONS_TESTS=("instagocb" "instapgx" "instacosmos" "instapgx/v2")
for str in ${INTEGRATIONS_TESTS[@]}; do
dir=./instrumentation/$str
echo "Generating test coverage for $dir"
cd $dir
go mod tidy
go test -v -tags=integration -coverpkg=./... -cover -covermode atomic -coverprofile $TRACER_PATH/coverage/coverage_$(date +%s%N)_$RANDOM.out ./... -json > $TRACER_PATH/coverage/coverage_$(date +%s%N)_$RANDOM.json && cd -
done
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_CLOUD_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}