mit-dci / opencbdc-tx

A transaction processor for a hypothetical, general-purpose, central bank digital currency
Other
896 stars 198 forks source link

ci: add shellcheck gh action, lint fixes, parallel acts #298

Open rockett-m opened 1 month ago

rockett-m commented 1 month ago

This adds a shellcheck github workflow to check lint our shell files after discussion with @HalosGhost

I fixed a bunch of warnings / errors / info messages from shellcheck across our *.sh scripts.

Edit: added I assume we will want a scripts/shellcheck.sh script to tidy up the .github/workflows/ci.yml :: shellcheck stage - and to have an easy way for users to run shellcheck / view reports.

act -j shellcheck --container-architecture linux/amd64

rockett-m commented 1 month ago

@HalosGhost I did see the braces recommendation a lot via shellcheck. A warning not an error. I tried to clear as many warnings as I could for this PR

https://www.shellcheck.net/wiki/SC2250

rockett-m commented 1 month ago

Divide and conquer PR new plan Commit 1: ci.yml and shellcheck.sh and any fatal errors across .sh files (so the stage can pass) Commit 2: shellcheck info and warning messages fixed to .sh files Commit 3: style fixes etc and shebang update to *.sh scripts Commit 4: use NUM_CORES and xargs in lint.sh for parallelization to lint.sh

rockett-m commented 3 weeks ago

@HalosGhost Incorporated your suggestions. Added more intelligent coloring, waived error codes/severity messages, summary report.

Can be viewed here: https://github.com/mit-dci/opencbdc-tx/actions/runs/10501604065/job/29091863763?pr=298

The waivers are more powerful when looking beyond errors (majority of the info warnings are about variable quotations 'SC2086')

$ ./scripts/shellcheck.sh -C auto -S info -e SC2034 -e SC2086 -e SC1010

sh-chk

Edit: I will add a path to the full report as well in the next push