Repository navigation
Lighter PR checklist: what is now automated #3215
Replies: 2 comments
|
I am very happy to see the mcdoc screenshot being moved over to the CI, with requirements for the user to read through them, and the automatic checking of the doc headers is a very nice feature to have to alert a contributor to fix it. The clang formatting being moved is also very nice, as it is one of those that often take an accidental extra commit that adds that extra bit to the contributing process. The c linting getting fast is impressive, and it surely accelerates the PR.
These are my 2 cents anyways :-) |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Lighter PR checklist: what is now automated
Improved automation for PR work (fewer checkmarks but a grumpy linter added)
The goal is to move checks out of the PR template and into CI, so contributors tick fewer boxes and reviewers get the same guarantees automatically. Status is as of 2026-11-28.
TL;DR
mcdoc-pagesartifact.%Pentry fails the PR..comp, and the whole library is formatted now (Apply mccode-clangformat to 127 unformatted components #3213, merged).--c-lintgets fast. cppcheck takes over 12 min per instrument,clang --analyze15–30 s and finds more. The switch is in progress, with clang as a soft dependency.SNS_source_analyticwithsample_t=1changes results.-Wall -Wextracompile check run on every PR, and should the--c-lintcheckbox stay?@farhi @ebknudsen @mads-bertelsen @Lomholy @tkittel @g5t - what do you think?
(My own 0.02$ is that for now the --c-lint should stay, and it is good practice to run it - soon in a fraction of the time...)
Summary
mcdocand attach a screenshot of the rendered pagemcdoc-pagesartifactmccode-clangformaton changed components.comp; checkbox removed%Pentriesmcrun --c-lint(cppcheck, very slow)clang --analyzebeing designed1. Doc-header lint:
mccode-check-doc-params(#3211)A small Python tool (stdlib +
mccodelib) plus thecheck-doc-paramsworkflow. It runs on the.comp/.instrfiles a PR adds or modifies, and fails when:%P/%Parameterssection although the file has parameters%Pdescription (an empty cell in the mcdoc table)%Pentry (mcdoc silently uses the first)%Pentry names something that is not a parameter (stale or misspelled; OUTPUT/CALCULATED/GLOBAL sections and INHERIT/COPY components are exempt).compis not formatted withmccode-clangformat(instruments are not checked, as before)Parameters coming in via
%include'd instruments count; TRACE snippet folders are skipped. All 1188 components and instruments outsideparked/pass. Along the way the mcdoc parser got fixes, and the McStas and McXtrace headers were cleaned up, including the SasView generators and the regenerated SasView components.2. mcdoc pages from CI instead of screenshots (#3211)
The same workflow renders the mcdoc page of every changed file that passes the lint and uploads them as the
mcdoc-pagesartifact (14 days, MathJax bundled so formulas render offline). The PR template now asks: I have reviewed themcdocpage of the component/instrument in themcdoc-pagesartifact of thecheck-doc-paramsCI run, instead of asking for a screenshot.3. clang-format enforced in CI (#3211, #3213)
mccode-clangformatcheckbox is removed from the PR template.4. Making
--c-lintfast (in progress)mcrun --c-lintruns cppcheck with--check-level=exhaustiveon the whole generated C file (16k–40k lines, about 8.6k of them runtime). Measured on macOS arm64 (cppcheck 2.22.0, clang 21.1.8), on five instruments:cppcheck --check-level=exhaustive(today)cppcheck, normal levelclang --analyzeclang -fsyntax-only -Wall -Wextraclang --analyzemissed.interpolation-lib.c, uncheckedfopenresults and leaks.Proposal:
--c-lint: useclang --analyzewith the dead-store checker disabled. clang would be a soft dependency like cppcheck today: if it is missing, mcrun says so, and nothing else requires it. cppcheck stays selectable throughCLINT/CLINTERFLAGSinmccode_config.json. This is being implemented on branch c-lint-clang. The linter gets the build's -I/-D/-U flags so it finds the same headers, clang replaces cppcheck in the dev environment, and the cl.exe flag conversion bug is fixed on the way. Windows is not verified yet.-fsyntax-only -Wall -Wextra, reporting only warnings in instrument and component code. It is cheap enough for every PR; start as warn-only.--check-level=exhaustive, which makes it at least 4× faster.Bugs found along the way (fixed in #3214, open)
The first three are fixed in #3214, one line each. Only the SNS fix changes results, and only for sample_t=1. Before/after runs of other McStas and McXtrace instruments gave identical results. The interpolation-lib.c issue is left as it is.
SNS_source_analytic,sample_t=1short-pulse branch: time is sampled overttmax - tinmininstead ofttmax - ttmin, while the weight usesttmax - ttmin. It changes results wheneverttmin > tinmin, which is the default withtinmin=0.solve_2nd_order(runtime): when A and B are both about 0,*t0is never written. The gravityPROP_X0/Y0/Z0macros then compare an uninitialisedmc_dt. Rare, but undefined; the fix is one line initialising*t0.pol-lib.c,case none: setsbz=0instead of*bz=0.interpolation-lib.c,interpolator_interpolate3_3: returns a pointer to a local array. It is harmless today, since the only caller (Pol_tabled_field) just compares the pointer with NULL.Open points for discussion
-Wall -WextraCI check fail the build, or only warn at first?--c-lintcheckbox go once--c-lintuses clang, or stay as a recommended local step?mcdoc-pagesupload on a real runner.All reactions