chore(ci): add SonarCloud scan job to the build-test workflow - #327
Conversation
Co-Authored-By: jason.han <jason.han@jpl.nasa.gov>
Original prompt from Devin Bot
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…he python test split Co-Authored-By: jason.han <jason.han@jpl.nasa.gov>
Summary
Adds a SonarCloud scan to CircleCI, mirroring
Open-MBEE/flexo-mms-layer1-serviceso its existingSonarCloudcontext (which suppliesSONAR_TOKEN) is reused with no new credential:sonarsource/sonarcloud@4.0.0(pinned, same as layer1) and ascanjob in thebuild-testworkflow withrequires: [build-and-test],context: [SonarCloud], and the same branch/tag filters as the workflow's other jobs.sonar-project.propertiesin the Go form (sonar.sources=./sonar.tests=./sonar.test.inclusions, per the current Sonar Go docs): hand-written Go andpython/opensysmlare source;**/*_test.goandpython/tests/**are tests; fixture/corpus/generated trees are excluded (**/testdata/**,examples/**incl. the fetched OMG corpus,python/tests/golden/**,**/*.pb.go, generatedinternal/core/rdf/ontology/table.go).scripts/and.github/workflowsstay in scope on purpose. Novendor/dir exists, so none is excluded.build-and-testalready writescoverage.txtbut only persistedbin/sysml-grpc;coverage.txtis now persisted too, and the scan job attaches the workspace at the checkout root (wheresonar.go.coverage.reportPaths=coverage.txtresolves) and prints the file so an absent profile is visible rather than silently analysed as no coverage.circleci-agent step halt) whenSONAR_TOKENis empty, since forked PRs never receive the context. With a token present, a failing scan fails the job.git rev-parse --is-shallow-repositoryguard) because SonarCloud needs full history for blame/new-code, and awhen: on_failstep points at the setup doc.docs/project/releasing.mdcovering the context name, what the scan reads, fork behaviour, and the one-time project-provisioning step (already done forOpen-MBEE_OpenSysML; kept because a CI-run scan cannot auto-create a project).Scope corrections and coverage wiring only — no rule silencing, severity changes, or quality-gate overrides.
Baseline from the first scan of
main@ a6544ed (public API,api/measures/component?component=Open-MBEE_OpenSysML&metricKeys=ncloc,coverage):ncloc=157022, nocoverage/lines_to_covermeasure at all, and the analysis includedexamples/,python/tests/golden, andapi/proto. The exclusions above should drop the fixture/generated trees from the analysis, and coverage should appear — provable only on the first CI run of this config, since the scan needs the CI-sideSONAR_TOKEN.No existing job's commands, gates, or filters changed beyond the added workspace path.
Verification:
circleci config validate .circleci/config.yml→ valid;go build ./...,go vet ./...,gofmt -l .(empty),go test ./..., the training-corpus gate withOPENSYSML_REQUIRE_TRAINING_CORPUS=1, andpython3 scripts/check-doc-links.pyall pass. The scan itself was not exercised locally (noSONAR_TOKEN, context is CI-only).Link to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/6b0bcfcf8a4547b78190001d31c4e7b7
Requested by: @HuiJun