Update sonarqube.yml with docker prune #1359
Workflow file for this run
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
name: Generate SonarQube report | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
build: | |
name: Run analysis | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Run coverage commands | |
run: | | |
#!/bin/bash | |
echo "Prune docker resources - to get some free memory" | |
docker system prune -f | |
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 coverage.out ./... -json > coverage.json | |
LIB_LIST=$(find ./instrumentation -name go.mod -exec dirname {} \;) | |
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 coverage.out ./... -json > coverage.json && cd -; | |
done | |
echo "Generating test coverage for ./instrumentation/instapgx" | |
cd ./instrumentation/instapgx | |
go mod tidy | |
go test -v -tags=integration -coverpkg=./... -cover -covermode atomic -coverprofile coverage.out ./... -json > coverage.json && cd - | |
#echo "Cleaning go build cache" | |
#go clean -cache | |
#docker system prune -f | |
- name: Sonarqube Scan | |
uses: sonarsource/sonarqube-scan-action@master | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} |