Skip to content

Commit

Permalink
Hook ansible-lint and yamllint to .travis
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestas-poskus committed May 7, 2019
1 parent 931fcde commit 0db6657
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ script:
# Test role.
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml'

# Lint role.
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm bash /etc/ansible/roles/role_under_test/lint /etc/ansible/roles/role_under_test'

# View container logs
- 'sudo docker logs "$(cat ${container_id})"'

Expand Down
13 changes: 13 additions & 0 deletions lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
path=${1:-.}

python_path="$(python -m site --user-base)/bin"
echo "Python pip bin's path: $python_path"

pip install yamllint --user
pip install ansible-lint --user

yamllint_file="/tmp/yamllint.yaml"

curl https://raw.githubusercontent.com/ansible/galaxy/devel/galaxy/importer/linters/yamllint.yaml -o "$yamllint_file"
"$python_path/yamllint" -s -c "$yamllint_file" "$path" && "$python_path/ansible-lint" "$path"
21 changes: 21 additions & 0 deletions yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# Based on ansible-lint config
extends: default

rules:
braces: {max-spaces-inside: 1, level: error}
brackets: {max-spaces-inside: 1, level: error}
colons: {max-spaces-after: -1, level: error}
commas: {max-spaces-after: -1, level: error}
comments: disable
comments-indentation: disable
document-start: disable
empty-lines: {max: 3, level: error}
hyphens: {level: error}
indentation: disable
key-duplicates: enable
line-length: disable
new-line-at-end-of-file: disable
new-lines: {type: unix}
trailing-spaces: disable
truthy: disable

0 comments on commit 0db6657

Please sign in to comment.