diff --git a/ssf/files/default/.travis.yml b/ssf/files/default/.travis.yml index 0a327e51..83deaebc 100644 --- a/ssf/files/default/.travis.yml +++ b/ssf/files/default/.travis.yml @@ -2,20 +2,10 @@ # vim: ft=yaml --- {%- from tplroot ~ "/libcimatrix.jinja" import format_ci_matrix with context %} +## Machine config dist: {{ travis.dist }} -stages: - {%- if platforms and not use_cirrus_ci %} - - test - {%- endif %} - - lint - - name: release - if: branch = master AND type != pull_request {%- if platforms and not use_cirrus_ci %} - sudo: required -cache: bundler -language: ruby - services: - docker {%- set travis_addons = travis.addons %} @@ -29,59 +19,80 @@ addons: # yamllint enable rule:indentation {%- endif %} -# Make sure the instances listed below match up with -# the `platforms` defined in `kitchen.yml` -{%- if semrel_formula == 'template' %} -# NOTE: Please try to select up to six instances that add some meaningful -# testing of the formula's behaviour. If possible, try to refrain from -# the classical "chosing all the instances because I want to test on -# another/all distro/s" trap: it will just add time to the testing (see -# the discussion on #121). As an example, the set chosen below covers -# the most used distros families, systemd and non-systemd and the latest -# three supported Saltstack versions with python2 and 3. -# As for `kitchen.yml`, that should still contain all of the platforms, -# to allow for comprehensive local testing -# Ref: https://github.com/saltstack-formulas/template-formula/issues/118 -# Ref: https://github.com/saltstack-formulas/template-formula/issues/121 -{%- endif %} -env: - matrix: - {%- if semrel_formula == 'salt' %} - # The ordering used below has been selected based on the time required in Travis - # The slower ones are kept as high up as possible, to run concurrently rather than - # slow down the entire run at the end (i.e. `centos-6` and `opensuse`) - # However, the groupings needed to be maintained in some semblance of order - # so this is a best-effort matrix, in the circumstances - {%- endif %} - {{- format_ci_matrix(platforms, inspec_suites_kitchen, inspec_suites_matrix, platforms_matrix, platforms_matrix_commented_includes, semrel_formula) }} +## Language and cache config +language: ruby +cache: bundler +## Script to run for the test stage script: {%- for pre_cmd in script_kitchen.pre %} - {{ pre_cmd }} {%- endfor %} - - {{ script_kitchen.bin }} {{ script_kitchen.cmd }} ${INSTANCE} + - {{ script_kitchen.bin }} {{ script_kitchen.cmd }} "${INSTANCE}" {%- for post_cmd in script_kitchen.post %} - {{ post_cmd }} {%- endfor %} {%- endif %} +## Stages and jobs matrix +stages: + - 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: 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` + + {%- if platforms and not use_cirrus_ci %} + + ## Define the rest of the matrix based on Kitchen testing + # Make sure the instances listed below match up with + # the `platforms` defined in `kitchen.yml` + {%- if semrel_formula == 'template' %} + # NOTE: Please try to select up to six instances that add some meaningful + # testing of the formula's behaviour. If possible, try to refrain from + # the classical "chosing all the instances because I want to test on + # another/all distro/s" trap: it will just add time to the testing (see + # the discussion on #121). As an example, the set chosen below covers + # the most used distros families, systemd and non-systemd and the latest + # three supported Saltstack versions with python2 and 3. + # As for `kitchen.yml`, that should still contain all of the platforms, + # to allow for comprehensive local testing + # Ref: https://github.com/saltstack-formulas/template-formula/issues/118 + # Ref: https://github.com/saltstack-formulas/template-formula/issues/121 + {%- elif semrel_formula == 'salt' %} + # The ordering used below has been selected based on the time required in Travis + # The slower ones are kept as high up as possible, to run concurrently rather than + # slow down the entire run at the end (i.e. `centos-6` and `opensuse`) + # However, the groupings needed to be maintained in some semblance of order + # so this is a best-effort matrix, in the circumstances + {%- endif %} + {{- format_ci_matrix(platforms, inspec_suites_kitchen, inspec_suites_matrix, platforms_matrix, platforms_matrix_commented_includes, semrel_formula, use_new_travis_format=True) }} + {%- endif %} + + ## Define the release stage that runs `semantic-release` - stage: release language: node_js node_js: lts/* diff --git a/ssf/libcimatrix.jinja b/ssf/libcimatrix.jinja index 7ef96130..50c4fef2 100644 --- a/ssf/libcimatrix.jinja +++ b/ssf/libcimatrix.jinja @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # vim: ft=jinja -{%- macro format_ci_matrix(platforms, inspec_suites_kitchen, inspec_suites_matrix, platforms_matrix, platforms_matrix_commented_includes, semrel_formula, width=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 ) %} {%- filter indent(width) %} {#- Centralise duplication from here and `kitchen.yml` #} {%- set platform_and_suite_names_done = [] %} @@ -48,6 +48,11 @@ {%- set include_instance = False %} {%- endif %} {%- endif %} +{#- Define `instance_and_env`, modified for new Travis format #} +{%- set instance_and_env = 'INSTANCE: ' %} +{%- if use_new_travis_format %} +{%- set instance_and_env = 'env: INSTANCE=' %} +{%- endif %} {%- if include_instance %} {#- Only add a prefix if suite_name is given #} {%- set prefix = '' %} @@ -62,7 +67,7 @@ salt_ver | replace('.', '-'), py_ver, ) %} -{{ comment }}- INSTANCE: {{ instance }} +{{ comment }}- {{instance_and_env }}{{ instance }} {%- endif %} {%- endif %} {%- endif %}