name: SonarCloud # Main is analyzed once a day, at the commit the nightly builds: Stage 2 admits a nightly only on # that commit's own analysis, and nightly-dispatch.yml waits for it before dispatching the signer. on: workflow_dispatch: workflow_run: workflows: [VectorCraft unsigned nightly] types: [requested] branches: [main] pull_request: types: [opened, synchronize, reopened] permissions: contents: read concurrency: group: ${{ github.ref == 'refs/heads/main' && format('sonarcloud-main-{0}', github.sha) || format('sonarcloud-{0}', github.ref) }} # A main run is the analysis a nightly waits for; superseded runs there would never finish. cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: nightly-commit: name: Nightly commit is main's head # A workflow_run checks out and analyzes main's head, so main must not have moved since the # nightly started. if: github.event_name == 'workflow_run' runs-on: ubuntu-latest timeout-minutes: 2 steps: - name: Harden runner uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 with: egress-policy: audit - name: Require main's head to be the nightly's commit env: NIGHTLY_SHA: ${{ github.event.workflow_run.head_sha }} RUN_SHA: ${{ github.sha }} run: | if [ "$NIGHTLY_SHA" != "$RUN_SHA" ]; then echo "::error::main moved from $NIGHTLY_SHA to $RUN_SHA after the nightly started; this run would not analyze the nightly's commit" exit 1 fi sonarcloud: needs: nightly-commit if: ${{ !cancelled() && contains(fromJSON('["success","skipped"]'), needs.nightly-commit.result) }} # Tracked at @main so org-wide CI improvements propagate without PR churn. # The reusable workflow defaults build-jobs to 2 so a cold instrumented # archive stays within hosted-runner memory (craft-common-actions#333). uses: storytold/craft-common-actions/.github/workflows/sonarcloud.yml@main with: python-coverage-source: .github/scripts python-coverage-script: .github/scripts/tests/test_release_rpm_smoke.py secrets: inherit