apptension / saas-boilerplate

SaaS Boilerplate - Open Source and free SaaS stack that lets you build SaaS products faster in React, Django and AWS. Focus on essential business logic instead of coding repeatable features!
https://apptension.com/saas-boilerplate
MIT License
2.23k stars 266 forks source link

Consider adding the shell scripts linter `shellcheck` into CI/CD #377

Open Toreno96 opened 1 year ago

Toreno96 commented 1 year ago

Description

We have a significant number of shell scripts in the repo:

$ fd -H '\.sh$'
packages/backend/scripts/build.sh
packages/backend/scripts/build_docs.sh
packages/backend/scripts/build_static.sh
packages/backend/scripts/deploy.sh
packages/backend/scripts/execute_remote.sh
packages/backend/scripts/install_localstack_fixtures.sh
packages/backend/scripts/run.sh
packages/backend/scripts/run_local.sh
packages/backend/scripts/run_migrations.sh
packages/backend/scripts/run_tests.sh
packages/backend/scripts/trigger_migrations_job.sh
packages/internal/core/scripts/docker-create-volumes.sh
packages/internal/core/scripts/docker-login.sh
packages/internal/core/scripts/get-version.sh
packages/internal/local-ws-server/scripts/run.sh
packages/internal/ssm-editor/scripts/run.sh
packages/internal/tools/scripts/cdk-bootstrap.sh
packages/internal/tools/scripts/chamber-exec.sh
packages/internal/tools/scripts/clean-codebuild-branches.sh
packages/webapp/scripts/start-storybook.sh
packages/webapp-libs/webapp-api-client/scripts/download-graphql-schema.sh
packages/webapp-libs/webapp-contentful/scripts/download-graphql-schema.sh
packages/workers/scripts/deploy.sh
packages/workers/scripts/run_build.sh
packages/workers/scripts/run_lint.sh
packages/workers/scripts/run_tests.sh
packages/workers/scripts/stop-task-scheduling-executions.sh
packages/workers/scripts/wait-for-it.sh

I recommend adding the shellcheck linter into CI/CD to ensure all those are free of hidden bugs and follow the best practices. It will also make it easier for users to customize those scripts if they need to, and to learn the shell scripting along the way, as it provides detailed instructions and rationale in case of any error/warning, e.g. see https://github.com/koalaman/shellcheck/wiki/SC1014.

I have been using shellcheck for several years and it helped me a lot. It also offers support pre-commit if we ever want it: https://github.com/koalaman/shellcheck#pre-commit.

Describe the solution you'd like

See above

Describe alternatives you've considered

No response

Additional context

I see that there's one mention of shellcheck in the codebase:

$ rg -. -i shellcheck
packages/backend/scripts/build.sh
12:  # shellcheck disable=SC2091

This is a directive to disable the specific warning, so I believe the author is already using shellcheck locally, but the tool is not integrated into the codebase itself 😄

Validations

Toreno96 commented 1 year ago

https://github.com/apptension/aws-boilerplate/issues/386 did not make (pun unintended) this issue outdated because we still have a few (runtime) bash scripts.