Skip to content

Commit b50ef71

Browse files
committed
ci: merge travis matrix, add salt-lint & rubocop to lint job
* Automated using myii/ssf-formula#60
1 parent 62d20bc commit b50ef71

File tree

6 files changed

+82
-38
lines changed

6 files changed

+82
-38
lines changed

.rubocop.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
# Any offenses that should be fixed, e.g. collected via. `rubocop --auto-gen-config`
11+
Metrics/BlockLength:
12+
Max: 55

.salt-lint

+13
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

+40-26
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,70 @@
11
# -*- coding: utf-8 -*-
22
# vim: ft=yaml
33
---
4+
## Machine config
45
dist: bionic
5-
stages:
6-
- test
7-
- lint
8-
- name: release
9-
if: branch = master AND type != pull_request
10-
116
sudo: required
12-
cache: bundler
13-
language: ruby
14-
157
services:
168
- docker
179

18-
# Make sure the instances listed below match up with
19-
# the `platforms` defined in `kitchen.yml`
20-
env:
21-
matrix:
22-
- INSTANCE: repositories-debian-10-develop-py3
23-
# - INSTANCE: preferences-debian-10-develop-py3
24-
# - INSTANCE: repositories-ubuntu-1804-develop-py3
25-
# - INSTANCE: preferences-ubuntu-1804-develop-py3
26-
- INSTANCE: repositories-debian-9-2019-2-py3
27-
- INSTANCE: preferences-debian-9-2019-2-py3
28-
- INSTANCE: repositories-ubuntu-1804-2019-2-py3
29-
- INSTANCE: preferences-ubuntu-1804-2019-2-py3
10+
## Language and cache config
11+
language: ruby
12+
cache: bundler
3013

14+
## Script to run for the test stage
3115
script:
32-
- bin/kitchen verify ${INSTANCE}
16+
- bin/kitchen verify "${INSTANCE}"
3317

18+
## Stages and jobs matrix
19+
stages:
20+
- test
21+
- name: release
22+
if: branch = master AND type != pull_request
3423
jobs:
3524
include:
36-
# Define the `lint` stage (runs `yamllint` and `commitlint`)
37-
- stage: lint
38-
language: node_js
25+
## Define the test stage that runs the linters (and testing matrix, if applicable)
26+
27+
# Run all of the linters in a single job
28+
- language: node_js
3929
node_js: lts/*
30+
env: Lint
31+
name: 'Lint: salt-lint, yamllint, rubocop & commitlint'
4032
before_install: skip
4133
script:
34+
# Install and run `salt-lint`
35+
- pip install --user salt-lint
36+
- git ls-files | grep '\.sls$\|\.jinja$\|\.j2$\|\.tmpl$'
37+
| xargs -I {} salt-lint {}
4238
# Install and run `yamllint`
4339
# Need at least `v1.17.0` for the `yaml-files` setting
4440
- pip install --user yamllint>=1.17.0
4541
- yamllint -s .
42+
# Install and run `rubocop`
43+
- gem install rubocop
44+
- rubocop -d
4645
# Install and run `commitlint`
4746
- npm install @commitlint/config-conventional -D
4847
- npm install @commitlint/travis-cli -D
4948
- commitlint-travis
50-
# Define the release stage that runs `semantic-release`
49+
50+
## Define the rest of the matrix based on Kitchen testing
51+
# Make sure the instances listed below match up with
52+
# the `platforms` defined in `kitchen.yml`
53+
- env: INSTANCE=repositories-debian-10-develop-py3
54+
# - env: INSTANCE=preferences-debian-10-develop-py3
55+
# - env: INSTANCE=repositories-ubuntu-1804-develop-py3
56+
# - env: INSTANCE=preferences-ubuntu-1804-develop-py3
57+
- env: INSTANCE=repositories-debian-9-2019-2-py3
58+
- env: INSTANCE=preferences-debian-9-2019-2-py3
59+
- env: INSTANCE=repositories-ubuntu-1804-2019-2-py3
60+
- env: INSTANCE=preferences-ubuntu-1804-2019-2-py3
61+
62+
## Define the release stage that runs `semantic-release`
5163
- stage: release
5264
language: node_js
5365
node_js: lts/*
66+
env: Release
67+
name: 'Run semantic-release inc. file updates to AUTHORS, CHANGELOG & FORMULA'
5468
before_install: skip
5569
script:
5670
# Update `AUTHORS.md`

.yamllint

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ yaml-files:
1717
# Default settings
1818
- '*.yaml'
1919
- '*.yml'
20+
- .salt-lint
2021
- .yamllint
2122
# SaltStack Formulas additional settings
2223
- '*.example'

Gemfile

+4-3
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'

bin/kitchen

+12-9
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,25 @@
88
# this file is here to facilitate running it.
99
#
1010

11-
require "pathname"
12-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13-
Pathname.new(__FILE__).realpath)
11+
require 'pathname'
12+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
13+
Pathname.new(__FILE__).realpath)
1414

15-
bundle_binstub = File.expand_path("../bundle", __FILE__)
15+
bundle_binstub = File.expand_path('bundle', __dir__)
1616

1717
if File.file?(bundle_binstub)
1818
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
1919
load(bundle_binstub)
2020
else
21-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21+
abort(
22+
'Your `bin/bundle` was not generated by Bundler, '\
23+
'so this binstub cannot run. Replace `bin/bundle` by running '\
24+
'`bundle binstubs bundler --force`, then run this command again.'
25+
)
2326
end
2427
end
2528

26-
require "rubygems"
27-
require "bundler/setup"
29+
require 'rubygems'
30+
require 'bundler/setup'
2831

29-
load Gem.bin_path("test-kitchen", "kitchen")
32+
load Gem.bin_path('test-kitchen', 'kitchen')

0 commit comments

Comments
 (0)