Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged

Conversation

myii
Copy link
Contributor

@myii myii commented Aug 7, 2019

  • Semi-automated using ssf-formula (v0.5.0)
  • Fix errors shown below:
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)

Refer back to: saltstack-formulas/template-formula#159 (comment).

# 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
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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 %}

Copy link
Contributor Author

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(' ') }}

Copy link
Member

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?

Copy link
Contributor Author

@myii myii Aug 7, 2019

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)
```
@myii myii force-pushed the chore/standardise-structure branch from 65cdf12 to 03d15e9 Compare August 7, 2019 17:26
@myii
Copy link
Contributor Author

myii commented Aug 7, 2019

@javierbertoli We've got an unrelated Travis error here:

            Comment: Failed to configure repo 'deb [arch=amd64  ]
http://repository.spotify.com stable non-free': W: GPG error:
http://repository.spotify.com stable InRelease:
The following signatures couldn't be verified because the public key
 is not available: NO_PUBKEY 4773BD5E130D1D45

@javierbertoli
Copy link
Member

It seems the example repo key changed. We should update it or change it to use the remote gpg file

@javierbertoli javierbertoli merged commit c78aa26 into saltstack-formulas:master Aug 7, 2019
@javierbertoli
Copy link
Member

Thanks, @myii !

@myii
Copy link
Contributor Author

myii commented Aug 7, 2019

You're welcome, @javierbertoli. Appreciate the review and merge.

@saltstack-formulas-travis

🎉 This PR is included in version 0.9.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants