Skip to content

SCANPY-197 setup shadow scans #237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ env:
ARTIFACTORY_DEPLOY_ACCESS_TOKEN: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-qa-deployer access_token]
ARTIFACTORY_DEPLOY_REPO: sonarsource-pypi-public-qa
GITHUB_TOKEN: VAULT[development/github/token/licenses-ro token]
SONAR_TOKEN: VAULT[development/kv/data/next data.token]
SONAR_HOST_URL: https://next.sonarqube.com/sonarqube
DEPLOY_PULL_REQUEST: 'true'
POETRY_VIRTUALENVS_PATH: "~/.cache/poetry/venvs"
POETRY_CACHE_DIR: "~/.cache/poetry/pypoetry"
Expand Down Expand Up @@ -158,12 +156,12 @@ documentation_task:
- poetry run python tools/generate_cli_documentation.py
- git diff --exit-code CLI_ARGS.md

analysis_linux_task:
analysis_base_linux_template: &ANALYSIS_BASE_LINUX_TEMPLATE
<<: *LINUX_CONTAINER_DEFINITION
alias: analysis
name: "NEXT Analysis"
alias: analysis_base
name: "Analysis Base"
<<: *POETRY_INSTALL
# For NEXT analysis we don't need to set the build versions, but we still need to access jfrog to recover the dependencies
# For analysis we don't need to set the build versions, but we still need to access jfrog to recover the dependencies
analysis_script:
- poetry run pytest --cov-report=xml:coverage.xml --cov-config=pyproject.toml --cov=src --cov-branch tests
- poetry run mypy src/ > mypy-report.txt || true # mypy exits with 1 if there are errors
Expand All @@ -177,6 +175,30 @@ analysis_linux_task:
format: junit
type: text/xml

analysis_next_task:
<<: *ANALYSIS_BASE_LINUX_TEMPLATE
alias: sonar_analysis_next
name: "NEXT Analysis"
env:
SONAR_TOKEN: VAULT[development/kv/data/next data.token]
SONAR_HOST_URL: https://next.sonarqube.com/sonarqube

analysis_SQC_EU_shadow_task:
<<: *ANALYSIS_BASE_LINUX_TEMPLATE
alias: sonar_analysis_shadow_sqc_eu
name: "SQC-EU Shadow Analysis"
env:
SONAR_TOKEN: VAULT[development/kv/data/sonarcloud data.token]
SONAR_HOST_URL: https://sonarcloud.io

analysis_SQC_US_shadow_task:
<<: *ANALYSIS_BASE_LINUX_TEMPLATE
alias: sonar_analysis_shadow_sqc_us
name: "SQC-US Shadow Analysis"
env:
SONAR_TOKEN: VAULT[development/kv/data/sonarqube-us data.token]
SONAR_HOST_URL: https://sonarqube.us

qa_task:
alias: qa
matrix:
Expand Down Expand Up @@ -275,7 +297,9 @@ its_macos_task:
promote_task:
depends_on:
- formatting
- analysis
- sonar_analysis_next
- sonar_analysis_shadow_sqc_eu
- sonar_analysis_shadow_sqc_us
- qa
- qa_windows
- build
Expand Down
7 changes: 7 additions & 0 deletions .cirrus/analysis.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#!/bin/bash

function run_analysis {
# deal with strange SonarQube configuration for the US region
SONAR_REGION=""
if [ "$SONAR_HOST_URL" == "https://sonarqube.us" ]; then
SONAR_REGION="-Dsonar.region=us"
fi

# extra analysis parameters are set in the 'sonar-project.properties'
pysonar \
-Dsonar.host.url="$SONAR_HOST_URL" \
${SONAR_REGION} \
-Dsonar.token="$SONAR_TOKEN" \
-Dsonar.analysis.buildNumber=$CI_BUILD_NUMBER \
-Dsonar.analysis.pipeline="$PIPELINE_ID" \
Expand Down
1 change: 1 addition & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
sonar.projectKey=SonarSource_sonar-scanner-python
sonar.projectName=Python Scanner
sonar.organization=sonarsource
sonar.python.version=3.9,3.10,3.11,3.12,3.13
sonar.python.coverage.reportPaths=coverage.xml
sonar.python.mypy.reportPaths=mypy-report.txt
Expand Down