rocky-linux / infrastructure

The infrastructure monorepo for the Rocky Linux project. This project will be archived/deprecated in the future.
https://rockylinux.org
386 stars 46 forks source link

Set scripting/coding/style standards #8

Open Gorian opened 3 years ago

Gorian commented 3 years ago

Something I've often seen teams neglect but is important for long-term maintenance and ease of collaboration is standardizing on coding and style standards, like https://google.github.io/styleguide/shellguide.html for bash scripts, making sure that people aren't writing POSIX scripts but then using a #!/bin/bash shebang, or requiring python to comply with pep8, etc

oranenj commented 3 years ago

What are the automatic tools that could help enforce this? For shell scripts, running at least ShellCheck is probably a good idea.

Darkbat91 commented 3 years ago

Agreed we need to get something formalised before we get too many contributions.

Highly recommend we get ansible-lint set up and make it a requirement on the Ansible side.

Generally pre-commit is not a bad idea as well but not sure how restrictive we want this to be.

dpavlos commented 3 years ago

+1 for ansible-lint

greg-hellings commented 3 years ago

As someone who helps to maintain some of the following, and writes a TON of Ansible code...

Putting all of them into pre-commit is not too difficult, either.

danielkubat commented 3 years ago

ansible-lint GH Action: https://github.com/ansible/ansible-lint-action (PR https://github.com/rocky-linux/infrastructure/pull/24 merged) shellcheck GH Action: https://github.com/ludeeus/action-shellcheck yamllint GH Action: https://github.com/ibiqlik/action-yamllint (PR https://github.com/rocky-linux/infrastructure/pull/13 merged)

derekmpage commented 3 years ago

I guess this is a good place to bring this up, as it is not part of our current ansible structure.

How do we want to handle collections? Specifically levering Galaxy collections https://galaxy.ansible.com/ so we are duplicating efforts that are already well maintained?

nazunalika commented 3 years ago

I guess this is a good place to bring this up, as it is not part of our current ansible structure.

How do we want to handle collections? Specifically levering Galaxy collections https://galaxy.ansible.com/ so we are duplicating efforts that are already well maintained?

Our ansible structure emulates loosely the Fedora and CentOS ansible structure - We will be using ansible collections that are pulled as defined by the requirements.yml. For example, we are already defining the freeipa collection.

lisenet commented 3 years ago

+1 for ShellCheck. Standardising the way things are developed is crucial.

Gorian commented 3 years ago

I'd just like to point out that something like shellcheck and having a style guide are not necessarily the same thing - for example, shellcheck won't care if you comment your functions correctly, or whether you put do on the same line as a forloop or not, etc. but those sorts of things are still important for consistency in a large project - arguably, the correct placement of braces or whether then goes on the same line as if or the next is less important than tabs vs. spaces, but it's still important to define these things in the beginning rather than later when you realize it causes issues and then have to refactor old code.

christophedumont5 commented 3 years ago

+1 for molecule and testinfra