diff --git a/.cirrus.star b/.cirrus.star deleted file mode 100644 index bc1f3998..00000000 --- a/.cirrus.star +++ /dev/null @@ -1,4 +0,0 @@ -load("github.com/SonarSource/cirrus-modules@v3", "load_features") - -def main(ctx): - return load_features(ctx) diff --git a/.cirrus.yml b/.cirrus.yml deleted file mode 100644 index 0664c3b7..00000000 --- a/.cirrus.yml +++ /dev/null @@ -1,84 +0,0 @@ -env: - ARTIFACTORY_URL: VAULT[development/kv/data/repox data.url] - ARTIFACTORY_PRIVATE_USERNAME: vault-${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-private-reader - ARTIFACTORY_PRIVATE_ACCESS_TOKEN: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-private-reader access_token] - ARTIFACTORY_DEPLOY_USERNAME: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-qa-deployer username] - 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] - 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-.*") - -.jfrog_config_template: &JFROG_CONFIG_TEMPLATE - jfrog_config_script: - - $JF_ALIAS config add repox --artifactory-url "$ARTIFACTORY_URL" --access-token "$ARTIFACTORY_PRIVATE_ACCESS_TOKEN" - - $JF_ALIAS poetry-config --server-id-resolve repox --repo-resolve sonarsource-pypi - - $JF_ALIAS poetry install --build-name="$CIRRUS_REPO_NAME" --build-number="$CI_BUILD_NUMBER" - -poetry_cache_template: &POETRY_CACHE - poetry_cache: - folder: ~/.cache/poetry/ - fingerprint_script: cat poetry.lock - -.poetry_macos_template: &POETRY_MACOS_TEMPLATE - <<: *POETRY_CACHE - jfrog_install_script: - - brew install jfrog-cli - - jf intro - poetry_install_script: - - brew install poetry - - poetry config keyring.enabled false # Keyring is locked in macOS VM and not needed for downloading dependencies - <<: *JFROG_CONFIG_TEMPLATE - -macos_worker_template: &MACOS_WORKER_DEFINITION - persistent_worker: - isolation: - tart: - image: ghcr.io/cirruslabs/macos-sonoma-xcode:15.3 - cpu: 3 - memory: 6G - resources: - tart-vms: 1 - labels: - envname: prod - -qa_macos_task: - alias: qa_macos - only_if: $CIRRUS_CRON == "macos-its-cron" - name: "[macOS] Run tests" - <<: [*MACOS_WORKER_DEFINITION, *POETRY_MACOS_TEMPLATE] - env: - PATH: "/Users/admin/.local/bin:$PATH" - install_uv_script: - - brew install uv - test_39_script: - - .cirrus/run_macos_tests.sh "3.9.18" - test_310_script: - - .cirrus/run_macos_tests.sh "3.10.13" - test_311_script: - - .cirrus/run_macos_tests.sh "3.11.7" - test_312_script: - - .cirrus/run_macos_tests.sh "3.12.1" - test_313_script: - - .cirrus/run_macos_tests.sh "3.13.2" - -its_macos_task: - name: "[macOS] Integration Tests" - alias: its_macos - only_if: $CIRRUS_CRON == "macos-its-cron" - # the macOS workers are only available from Monday 06:45 CEST to Friday 20:00 CEST (see https://xtranet-sonarsource.atlassian.net/wiki/spaces/Platform/pages/3447980037/MacOS+Persistent+Workers+User+Guide+-+Cirrus+CI) - <<: [*MACOS_WORKER_DEFINITION, *POETRY_MACOS_TEMPLATE] - sonarqube_cache: - folder: sonarqube_cache/ - populate_script: mkdir -p sonarqube_cache && wget -q https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-$SONARQUBE_VERSION.zip -O sonarqube_cache/sonarqube.zip - fingerprint_script: echo "sonarqube-$SONARQUBE_VERSION" - its_script: - - .cirrus/run_its.sh diff --git a/.github/actions/config-poetry/config-poetry.sh b/.github/actions/config-poetry/config-poetry.sh index 98aa7628..1ad76663 100755 --- a/.github/actions/config-poetry/config-poetry.sh +++ b/.github/actions/config-poetry/config-poetry.sh @@ -13,9 +13,12 @@ set_build_env() { } config_poetry() { - jf config add repox --artifactory-url "$ARTIFACTORY_URL" --access-token "$ARTIFACTORY_ACCESS_TOKEN" - jf poetry-config --server-id-resolve repox --repo-resolve "$ARTIFACTORY_PYPI_REPO" - jf poetry install --build-name="$PROJECT" --build-number="$BUILD_NUMBER" + echo "config add repox" + jf config add repox --artifactory-url "$ARTIFACTORY_URL" --access-token "$ARTIFACTORY_ACCESS_TOKEN" + echo "poetry-config" + jf poetry-config --server-id-resolve repox --repo-resolve "$ARTIFACTORY_PYPI_REPO" + echo "poetry install" + jf poetry install --build-name="$PROJECT" --build-number="$BUILD_NUMBER" -v } main() { diff --git a/.github/workflows/MacOsBuild.yml b/.github/workflows/MacOsBuild.yml new file mode 100644 index 00000000..4d56b8d8 --- /dev/null +++ b/.github/workflows/MacOsBuild.yml @@ -0,0 +1,81 @@ +name: macOS Build and Tests +on: + schedule: + - cron: "45 4 * * 1-5" # Monday to Friday at 06:45 CEST (04:45 UTC) + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + qa_macos: + name: "[macOS] Test Python ${{ matrix.python-version }}" + runs-on: macos-latest-xlarge + permissions: + id-token: write + contents: read + strategy: + fail-fast: false + matrix: + python-version: ["3.9.18", "3.10.13", "3.11.7", "3.12.1", "3.13.2"] + steps: + - name: Setup Cloudflare WARP + uses: SonarSource/gh-action_setup-cloudflare-warp@v1 + + - name: Checkout repository + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 + + - name: Install mise and tools + uses: jdx/mise-action@e3d7b8d67a7958d1207f6ed871e83b1ea780e7b0 # v3.3.1 + + - name: Configure poetry + uses: ./.github/actions/config-poetry + with: + python-version: ${{ matrix.python-version }} + + - name: Run tests for Python ${{ matrix.python-version }} + run: | + echo "========================================================================" + echo "Running tests on macOS with Python version: ${{ matrix.python-version }}" + echo "========================================================================" + poetry run python --version + poetry install + poetry run pytest tests/ + + its_macos: + name: "[macOS] Integration Tests" + runs-on: macos-latest-xlarge + permissions: + id-token: write + contents: read + env: + SONARQUBE_VERSION: 25.3.0.104237 + steps: + - name: Setup Cloudflare WARP + uses: SonarSource/gh-action_setup-cloudflare-warp@v1 + + - name: Checkout repository + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 + + - name: Install mise and tools + uses: jdx/mise-action@e3d7b8d67a7958d1207f6ed871e83b1ea780e7b0 # v3.3.1 + + - name: Cache SonarQube + uses: SonarSource/ci-github-actions/cache@v1 + id: sonarqube-cache + with: + path: sonarqube_cache/ + key: sonarqube-25.3.0.104237 + restore-keys: cache-${{ runner.os }}- + - name: Download SonarQube + if: ${{ !steps.sonarqube-cache.outputs.cache-hit }} + run: | + mkdir -p sonarqube_cache + if [ ! -f sonarqube_cache/sonarqube.zip ]; then + wget -q https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-$SONARQUBE_VERSION.zip -O sonarqube_cache/sonarqube.zip + fi + - name: Configure poetry + uses: ./.github/actions/config-poetry + - name: Execute the integration tests + run: ./.github/scripts/run_its.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a7c05e8f..e1f8f911 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,7 @@ name: Build on: + schedule: + - cron: "0 3 * * *" # Every day at 03:00 UTC push: branches: [master, branch-*, dogfood-*] pull_request: @@ -128,8 +130,8 @@ jobs: artifactory-deployer-role: qa-deployer qa: - name: "Test Python ${{ matrix.python-version }}" - runs-on: github-ubuntu-latest-s + name: "[${{ matrix.runner }}] Test Python ${{ matrix.python-version }}" + runs-on: ${{ matrix.runner }} needs: [install_deps] permissions: id-token: write @@ -137,9 +139,14 @@ jobs: strategy: fail-fast: false matrix: + runner: [github-ubuntu-latest-s, macos-latest-xlarge] python-version: ["3.9.18", "3.9.6", "3.10.13", "3.11.7", "3.12.1", "3.13.2", "3.14.0"] steps: + - name: Setup Cloudflare WARP + if: ${{ matrix.runner == 'macos-latest-xlarge' }} + uses: SonarSource/gh-action_setup-cloudflare-warp@v1 + - name: Checkout repository uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 - name: Configure poetry @@ -167,14 +174,22 @@ jobs: poetry run pytest tests/ its: - name: "Integration Tests" - runs-on: github-ubuntu-latest-s + name: "[${{ matrix.runner }}] Integration Tests" + runs-on: ${{ matrix.runner }} permissions: id-token: write contents: write + strategy: + fail-fast: false + matrix: + runner: [github-ubuntu-latest-s, macos-latest-xlarge] env: SONARQUBE_VERSION: 25.3.0.104237 steps: + - name: Setup Cloudflare WARP + if: ${{ matrix.runner == 'macos-latest-xlarge' }} + uses: SonarSource/gh-action_setup-cloudflare-warp@v1 + - name: Checkout repository uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 - name: Cache SonarQube diff --git a/tests/its/conftest.py b/tests/its/conftest.py index 79aff3d1..5b41ce42 100644 --- a/tests/its/conftest.py +++ b/tests/its/conftest.py @@ -38,7 +38,7 @@ def check_health(sonarqube_client: SonarQubeClient) -> bool: return False -if "CIRRUS_OS" in os.environ: +if "CI" in os.environ: from time import sleep @pytest.fixture(scope="session")