diff --git a/.github/workflows/coverage_run_and_upload.yml b/.github/workflows/coverage_run_and_upload.yml deleted file mode 100644 index 4cdd89d77..000000000 --- a/.github/workflows/coverage_run_and_upload.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Generate code coverage and upload to artifact -on: - push: - branches: - - main - pull_request: - types: [opened, synchronize, reopened] -jobs: - build: - 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" - - go test -v -coverpkg=./... -cover -covermode atomic -coverprofile $TRACER_PATH/coverage/coverage.out ./... -json > $TRACER_PATH/coverage/coverage.json - - DEPRECATED_PKGS=".*instaamqp$" - - LIB_LIST=$(find ./instrumentation -name go.mod -exec dirname {} \; | grep -E -v "$DEPRECATED_PKGS") - - 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 - - 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: Upload code coverage - uses: actions/upload-artifact@v3 - with: - name: go-tracer-code-coverage - path: coverage - diff --git a/.github/workflows/coverage_run_and_upload_sonarcloud.yml b/.github/workflows/coverage_run_and_upload_sonarcloud.yml deleted file mode 100644 index ef5cb2273..000000000 --- a/.github/workflows/coverage_run_and_upload_sonarcloud.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Generate code coverage and upload to artifact for sonarcloud -on: - push: - branches: - - main -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: Upload code coverage - uses: actions/upload-artifact@v3 - with: - name: go-tracer-code-coverage-sonarcloud - path: coverage - diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 19b174c00..6369a74f6 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -1,41 +1,68 @@ name: Generate SonarCloud report on: - workflow_run: - workflows: [Generate code coverage and upload to artifact for sonarcloud] - types: [completed] + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] jobs: - build: - name: Run sonarcloud analysis + generateCoverage: + name: Code Coverage runs-on: ubuntu-latest - if: github.event.workflow_run.conclusion == 'success' + env: + COSMOS_CONNECTION_URL: ${{ secrets.COSMOS_CONNECTION_URL }} + COSMOS_KEY: ${{ secrets.COSMOS_KEY }} steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: 'Download code coverage' - uses: actions/github-script@v6 - with: - script: | - let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.payload.workflow_run.id, - }); - let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { - return artifact.name == "go-tracer-code-coverage-sonarcloud" - })[0]; - let download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip', - }); - let fs = require('fs'); - fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/go-tracer-code-coverage-sonarcloud.zip`, Buffer.from(download.data)); - - name: 'Unzip code coverage' - run: unzip go-tracer-code-coverage-sonarcloud.zip -d coverage + - 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 }} + diff --git a/.github/workflows/sonarcloud_for_pr.yml b/.github/workflows/sonarcloud_for_pr.yml deleted file mode 100644 index 23d7dee14..000000000 --- a/.github/workflows/sonarcloud_for_pr.yml +++ /dev/null @@ -1,65 +0,0 @@ -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 }} - diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml deleted file mode 100644 index f4a1868ae..000000000 --- a/.github/workflows/sonarqube.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Generate SonarQube report -on: - workflow_run: - workflows: [Generate code coverage and upload to artifact] - types: [completed] -jobs: - build: - name: Run analysis - runs-on: ubuntu-latest - if: github.event.workflow_run.conclusion == 'success' - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: 'Download code coverage' - uses: actions/github-script@v6 - with: - script: | - let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.payload.workflow_run.id, - }); - let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { - return artifact.name == "go-tracer-code-coverage" - })[0]; - let download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip', - }); - let fs = require('fs'); - fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/go-tracer-code-coverage.zip`, Buffer.from(download.data)); - - name: 'Unzip code coverage' - run: unzip go-tracer-code-coverage.zip -d coverage - - name: Sonarqube Scan - uses: sonarsource/sonarqube-scan-action@master - - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}