From 227d40c9bf8139f34665c7f704e5481ce33eee07 Mon Sep 17 00:00:00 2001 From: wobrschalek Date: Mon, 9 Mar 2026 21:12:10 -0700 Subject: [PATCH 1/2] added sonarqcube config --- .github/workflows/sonarqube.yml | 86 +++++++++++++++++++ .../workflows/test-sysmlv2-python-client.yml | 8 +- .gitignore | 1 + sonar-project.properties | 8 ++ 4 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/sonarqube.yml create mode 100644 sonar-project.properties diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml new file mode 100644 index 0000000..a5a4ea9 --- /dev/null +++ b/.github/workflows/sonarqube.yml @@ -0,0 +1,86 @@ +name: SonarQube + +on: + push: + branches: [ main, develop ] + pull_request: + +jobs: + sonar: + runs-on: ubuntu-latest + + steps: + - name: Check SONAR_TOKEN presence + run: | + if [ -z "$SONAR_TOKEN" ]; then + echo "SONAR_TOKEN missing" + exit 1 + else + echo "SONAR_TOKEN present" + fi + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Restore SysIDE license file + run: | + if [ -n "$SYSIDE_LICENSE_CONTENT_B64" ]; then + echo "SysIDE license content found, restoring license file..." + echo "$SYSIDE_LICENSE_CONTENT_B64" | base64 -d > automator-license.lic + ls -l automator-license.lic + echo "SysIDE license key found, attempting to set up license..." + python -c " + try: + import syside + print(syside.__version__) + except ImportError: + print('syside_license not available, tests will use mocks') + except Exception as e: + print(f'Failed to activate SysIDE license: {e}, tests will use mocks') + " || echo "License setup failed, tests will use mocks" + else + echo "No SysIDE license content found, tests will use mocks if supported" + fi + env: + SYSIDE_LICENSE_CONTENT_B64: ${{ secrets.SYSIDE_LICENSE_CONTENT_B64 }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install requests + pip install git+https://github.com/Open-MBEE/sysmlv2-python-client.git@main + pip install syside==0.8.5 + pip install pytest pytest-cov pytest-check coverage + pip install -e . + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + + - name: SonarQube Scan + uses: SonarSource/sonarqube-scan-action@v6 + with: + args: > + -Dsonar.scanner.skipJreProvisioning=true + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_SCANNER_SKIP_JRE_PROVISIONING: "true" + + - name: Run tests with coverage + env: + SYSIDE_LICENSE_FILE: automator-license.lic + run: | + coverage run -m pytest + coverage xml -o coverage.xml + diff --git a/.github/workflows/test-sysmlv2-python-client.yml b/.github/workflows/test-sysmlv2-python-client.yml index 67b79aa..2ab44a3 100644 --- a/.github/workflows/test-sysmlv2-python-client.yml +++ b/.github/workflows/test-sysmlv2-python-client.yml @@ -18,7 +18,7 @@ jobs: id: setup-python uses: actions/setup-python@v4 with: - python-version: '3.11' + python-version: '3.12' - name: Cache pip dependencies uses: actions/cache@v3 @@ -37,11 +37,7 @@ jobs: - name: Run tests with coverage run: | mkdir -p test-results - pytest -v --tb=short \ - --junitxml=test-results/results.xml \ - --cov=src/sysmlv2_client \ - --cov-report=xml:test-results/coverage.xml \ - --cov-report=html:test-results/htmlcov + pytest -v --tb=short --junitxml=test-results/results.xml --cov=src/sysmlv2_client --cov-report=xml:test-results/coverage.xml --cov-report=html:test-results/htmlcov - name: Upload test results uses: actions/upload-artifact@v4 diff --git a/.gitignore b/.gitignore index e3258ba..68c2a5b 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ env/ flexo-setup/docker-compose/env/*.env /build /src/sysmlv2_python_client.egg-info +/test-results diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..3d36483 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,8 @@ +sonar.projectKey=sysmlv2-python-client +sonar.organization=openmbee +sonar.host.url=https://sonarcloud.io + +sonar.sources=src +sonar.tests=tests +sonar.python.version=3.12 +sonar.python.coverage.reportPaths=coverage.xml From bdbc7f166dd3a64cf13b58477917af9d0ef926cd Mon Sep 17 00:00:00 2001 From: wobrschalek Date: Mon, 9 Mar 2026 21:27:10 -0700 Subject: [PATCH 2/2] Update sonarqube.yml --- .github/workflows/sonarqube.yml | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index a5a4ea9..99cb37f 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -31,34 +31,10 @@ jobs: with: python-version: '3.12' - - name: Restore SysIDE license file - run: | - if [ -n "$SYSIDE_LICENSE_CONTENT_B64" ]; then - echo "SysIDE license content found, restoring license file..." - echo "$SYSIDE_LICENSE_CONTENT_B64" | base64 -d > automator-license.lic - ls -l automator-license.lic - echo "SysIDE license key found, attempting to set up license..." - python -c " - try: - import syside - print(syside.__version__) - except ImportError: - print('syside_license not available, tests will use mocks') - except Exception as e: - print(f'Failed to activate SysIDE license: {e}, tests will use mocks') - " || echo "License setup failed, tests will use mocks" - else - echo "No SysIDE license content found, tests will use mocks if supported" - fi - env: - SYSIDE_LICENSE_CONTENT_B64: ${{ secrets.SYSIDE_LICENSE_CONTENT_B64 }} - - name: Install dependencies run: | python -m pip install --upgrade pip pip install requests - pip install git+https://github.com/Open-MBEE/sysmlv2-python-client.git@main - pip install syside==0.8.5 pip install pytest pytest-cov pytest-check coverage pip install -e . @@ -78,8 +54,6 @@ jobs: SONAR_SCANNER_SKIP_JRE_PROVISIONING: "true" - name: Run tests with coverage - env: - SYSIDE_LICENSE_FILE: automator-license.lic run: | coverage run -m pytest coverage xml -o coverage.xml