Skip to content

Commit 6a63d3a

Browse files
authored
Merge pull request #60 from myii/feat/merge-travis-matrix-and-add-salt-lint-and-rubocop
feat: merge travis matrix, add `salt-lint` & `rubocop` to `lint` job
2 parents 6d70da2 + 5890b8a commit 6a63d3a

File tree

21 files changed

+413
-85
lines changed

21 files changed

+413
-85
lines changed

.rubocop.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
# General overrides used across formulas in the org
5+
Metrics/LineLength:
6+
# Increase from default of `80`
7+
# Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`)
8+
Max: 88
9+
10+
# General settings across all cops in this formula
11+
AllCops:
12+
# Files to ignore completely
13+
Exclude:
14+
- ssf/files/**/*
15+
16+
# Any offenses that should be fixed, e.g. collected via. `rubocop --auto-gen-config`

.salt-lint

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
exclude_paths: []
5+
skip_list:
6+
# Using `salt-lint` for linting other files as well, such as Jinja macros/templates
7+
- 205 # Use ".sls" as a Salt State file extension
8+
# Skipping `207` and `208` because `210` is sufficient, at least for the time-being
9+
# I.e. Allows 3-digit unquoted codes to still be used, such as `644` and `755`
10+
- 207 # File modes should always be encapsulated in quotation marks
11+
- 208 # File modes should always contain a leading zero
12+
tags: []
13+
verbosity: 1

.travis.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,47 @@
11
# -*- coding: utf-8 -*-
22
# vim: ft=yaml
33
---
4+
## Machine config
45
dist: bionic
6+
7+
## Stages and jobs matrix
58
stages:
6-
- lint
9+
- test
710
- name: release
811
if: branch = master AND type != pull_request
9-
1012
jobs:
1113
include:
12-
# Define the `lint` stage (runs `yamllint` and `commitlint`)
13-
- stage: lint
14-
language: node_js
14+
## Define the test stage that runs the linters (and testing matrix, if applicable)
15+
16+
# Run all of the linters in a single job
17+
- language: node_js
1518
node_js: lts/*
19+
env: Lint
20+
name: 'Lint: salt-lint, yamllint, rubocop & commitlint'
1621
before_install: skip
1722
script:
23+
# Install and run `salt-lint`
24+
- pip install --user salt-lint
25+
- git ls-files | grep '\.sls$\|\.jinja$\|\.j2$\|\.tmpl$'
26+
| xargs -I {} salt-lint {}
1827
# Install and run `yamllint`
1928
# Need at least `v1.17.0` for the `yaml-files` setting
2029
- pip install --user yamllint>=1.17.0
2130
- yamllint -s .
31+
# Install and run `rubocop`
32+
- gem install rubocop
33+
- rubocop -d
2234
# Install and run `commitlint`
2335
- npm install @commitlint/config-conventional -D
2436
- npm install @commitlint/travis-cli -D
2537
- commitlint-travis
26-
# Define the release stage that runs `semantic-release`
38+
39+
## Define the release stage that runs `semantic-release`
2740
- stage: release
2841
language: node_js
2942
node_js: lts/*
43+
env: Release
44+
name: 'Run semantic-release inc. file updates to AUTHORS, CHANGELOG & FORMULA'
3045
before_install: skip
3146
script:
3247
# Update `AUTHORS.md`

.yamllint

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ ignore: |
1515
test/**/states/**/*.sls
1616
.kitchen/
1717
ssf/files/default/.cirrus.yml
18+
ssf/files/default/.rubocop.yml
19+
ssf/files/default/.salt-lint
1820
ssf/files/default/.travis.yml
1921
ssf/files/default/.yamllint
2022
ssf/files/default/kitchen.yml
@@ -24,6 +26,7 @@ yaml-files:
2426
# Default settings
2527
- '*.yaml'
2628
- '*.yml'
29+
- .salt-lint
2730
- .yamllint
2831
# SaltStack Formulas additional settings
2932
- '*.example'

Gemfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
source "https://rubygems.org"
1+
# frozen_string_literal: true
2+
3+
source 'https://rubygems.org'
24

35
gem 'kitchen-docker', '>= 2.9'
4-
gem 'kitchen-salt', '>= 0.6.0'
56
gem 'kitchen-inspec', '>= 1.1'
6-
7+
gem 'kitchen-salt', '>= 0.6.0'

pillar.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ ssf:
127127
- inspec/README.md
128128
- .gitignore
129129
- .cirrus.yml
130+
- .rubocop.yml
131+
- .salt-lint
130132
- .travis.yml
131133
- .yamllint
132134
- commitlint.config.js

ssf/config/formulas.sls

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ prepare-git-branch-for-{{ formula }}:
109109
platforms: {{ context.platforms | yaml }}
110110
platforms_matrix: {{ context.platforms_matrix | yaml }}
111111
platforms_matrix_commented_includes: {{ context.platforms_matrix_commented_includes | yaml }}
112+
rubocop: {{ context.rubocop | yaml }}
113+
salt_lint: {{ context.salt_lint | yaml }}
112114
script_kitchen: {{ context.script_kitchen | yaml }}
113115
suite: {{ suite | yaml }}
114116
travis: {{ context.travis | yaml }}

ssf/defaults.yaml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
---
44
ssf_node_anchors:
55
defaults:
6+
common:
7+
lint:
8+
line_length:
9+
bugbear: &line_length_bugbear 88
10+
default: &line_length_default 80
611
formula: &formula_default
712
context: &context_default
813
git:
@@ -17,8 +22,8 @@ ssf_node_anchors:
1722
# An alternative method could be to use:
1823
# `git describe --abbrev=0 --tags`
1924
# yamllint disable rule:line-length
20-
title: 'feat(tofs): implementation for all file.managed'
21-
body: '* Checked using https://github.com/myii/ssf-formula/pull/54'
25+
title: 'ci: merge travis matrix, add `salt-lint` & `rubocop` to `lint` job'
26+
body: '* Automated using https://github.com/myii/ssf-formula/pull/60'
2227
# yamllint enable rule:line-length
2328
github:
2429
owner: saltstack-formulas
@@ -159,6 +164,14 @@ ssf_node_anchors:
159164
# To deal with excessive instances when mimicking `kitchen list -b`
160165
# If values are set, only use these as commented entries in the matrix
161166
platforms_matrix_commented_includes: []
167+
rubocop:
168+
AllCops: {}
169+
Cops:
170+
Metrics/LineLength:
171+
Bugbear: *line_length_bugbear
172+
Default: *line_length_default
173+
Max: *line_length_bugbear
174+
salt_lint: {}
162175
script_kitchen:
163176
bin: bin/kitchen
164177
cmd: verify
@@ -167,6 +180,7 @@ ssf_node_anchors:
167180
travis:
168181
addons: {}
169182
dist: bionic
183+
use_single_job_for_linters: true
170184
use_cirrus_ci: false
171185
use_tofs: false
172186
yamllint:
@@ -182,6 +196,7 @@ ssf_node_anchors:
182196
default:
183197
- '*.yaml'
184198
- '*.yml'
199+
- '.salt-lint'
185200
- '.yamllint'
186201
additional_ssf:
187202
- '*.example'
@@ -207,9 +222,9 @@ ssf_node_anchors:
207222
key-duplicates: {}
208223
# key-ordering: {}
209224
line-length:
210-
bugbear: 88
211-
default: 80
212-
max: 88
225+
bugbear: *line_length_bugbear
226+
default: *line_length_default
227+
max: *line_length_bugbear
213228
# new-line-at-end-of-file: {}
214229
# new-lines: {}
215230
octal-values:

ssf/files/default/.rubocop.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
# General overrides used across formulas in the org
5+
{%- set MLL = 'Metrics/LineLength' %}
6+
{{ MLL }}:
7+
{%- set rbcp_MLL = rubocop.Cops.get(MLL) %}
8+
{%- if rbcp_MLL.Max == rbcp_MLL.Bugbear %}
9+
# Increase from default of `{{ rbcp_MLL.Default }}`
10+
# Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`)
11+
{%- endif %}
12+
Max: {{ rbcp_MLL.Max }}
13+
14+
{%- if rubocop.AllCops %}
15+
16+
# General settings across all cops in this formula
17+
AllCops:
18+
{#- This is purposefully simplistic for the time being,
19+
until (if ever) more advanced configuration is necessary #}
20+
{%- if rubocop.AllCops.Exclude %}
21+
# Files to ignore completely
22+
Exclude:
23+
{%- for path in rubocop.AllCops.Exclude %}
24+
- {{ path }}
25+
{%- endfor %}
26+
{%- endif %}
27+
{%- endif %}
28+
29+
# Any offenses that should be fixed, e.g. collected via. `rubocop --auto-gen-config`
30+
{%- for cop, config in rubocop.Cops.items() if cop not in [MLL] %}
31+
{{ cop }}:
32+
{#- This is purposefully simplistic for the time being,
33+
until (if ever) more advanced configuration is necessary #}
34+
{%- for k, v in config.items() %}
35+
{{ k }}: {{ v }}
36+
{%- endfor %}
37+
{%- endfor %}

ssf/files/default/.salt-lint

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
exclude_paths: []
5+
skip_list:
6+
# Using `salt-lint` for linting other files as well, such as Jinja macros/templates
7+
- 205 # Use ".sls" as a Salt State file extension
8+
# Skipping `207` and `208` because `210` is sufficient, at least for the time-being
9+
# I.e. Allows 3-digit unquoted codes to still be used, such as `644` and `755`
10+
- 207 # File modes should always be encapsulated in quotation marks
11+
- 208 # File modes should always contain a leading zero
12+
tags: []
13+
verbosity: 1

0 commit comments

Comments
 (0)