Skip to content

Commit

Permalink
Switch to molecule for tests
Browse files Browse the repository at this point in the history
- fixed lint errors
- drop support for Ansible 2.2
  • Loading branch information
bdellegrazie committed Dec 25, 2018
1 parent 3648a56 commit 864d243
Show file tree
Hide file tree
Showing 33 changed files with 1,105 additions and 195 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.bundle
docker
.dockerignore
Gemfile*
.git*
.pre-commit-config.yaml
*.md
.travis.yml
.kitchen*
Rakefile
test*
vendor
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ build
.project
.pydevproject
.settings/
.venv/

# Mac OS X stuff...
.DS_Store
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
system
8 changes: 8 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Convenience for Inspec tests

Metrics/BlockLength:
Enabled: false

Metrics/LineLength:
Enabled: false
56 changes: 16 additions & 40 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,36 @@
---
dist: trusty
sudo: required
env:
matrix:
- distro: centos7
- distro: centos6
- distro: fedora27
- distro: ubuntu1804
- distro: ubuntu1604
- distro: debian9
- distro: debian8

language: ruby
bundler_args: --without=development --binstubs=vendor/bin

language: python
services:
- docker

cache:
bundler: true
directories:
- $HOME/.cache/pip
- $HOME/.gilt/clone
- $HOME/.inspec/cache

before_cache:
- rm -f $HOME/.cache/pip/log/debug.log

services:
- docker

before_install:
- sudo apt-get update
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce

environment:
PIPENV_VENV_IN_PROJECT=1

install:
- pip install pipenv
- pipenv sync --dev
- bundle install --without=development --binstubs=vendor/bin

script:
# Configure test script so we can run extra tests after playbook is run.
- export container_id=$(date +%s)
- export cleanup=false

# Download test shim.
- wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/
- chmod +x ${PWD}/tests/test.sh

# Run tests.
- ${PWD}/tests/test.sh
- ${PWD}/vendor/bin/inspec exec tests/profile -t docker://${container_id} --color --reporter=cli

# Cleanup
- docker rm -f ${container_id}

stages:
- lint
- test

jobs:
include:
- stage: lint
before_install: pip install --user pre-commit
install: pre-commit install
script: pre-commit run --all-files
# Run tests
- pipenv run molecule test --all

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
19 changes: 19 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
extends: default
ignore: |
.pre-commit-config.yaml
.travis.yml
vendor/

rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
comments:
require-starting-space: false
line-length: disable
# NOTE(retr0h): Templates no longer fail this lint rule.
# Uncomment if running old Molecule templates.
# truthy: disable
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ source "https://rubygems.org"

group :test do
gem 'inspec'
gem 'rubocop'
gem 'travis'
end
77 changes: 64 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ GEM
specs:
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
aws-sdk (2.11.190)
aws-sdk-resources (= 2.11.190)
aws-sdk-core (2.11.190)
ast (2.4.0)
aws-sdk (2.11.197)
aws-sdk-resources (= 2.11.197)
aws-sdk-core (2.11.197)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-resources (2.11.190)
aws-sdk-core (= 2.11.190)
aws-sdk-resources (2.11.197)
aws-sdk-core (= 2.11.197)
aws-sigv4 (1.0.3)
azure_graph_rbac (0.17.0)
ms_rest_azure (~> 0.11.0)
Expand All @@ -20,7 +21,7 @@ GEM
backports (3.11.4)
builder (3.2.3)
coderay (1.1.2)
concurrent-ruby (1.1.3)
concurrent-ruby (1.1.4)
connection_pool (2.2.2)
declarative (0.0.10)
declarative-option (0.1.0)
Expand All @@ -30,6 +31,7 @@ GEM
multi_json
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
equatable (0.5.0)
erubis (2.7.0)
ethon (0.11.0)
ffi (>= 1.3.0)
Expand Down Expand Up @@ -75,7 +77,7 @@ GEM
domain_name (~> 0.5)
httpclient (2.8.3)
inifile (3.0.0)
inspec (3.0.64)
inspec (3.2.6)
addressable (~> 2.4)
faraday (>= 0.9.0)
faraday_middleware (~> 0.12.2)
Expand All @@ -96,7 +98,10 @@ GEM
term-ansicolor
thor (~> 0.20)
tomlrb (~> 1.2)
train (~> 1.5, >= 1.5.6)
train (~> 1.5, >= 1.6.3)
tty-prompt (~> 0.17)
tty-table (~> 0.10)
jaro_winkler (1.5.1)
jmespath (1.4.0)
json (2.1.0)
jwt (2.1.0)
Expand All @@ -111,7 +116,7 @@ GEM
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mixlib-log (2.0.4)
mixlib-log (2.0.9)
mixlib-shellout (2.4.4)
ms_rest (0.7.3)
concurrent-ruby (~> 1.0)
Expand All @@ -124,6 +129,7 @@ GEM
ms_rest (~> 0.7.2)
multi_json (1.13.1)
multipart-post (2.0.0)
necromancer (0.4.0)
net-http-persistent (3.0.0)
connection_pool (~> 2.2)
net-http-pipeline (1.0.1)
Expand All @@ -133,14 +139,21 @@ GEM
nori (2.6.0)
os (1.0.0)
parallel (1.12.1)
parser (2.5.3.0)
ast (~> 2.4.0)
parslet (1.8.2)
pastel (0.7.2)
equatable (~> 0.5.0)
tty-color (~> 0.4.0)
powerpack (0.1.2)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (3.0.3)
pusher-client (0.6.2)
json
websocket (~> 1.0)
rainbow (3.0.0)
representable (3.0.4)
declarative (< 0.1.0)
declarative-option (< 0.2.0)
Expand All @@ -162,6 +175,15 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rubocop (0.61.1)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.4.0)
ruby-progressbar (1.10.0)
rubyntlm (0.6.2)
rubyzip (1.2.2)
semverse (3.0.0)
Expand All @@ -171,13 +193,19 @@ GEM
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
sslshake (1.2.0)
strings (0.1.4)
strings-ansi (~> 0.1.0)
unicode-display_width (~> 1.4.0)
unicode_utils (~> 1.4.0)
strings-ansi (0.1.0)
term-ansicolor (1.7.0)
tins (~> 1.0)
thor (0.20.3)
timeliness (0.3.8)
timers (4.2.0)
tins (1.20.2)
tomlrb (1.2.7)
train (1.5.11)
tomlrb (1.2.8)
train (1.6.3)
aws-sdk (~> 2)
azure_graph_rbac (~> 0.16)
azure_mgmt_key_vault (~> 0.17)
Expand All @@ -201,14 +229,35 @@ GEM
launchy (~> 2.1)
pusher-client (~> 0.4)
typhoeus (~> 0.6, >= 0.6.8)
tty-color (0.4.3)
tty-cursor (0.6.0)
tty-prompt (0.18.0)
necromancer (~> 0.4.0)
pastel (~> 0.7.0)
timers (~> 4.0)
tty-cursor (~> 0.6.0)
tty-reader (~> 0.5.0)
tty-reader (0.5.0)
tty-cursor (~> 0.6.0)
tty-screen (~> 0.6.4)
wisper (~> 2.0.0)
tty-screen (0.6.5)
tty-table (0.10.0)
equatable (~> 0.5.0)
necromancer (~> 0.4.0)
pastel (~> 0.7.2)
strings (~> 0.1.0)
tty-screen (~> 0.6.4)
typhoeus (0.8.0)
ethon (>= 0.8.0)
uber (0.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
unicode-display_width (1.4.1)
unicode_utils (1.4.0)
websocket (1.2.8)
winrm (2.3.0)
winrm (2.3.1)
builder (>= 2.1.2)
erubis (~> 2.7)
gssapi (~> 1.2)
Expand All @@ -217,17 +266,19 @@ GEM
logging (>= 1.6.1, < 3.0)
nori (~> 2.0)
rubyntlm (~> 0.6.0, >= 0.6.1)
winrm-fs (1.3.1)
winrm-fs (1.3.2)
erubis (~> 2.7)
logging (>= 1.6.1, < 3.0)
rubyzip (~> 1.1)
winrm (~> 2.0)
wisper (2.0.0)

PLATFORMS
ruby

DEPENDENCIES
inspec
rubocop
travis

BUNDLED WITH
Expand Down
17 changes: 17 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
molecule = "*"
ansible = "*"
pre-commit = "*"
yamllint = "*"
docker = "*"
python-gilt = "*"

[packages]

[requires]
python_version = "2.7"
Loading

0 comments on commit 864d243

Please sign in to comment.