-
Notifications
You must be signed in to change notification settings - Fork 92
feat(yamllint): include for this repo and apply rules throughout #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(yamllint): include for this repo and apply rules throughout #49
Conversation
# Install and run `yamllint` | ||
- pip install --user yamllint | ||
# yamllint disable-line rule:line-length | ||
- yamllint -s . .yamllint pillar.example test/salt/pillar/repositories.pillar.sls test/salt/pillar/preferences.pillar.sls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it possible to use some kind of globbing? I think we'll either lose track of the files to lint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, that is picked up automatically via. ssf-formula
. The .
is a glob, where it looks for all of the .yml
and .yaml
files recursively. We supply the rest after it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{%- set yamllint_files = ['.', '.yamllint', 'pillar.example'] %}
{#- Don't need to do this in index order but maintaining consistency with `kitchen.yml` #}
{%- for index in range(0, inspec_suites_kitchen | length) %}
{%- set suite = inspec_suites_kitchen[index] %}
{%- set pillars_from_files = suite.provisioner.pillars_from_files %}
{%- for pff in pillars_from_files %}
{%- for k, v in pff.items() %}
{%- if v not in yamllint_files %}
{%- do yamllint_files.append(v) %}
{%- endif %}
{%- endfor %}
{%- endfor %}
{%- endfor %}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# yamllint disable-line rule:line-length
- yamllint -s {{ yamllint_files | join(' ') }}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So either we should add a comment, warning that this will be automatically filled in by ssf-formula
or change that macro to do some kind of (pseudo here):
yamllint_files = [ yamllint_files_in_the_formula +
['.', '.yamllint', 'pillar.example']
].flatten.unique
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@javierbertoli Starting with the source data:
apt:
context:
git:
github:
repo: apt-formula
inspec_suites_kitchen:
0:
inspec_yml:
summary: >-
Verify that the apt repositories are configured correctly
supports: *supports_debian_ubuntu
provisioner:
pillars_from_files:
- .sls: test/salt/pillar/repositories.pillar.sls
state_top:
- '*':
- .repositories
- .update
1:
inspec_yml:
summary: >-
Verify that the apt preferences are configured correctly
supports: *supports_debian_ubuntu
provisioner:
pillars_from_files:
- .sls: test/salt/pillar/preferences.pillar.sls
state_top:
- '*':
- .preferences
You'll see that we're already tracking these "extra" files under pillars_from_files
. Introducing something like a yamllint_files_in_the_formula
would be unnecessary duplication. However, I'm sure the actual implementation itself could be improved.
* Semi-automated using `ssf-formula` (v0.5.0) * Fix errors shown below: ```bash apt-formula$ $(grep "\- yamllint" .travis.yml | sed -e "s:^\s\+-\s\(.*\):\1:") pillar.example 7:1 error trailing spaces (trailing-spaces) test/salt/pillar/repositories.pillar.sls 1:1 warning missing document start "---" (document-start) 19:1 error too many blank lines (1 > 0) (empty-lines) test/salt/pillar/preferences.pillar.sls 1:1 warning missing document start "---" (document-start) ```
65cdf12
to
03d15e9
Compare
@javierbertoli We've got an unrelated Travis error here:
|
It seems the example repo key changed. We should update it or change it to use the remote gpg file |
Thanks, @myii ! |
You're welcome, @javierbertoli. Appreciate the review and merge. |
🎉 This PR is included in version 0.9.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
ssf-formula
(v0.5.0)Refer back to: saltstack-formulas/template-formula#159 (comment).