Skip to content

Commit ca1bef7

Browse files
authored
Merge pull request #58 from myii/ci/merge-matrix-and-add-salt-lint-and-rubocop
ci: merge travis matrix, add `salt-lint` & `rubocop` to `lint` job
2 parents a21ead0 + b50ef71 commit ca1bef7

File tree

8 files changed

+121
-49
lines changed

8 files changed

+121
-49
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')

test/integration/preferences/controls/preferences_spec.rb

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
control 'Apt preferences' do
24
title 'should be configured'
35

@@ -18,30 +20,46 @@
1820
it { should be_owned_by 'root' }
1921
it { should be_grouped_into 'root' }
2022
its('mode') { should cmp '0644' }
21-
its(:content) { should match("Package: rspamd\nPin: origin rspamd.com\nPin-Priority: 650\n") }
23+
its(:content) do
24+
should match(
25+
"Package: rspamd\nPin: origin rspamd.com\nPin-Priority: 650\n"
26+
)
27+
end
2228
end
2329

2430
describe file('/etc/apt/preferences.d/01-all') do
2531
it { should exist }
2632
it { should be_owned_by 'root' }
2733
it { should be_grouped_into 'root' }
2834
its('mode') { should cmp '0644' }
29-
its(:content) { should match("Package: *\nPin: release stable\nPin-Priority: 610\n") }
35+
its(:content) do
36+
should match(
37+
"Package: *\nPin: release stable\nPin-Priority: 610\n"
38+
)
39+
end
3040
end
3141

3242
describe file('/etc/apt/preferences.d/02-all') do
3343
it { should exist }
3444
it { should be_owned_by 'root' }
3545
it { should be_grouped_into 'root' }
3646
its('mode') { should cmp '0644' }
37-
its(:content) { should match("Package: *\nPin: release testing\nPin-Priority: 600\n") }
47+
its(:content) do
48+
should match(
49+
"Package: *\nPin: release testing\nPin-Priority: 600\n"
50+
)
51+
end
3852
end
3953

4054
describe file('/etc/apt/preferences.d/03-all') do
4155
it { should exist }
4256
it { should be_owned_by 'root' }
4357
it { should be_grouped_into 'root' }
4458
its('mode') { should cmp '0644' }
45-
its(:content) { should match("Package: *\nPin: release unstable\nPin-Priority: 50\n") }
59+
its(:content) do
60+
should match(
61+
"Package: *\nPin: release unstable\nPin-Priority: 50\n"
62+
)
63+
end
4664
end
4765
end

test/integration/repositories/controls/repositories_spec.rb

+17-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
# frozen_string_literal: true
2+
13
control 'Apt repositories' do
24
title 'should be configured'
35

4-
if os[:name] == 'ubuntu'
5-
keyring_package = 'ubuntu-keyring'
6-
else
7-
keyring_package = 'debian-archive-keyring'
8-
end
6+
keyring_package = if os[:name] == 'ubuntu'
7+
'ubuntu-keyring'
8+
else
9+
'debian-archive-keyring'
10+
end
911

1012
describe package(keyring_package) do
1113
it { should be_installed }
@@ -28,14 +30,22 @@
2830
it { should be_owned_by 'root' }
2931
it { should be_grouped_into 'root' }
3032
its('mode') { should cmp '0644' }
31-
its(:content) { should match(%r{deb \[arch=amd64\] http://repository.spotify.com stable non-free}) }
33+
its(:content) do
34+
should match(
35+
%r{deb \[arch=amd64\] http://repository.spotify.com stable non-free}
36+
)
37+
end
3238
end
3339

3440
describe file('/etc/apt/sources.list.d/heroku-binary.list') do
3541
it { should exist }
3642
it { should be_owned_by 'root' }
3743
it { should be_grouped_into 'root' }
3844
its('mode') { should cmp '0644' }
39-
its(:content) { should match(%r{deb \[arch=amd64\] https://cli-assets.heroku.com/apt ./}) }
45+
its(:content) do
46+
should match(
47+
%r{deb \[arch=amd64\] https://cli-assets.heroku.com/apt ./}
48+
)
49+
end
4050
end
4151
end

0 commit comments

Comments
 (0)