Skip to content

Commit dbee3f7

Browse files
committed
feat(travis): update for new structure of merging the lint stage
1 parent ac9b7a5 commit dbee3f7

File tree

2 files changed

+59
-43
lines changed

2 files changed

+59
-43
lines changed

ssf/files/default/.travis.yml

Lines changed: 52 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,10 @@
22
# vim: ft=yaml
33
---
44
{%- from tplroot ~ "/libcimatrix.jinja" import format_ci_matrix with context %}
5+
## Machine config
56
dist: {{ travis.dist }}
6-
stages:
7-
{%- if platforms and not use_cirrus_ci %}
8-
- test
9-
{%- endif %}
10-
- lint
11-
- name: release
12-
if: branch = master AND type != pull_request
137
{%- if platforms and not use_cirrus_ci %}
14-
158
sudo: required
16-
cache: bundler
17-
language: ruby
18-
199
services:
2010
- docker
2111
{%- set travis_addons = travis.addons %}
@@ -29,59 +19,80 @@ addons:
2919
# yamllint enable rule:indentation
3020
{%- endif %}
3121

32-
# Make sure the instances listed below match up with
33-
# the `platforms` defined in `kitchen.yml`
34-
{%- if semrel_formula == 'template' %}
35-
# NOTE: Please try to select up to six instances that add some meaningful
36-
# testing of the formula's behaviour. If possible, try to refrain from
37-
# the classical "chosing all the instances because I want to test on
38-
# another/all distro/s" trap: it will just add time to the testing (see
39-
# the discussion on #121). As an example, the set chosen below covers
40-
# the most used distros families, systemd and non-systemd and the latest
41-
# three supported Saltstack versions with python2 and 3.
42-
# As for `kitchen.yml`, that should still contain all of the platforms,
43-
# to allow for comprehensive local testing
44-
# Ref: https://github.com/saltstack-formulas/template-formula/issues/118
45-
# Ref: https://github.com/saltstack-formulas/template-formula/issues/121
46-
{%- endif %}
47-
env:
48-
matrix:
49-
{%- if semrel_formula == 'salt' %}
50-
# The ordering used below has been selected based on the time required in Travis
51-
# The slower ones are kept as high up as possible, to run concurrently rather than
52-
# slow down the entire run at the end (i.e. `centos-6` and `opensuse`)
53-
# However, the groupings needed to be maintained in some semblance of order
54-
# so this is a best-effort matrix, in the circumstances
55-
{%- endif %}
56-
{{- format_ci_matrix(platforms, inspec_suites_kitchen, inspec_suites_matrix, platforms_matrix, platforms_matrix_commented_includes, semrel_formula) }}
22+
## Language and cache config
23+
language: ruby
24+
cache: bundler
5725

26+
## Script to run for the test stage
5827
script:
5928
{%- for pre_cmd in script_kitchen.pre %}
6029
- {{ pre_cmd }}
6130
{%- endfor %}
62-
- {{ script_kitchen.bin }} {{ script_kitchen.cmd }} ${INSTANCE}
31+
- {{ script_kitchen.bin }} {{ script_kitchen.cmd }} "${INSTANCE}"
6332
{%- for post_cmd in script_kitchen.post %}
6433
- {{ post_cmd }}
6534
{%- endfor %}
6635
{%- endif %}
6736

37+
## Stages and jobs matrix
38+
stages:
39+
- test
40+
- name: release
41+
if: branch = master AND type != pull_request
6842
jobs:
6943
include:
70-
# Define the `lint` stage (runs `yamllint` and `commitlint`)
71-
- stage: lint
72-
language: node_js
44+
## Define the test stage that runs the linters (and testing matrix, if applicable)
45+
46+
# Run all of the linters in a single job
47+
- language: node_js
7348
node_js: lts/*
49+
env: 'Lint: salt-lint, yamllint, rubocop & commitlint'
7450
before_install: skip
7551
script:
52+
# Install and run `salt-lint`
53+
- pip install --user salt-lint
54+
- git ls-files | grep '\.sls$\|\.jinja$\|\.j2$\|\.tmpl$'
55+
| xargs -I {} salt-lint {}
7656
# Install and run `yamllint`
7757
# Need at least `v1.17.0` for the `yaml-files` setting
7858
- pip install --user yamllint>=1.17.0
7959
- yamllint -s .
60+
# Install and run `rubocop`
61+
- gem install rubocop
62+
- rubocop -d
8063
# Install and run `commitlint`
8164
- npm install @commitlint/config-conventional -D
8265
- npm install @commitlint/travis-cli -D
8366
- commitlint-travis
84-
# Define the release stage that runs `semantic-release`
67+
68+
{%- if platforms and not use_cirrus_ci %}
69+
70+
## Define the rest of the matrix based on Kitchen testing
71+
# Make sure the instances listed below match up with
72+
# the `platforms` defined in `kitchen.yml`
73+
{%- if semrel_formula == 'template' %}
74+
# NOTE: Please try to select up to six instances that add some meaningful
75+
# testing of the formula's behaviour. If possible, try to refrain from
76+
# the classical "chosing all the instances because I want to test on
77+
# another/all distro/s" trap: it will just add time to the testing (see
78+
# the discussion on #121). As an example, the set chosen below covers
79+
# the most used distros families, systemd and non-systemd and the latest
80+
# three supported Saltstack versions with python2 and 3.
81+
# As for `kitchen.yml`, that should still contain all of the platforms,
82+
# to allow for comprehensive local testing
83+
# Ref: https://github.com/saltstack-formulas/template-formula/issues/118
84+
# Ref: https://github.com/saltstack-formulas/template-formula/issues/121
85+
{%- elif semrel_formula == 'salt' %}
86+
# The ordering used below has been selected based on the time required in Travis
87+
# The slower ones are kept as high up as possible, to run concurrently rather than
88+
# slow down the entire run at the end (i.e. `centos-6` and `opensuse`)
89+
# However, the groupings needed to be maintained in some semblance of order
90+
# so this is a best-effort matrix, in the circumstances
91+
{%- endif %}
92+
{{- format_ci_matrix(platforms, inspec_suites_kitchen, inspec_suites_matrix, platforms_matrix, platforms_matrix_commented_includes, semrel_formula, use_new_travis_format=True) }}
93+
{%- endif %}
94+
95+
## Define the release stage that runs `semantic-release`
8596
- stage: release
8697
language: node_js
8798
node_js: lts/*

ssf/libcimatrix.jinja

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# vim: ft=jinja
33

4-
{%- macro format_ci_matrix(platforms, inspec_suites_kitchen, inspec_suites_matrix, platforms_matrix, platforms_matrix_commented_includes, semrel_formula, width=4) %}
4+
{%- macro format_ci_matrix(platforms, inspec_suites_kitchen, inspec_suites_matrix, platforms_matrix, platforms_matrix_commented_includes, semrel_formula, width=4, use_new_travis_format=False ) %}
55
{%- filter indent(width) %}
66
{#- Centralise duplication from here and `kitchen.yml` #}
77
{%- set platform_and_suite_names_done = [] %}
@@ -48,6 +48,11 @@
4848
{%- set include_instance = False %}
4949
{%- endif %}
5050
{%- endif %}
51+
{#- Define `instance_and_env`, modified for new Travis format #}
52+
{%- set instance_and_env = 'INSTANCE: ' %}
53+
{%- if use_new_travis_format %}
54+
{%- set instance_and_env = 'env: INSTANCE=' %}
55+
{%- endif %}
5156
{%- if include_instance %}
5257
{#- Only add a prefix if suite_name is given #}
5358
{%- set prefix = '' %}
@@ -62,7 +67,7 @@
6267
salt_ver | replace('.', '-'),
6368
py_ver,
6469
) %}
65-
{{ comment }}- INSTANCE: {{ instance }}
70+
{{ comment }}- {{instance_and_env }}{{ instance }}
6671
{%- endif %}
6772
{%- endif %}
6873
{%- endif %}

0 commit comments

Comments
 (0)