Skip to content

SCANPY-201 Enable analysis on both SQC instances #238

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

Merged
merged 3 commits into from
Jun 23, 2025
Merged
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
39 changes: 32 additions & 7 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ 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"
SONARQUBE_VERSION: 25.3.0.104237
# Use bash (instead of sh on linux or cmd.exe on windows)
CIRRUS_SHELL: bash
JF_ALIAS: "jfrog"
CRON_NIGHTLY_JOB_NAME: "nightly"

only_if: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_TAG == "" && ($CIRRUS_PR != "" || $CIRRUS_BRANCH == 'master' || $CIRRUS_BRANCH =~ "branch-.*")
linux_container_definition: &LINUX_CONTAINER_DEFINITION
Expand Down Expand Up @@ -158,12 +157,10 @@ 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"
<<: *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 +174,34 @@ 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
# only executed in CRON job AND on master branch
only_if: $CIRRUS_CRON == $CRON_NIGHTLY_JOB_NAME && $CIRRUS_BRANCH == "master"
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
# only executed in CRON job AND on master branch
only_if: $CIRRUS_CRON == $CRON_NIGHTLY_JOB_NAME && $CIRRUS_BRANCH == "master"
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 +300,7 @@ its_macos_task:
promote_task:
depends_on:
- formatting
- analysis
- sonar_analysis_next
- 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