Skip to content

Commit

Permalink
Merge pull request #60 from myii/feat/merge-travis-matrix-and-add-sal…
Browse files Browse the repository at this point in the history
…t-lint-and-rubocop

feat: merge travis matrix, add `salt-lint` & `rubocop` to `lint` job
  • Loading branch information
myii authored Oct 10, 2019
2 parents 6d70da2 + 5890b8a commit 6a63d3a
Show file tree
Hide file tree
Showing 21 changed files with 413 additions and 85 deletions.
16 changes: 16 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
# General overrides used across formulas in the org
Metrics/LineLength:
# Increase from default of `80`
# Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`)
Max: 88

# General settings across all cops in this formula
AllCops:
# Files to ignore completely
Exclude:
- ssf/files/**/*

# Any offenses that should be fixed, e.g. collected via. `rubocop --auto-gen-config`
13 changes: 13 additions & 0 deletions .salt-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
exclude_paths: []
skip_list:
# Using `salt-lint` for linting other files as well, such as Jinja macros/templates
- 205 # Use ".sls" as a Salt State file extension
# Skipping `207` and `208` because `210` is sufficient, at least for the time-being
# I.e. Allows 3-digit unquoted codes to still be used, such as `644` and `755`
- 207 # File modes should always be encapsulated in quotation marks
- 208 # File modes should always contain a leading zero
tags: []
verbosity: 1
27 changes: 21 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,47 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
## Machine config
dist: bionic

## Stages and jobs matrix
stages:
- lint
- test
- name: release
if: branch = master AND type != pull_request

jobs:
include:
# Define the `lint` stage (runs `yamllint` and `commitlint`)
- stage: lint
language: node_js
## Define the test stage that runs the linters (and testing matrix, if applicable)

# Run all of the linters in a single job
- language: node_js
node_js: lts/*
env: Lint
name: 'Lint: salt-lint, yamllint, rubocop & commitlint'
before_install: skip
script:
# Install and run `salt-lint`
- pip install --user salt-lint
- git ls-files | grep '\.sls$\|\.jinja$\|\.j2$\|\.tmpl$'
| xargs -I {} salt-lint {}
# Install and run `yamllint`
# Need at least `v1.17.0` for the `yaml-files` setting
- pip install --user yamllint>=1.17.0
- yamllint -s .
# Install and run `rubocop`
- gem install rubocop
- rubocop -d
# Install and run `commitlint`
- npm install @commitlint/config-conventional -D
- npm install @commitlint/travis-cli -D
- commitlint-travis
# Define the release stage that runs `semantic-release`

## Define the release stage that runs `semantic-release`
- stage: release
language: node_js
node_js: lts/*
env: Release
name: 'Run semantic-release inc. file updates to AUTHORS, CHANGELOG & FORMULA'
before_install: skip
script:
# Update `AUTHORS.md`
Expand Down
3 changes: 3 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ ignore: |
test/**/states/**/*.sls
.kitchen/
ssf/files/default/.cirrus.yml
ssf/files/default/.rubocop.yml
ssf/files/default/.salt-lint
ssf/files/default/.travis.yml
ssf/files/default/.yamllint
ssf/files/default/kitchen.yml
Expand All @@ -24,6 +26,7 @@ yaml-files:
# Default settings
- '*.yaml'
- '*.yml'
- .salt-lint
- .yamllint
# SaltStack Formulas additional settings
- '*.example'
Expand Down
7 changes: 4 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source "https://rubygems.org"
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'kitchen-docker', '>= 2.9'
gem 'kitchen-salt', '>= 0.6.0'
gem 'kitchen-inspec', '>= 1.1'

gem 'kitchen-salt', '>= 0.6.0'
2 changes: 2 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ ssf:
- inspec/README.md
- .gitignore
- .cirrus.yml
- .rubocop.yml
- .salt-lint
- .travis.yml
- .yamllint
- commitlint.config.js
Expand Down
2 changes: 2 additions & 0 deletions ssf/config/formulas.sls
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ prepare-git-branch-for-{{ formula }}:
platforms: {{ context.platforms | yaml }}
platforms_matrix: {{ context.platforms_matrix | yaml }}
platforms_matrix_commented_includes: {{ context.platforms_matrix_commented_includes | yaml }}
rubocop: {{ context.rubocop | yaml }}
salt_lint: {{ context.salt_lint | yaml }}
script_kitchen: {{ context.script_kitchen | yaml }}
suite: {{ suite | yaml }}
travis: {{ context.travis | yaml }}
Expand Down
25 changes: 20 additions & 5 deletions ssf/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
---
ssf_node_anchors:
defaults:
common:
lint:
line_length:
bugbear: &line_length_bugbear 88
default: &line_length_default 80
formula: &formula_default
context: &context_default
git:
Expand All @@ -17,8 +22,8 @@ ssf_node_anchors:
# An alternative method could be to use:
# `git describe --abbrev=0 --tags`
# yamllint disable rule:line-length
title: 'feat(tofs): implementation for all file.managed'
body: '* Checked using https://github.com/myii/ssf-formula/pull/54'
title: 'ci: merge travis matrix, add `salt-lint` & `rubocop` to `lint` job'
body: '* Automated using https://github.com/myii/ssf-formula/pull/60'
# yamllint enable rule:line-length
github:
owner: saltstack-formulas
Expand Down Expand Up @@ -159,6 +164,14 @@ ssf_node_anchors:
# To deal with excessive instances when mimicking `kitchen list -b`
# If values are set, only use these as commented entries in the matrix
platforms_matrix_commented_includes: []
rubocop:
AllCops: {}
Cops:
Metrics/LineLength:
Bugbear: *line_length_bugbear
Default: *line_length_default
Max: *line_length_bugbear
salt_lint: {}
script_kitchen:
bin: bin/kitchen
cmd: verify
Expand All @@ -167,6 +180,7 @@ ssf_node_anchors:
travis:
addons: {}
dist: bionic
use_single_job_for_linters: true
use_cirrus_ci: false
use_tofs: false
yamllint:
Expand All @@ -182,6 +196,7 @@ ssf_node_anchors:
default:
- '*.yaml'
- '*.yml'
- '.salt-lint'
- '.yamllint'
additional_ssf:
- '*.example'
Expand All @@ -207,9 +222,9 @@ ssf_node_anchors:
key-duplicates: {}
# key-ordering: {}
line-length:
bugbear: 88
default: 80
max: 88
bugbear: *line_length_bugbear
default: *line_length_default
max: *line_length_bugbear
# new-line-at-end-of-file: {}
# new-lines: {}
octal-values:
Expand Down
37 changes: 37 additions & 0 deletions ssf/files/default/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
# General overrides used across formulas in the org
{%- set MLL = 'Metrics/LineLength' %}
{{ MLL }}:
{%- set rbcp_MLL = rubocop.Cops.get(MLL) %}
{%- if rbcp_MLL.Max == rbcp_MLL.Bugbear %}
# Increase from default of `{{ rbcp_MLL.Default }}`
# Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`)
{%- endif %}
Max: {{ rbcp_MLL.Max }}

{%- if rubocop.AllCops %}

# General settings across all cops in this formula
AllCops:
{#- This is purposefully simplistic for the time being,
until (if ever) more advanced configuration is necessary #}
{%- if rubocop.AllCops.Exclude %}
# Files to ignore completely
Exclude:
{%- for path in rubocop.AllCops.Exclude %}
- {{ path }}
{%- endfor %}
{%- endif %}
{%- endif %}

# Any offenses that should be fixed, e.g. collected via. `rubocop --auto-gen-config`
{%- for cop, config in rubocop.Cops.items() if cop not in [MLL] %}
{{ cop }}:
{#- This is purposefully simplistic for the time being,
until (if ever) more advanced configuration is necessary #}
{%- for k, v in config.items() %}
{{ k }}: {{ v }}
{%- endfor %}
{%- endfor %}
13 changes: 13 additions & 0 deletions ssf/files/default/.salt-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
exclude_paths: []
skip_list:
# Using `salt-lint` for linting other files as well, such as Jinja macros/templates
- 205 # Use ".sls" as a Salt State file extension
# Skipping `207` and `208` because `210` is sufficient, at least for the time-being
# I.e. Allows 3-digit unquoted codes to still be used, such as `644` and `755`
- 207 # File modes should always be encapsulated in quotation marks
- 208 # File modes should always contain a leading zero
tags: []
verbosity: 1
Loading

0 comments on commit 6a63d3a

Please sign in to comment.