60 lines
2.3 KiB
Bash
Executable File
60 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
export JAVA_HOME=/usr/bin/sonar-scanner/jre
|
|
|
|
python3 -m venv build_venv
|
|
source build_venv/bin/activate
|
|
python3 -m pip install --upgrade pip
|
|
python3 -m pip install dependency-check
|
|
|
|
echo "coverage report generation"
|
|
|
|
python3 -m pip install coverage
|
|
|
|
# Install module & dependencies
|
|
python3 -m pip install -e .
|
|
python3 -m pip install -r requirements.txt
|
|
|
|
docker-compose -remove-orphans up -d
|
|
|
|
echo "Sleeping for 30 seconds to wait for dependency containers to finish startup..."
|
|
sleep 30s
|
|
|
|
coverage run -m pytest pyinfra/test/ -x && coverage report -m && coverage xml
|
|
|
|
SERVICE_NAME=$1
|
|
|
|
echo "dependency-check:aggregate"
|
|
mkdir -p reports
|
|
dependency-check --enableExperimental -f JSON -f XML \
|
|
--disableAssembly -s . -o reports --project $SERVICE_NAME --exclude ".git/**" --exclude "venv/**" \
|
|
--exclude "build_venv/**" --exclude "**/__pycache__/**" --exclude "bamboo-specs/**"
|
|
|
|
if [[ -z "${bamboo_repository_pr_key}" ]]
|
|
then
|
|
echo "Sonar Scan for branch: ${bamboo_planRepository_1_branch}"
|
|
/usr/bin/sonar-scanner/bin/sonar-scanner -X\
|
|
-Dsonar.projectKey=RED_$SERVICE_NAME \
|
|
-Dsonar.host.url=https://sonarqube.iqser.com \
|
|
-Dsonar.login=${bamboo_sonarqube_api_token_secret} \
|
|
-Dsonar.dependencyCheck.jsonReportPath=reports/dependency-check-report.json \
|
|
-Dsonar.dependencyCheck.xmlReportPath=reports/dependency-check-report.xml \
|
|
-Dsonar.dependencyCheck.htmlReportPath=reports/dependency-check-report.html \
|
|
-Dsonar.python.coverage.reportPaths=reports/coverage.xml
|
|
|
|
else
|
|
echo "Sonar Scan for PR with key1: ${bamboo_repository_pr_key}"
|
|
/usr/bin/sonar-scanner/bin/sonar-scanner \
|
|
-Dsonar.projectKey=RED_$SERVICE_NAME \
|
|
-Dsonar.host.url=https://sonarqube.iqser.com \
|
|
-Dsonar.login=${bamboo_sonarqube_api_token_secret} \
|
|
-Dsonar.pullrequest.key=${bamboo_repository_pr_key} \
|
|
-Dsonar.pullrequest.branch=${bamboo_repository_pr_sourceBranch} \
|
|
-Dsonar.pullrequest.base=${bamboo_repository_pr_targetBranch} \
|
|
-Dsonar.dependencyCheck.jsonReportPath=reports/dependency-check-report.json \
|
|
-Dsonar.dependencyCheck.xmlReportPath=reports/dependency-check-report.xml \
|
|
-Dsonar.dependencyCheck.htmlReportPath=reports/dependency-check-report.html \
|
|
-Dsonar.python.coverage.reportPaths=reports/coverage.xml
|
|
fi
|