github.com/instana/go-sensor@v1.62.2-0.20240520081010-4919868049e1/.github/workflows/coverage_run_and_upload.yml (about)

     1  name: Generate code coverage and upload to artifact
     2  on:
     3    push:
     4      branches:
     5        - main
     6    pull_request:
     7      types: [opened, synchronize, reopened]
     8  jobs:
     9    build:
    10      name: Code Coverage
    11      runs-on: ubuntu-latest
    12      env:
    13        COSMOS_CONNECTION_URL: ${{ secrets.COSMOS_CONNECTION_URL }}
    14        COSMOS_KEY: ${{ secrets.COSMOS_KEY }}
    15      steps:
    16        - uses: actions/checkout@v3
    17          with:
    18            fetch-depth: 0
    19        - name: Run coverage commands
    20          run: |
    21              #!/bin/bash
    22  
    23              TRACER_PATH=$(pwd)
    24              echo $TRACER_PATH
    25              mkdir coverage
    26  
    27              echo "Starting Couchbase"
    28              docker-compose -f docker-compose-integration.yaml up -d
    29  
    30              echo "Starting Postgres"
    31              sudo systemctl start postgresql.service
    32              sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'mysecretpassword'"
    33              echo "After starting Postgres"
    34  
    35              go test -v -coverpkg=./... -cover -covermode atomic -coverprofile $TRACER_PATH/coverage/coverage.out ./... -json > $TRACER_PATH/coverage/coverage.json
    36  
    37              DEPRECATED_PKGS=".*instaamqp$"
    38    
    39              LIB_LIST=$(find ./instrumentation -name go.mod -exec dirname {} \; | grep -E -v "$DEPRECATED_PKGS")
    40  
    41              for lib in $LIB_LIST
    42                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 -;
    43              done
    44  
    45              INTEGRATIONS_TESTS=("instagocb" "instapgx" "instacosmos")
    46  
    47              for str in ${INTEGRATIONS_TESTS[@]}; do
    48                dir=./instrumentation/$str
    49                echo "Generating test coverage for $dir"
    50                cd $dir
    51                go mod tidy
    52                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 -
    53              done
    54  
    55        - name: Upload code coverage
    56          uses: actions/upload-artifact@v3
    57          with:
    58            name: go-tracer-code-coverage
    59            path: coverage
    60