Skip to content

Adds support for ansible-lint #1129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ docker/mysql_backup_mystamps.sql.gz

# maven-wrapper
.mvn/wrapper/maven-wrapper.jar

# @asm0dey uses molecule for role testing which generates .pyc files
# and also creates molecule directory
*.pyc
molecule/
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ before_script:
mkdir -p /tmp/uploads /tmp/preview;
cp src/main/resources/test/test.png /tmp/uploads/1.png;
npm install -g bootlint;
pip install --user html5validator;
pip install --user robotframework-lint;
pip install --user html5validator robotframework-lint;
if [ "$TRAVIS_BRANCH" = 'prod' -a "$TRAVIS_PULL_REQUEST" = 'false' ]; then
pip install --user ansible==2.1.1.0;
fi;
pip install --user ansible-lint;
if [ "$TRAVIS_PULL_REQUEST" != 'false' ]; then
gem install danger nokogiri --no-ri --no-rdoc;
fi;
Expand Down
8 changes: 4 additions & 4 deletions src/main/scripts/ci/ansible/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
monitorid: "{{ uptimerobot.monitorid }}"
apikey: "{{ uptimerobot.apikey }}"
state: paused
when: uptimerobot is defined and uptimerobot.monitorid != '' and uptimerobot.apikey != ''
when: uptimerobot is defined and uptimerobot.monitorid and uptimerobot.apikey

# we can't use service module here because our sudoers allows to execute only exact commands
- name: Stopping service
- name: Stopping service # noqa 301 ignoring this because we're always stopping service before deploy
raw:
sudo systemctl stop mystamps

Expand All @@ -48,7 +48,7 @@
backup: yes

# we can't use service module here because our sudoers allows to execute only exact commands
- name: Starting service
- name: Starting service # noqa 301 ignoring this because we're always starting service after deploy
raw:
sudo systemctl start mystamps

Expand All @@ -57,5 +57,5 @@
monitorid: "{{ uptimerobot.monitorid }}"
apikey: "{{ uptimerobot.apikey }}"
state: started
when: uptimerobot is defined and uptimerobot.monitorid != '' and uptimerobot.apikey != ''
when: uptimerobot is defined and uptimerobot.monitorid and uptimerobot.apikey

47 changes: 32 additions & 15 deletions src/main/scripts/ci/check-build-and-verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ TEST_STATUS=
CODENARC_STATUS=
SPOTBUGS_STATUS=
VERIFY_STATUS=
ANSIBLE_LINT_STATUS=

DANGER_STATUS=skip
if [ "${SPRING_PROFILES_ACTIVE:-}" = 'travis' ] && [ "${TRAVIS_PULL_REQUEST:-false}" != 'false' ]; then
Expand Down Expand Up @@ -66,6 +67,7 @@ if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
AFFECTS_GROOVY_FILES="$(echo "$MODIFIED_FILES" | grep -q '\.groovy$' || echo 'no')"
AFFECTS_PROPERTIES="$(echo "$MODIFIED_FILES" | grep -q '\.properties$' || echo 'no')"
AFFECTS_LICENSE_HEADER="$(echo "$MODIFIED_FILES" | grep -q 'license_header\.txt$' || echo 'no')"
AFFECTS_PLAYBOOKS="$(echo "$MODIFIED_FILES" | grep -Eq '(vagrant|deploy|bootstrap|/roles/.+)\.yml$' || echo 'no')"

if [ "$AFFECTS_POM_XML" = 'no' ]; then
POM_STATUS=skip
Expand Down Expand Up @@ -97,7 +99,12 @@ if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
fi
[ "$AFFECTS_ROBOT_FILES" != 'no' ] || RFLINT_STATUS=skip
[ "$AFFECTS_SHELL_FILES" != 'no' ] || SHELLCHECK_STATUS=skip

if [ "$AFFECTS_PLAYBOOKS" = 'no' ]; then
ANSIBLE_LINT_STATUS=skip
fi
fi

echo 'INFO: Some checks could be skipped'
else
echo "INFO: Couldn't determine list of modified files."
Expand Down Expand Up @@ -218,6 +225,15 @@ if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
>spotbugs.log 2>&1 || SPOTBUGS_STATUS=fail
fi
print_status "$SPOTBUGS_STATUS" 'Run SpotBugs'

if [ "$ANSIBLE_LINT_STATUS" != 'skip' ]; then
ansible-lint \
vagrant/provisioning/vagrant.yml \
vagrant/provisioning/bootstrap.yml \
src/main/scripts/ci/ansible/deploy.yml \
>ansible_lint.log 2>&1 || ANSIBLE_LINT_STATUS=fail
fi
print_status "$ANSIBLE_LINT_STATUS" 'Run Ansible Lint'
fi

mvn --batch-mode --activate-profiles frontend,native2ascii verify -Denforcer.skip=true -DskipUnitTests=true \
Expand All @@ -234,19 +250,20 @@ fi
print_status "$DANGER_STATUS" 'Run danger'

if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
[ "$CS_STATUS" = 'skip' ] || print_log cs.log 'Run CheckStyle'
[ "$PMD_STATUS" = 'skip' ] || print_log pmd.log 'Run PMD'
[ "$LICENSE_STATUS" = 'skip' ] || print_log license.log 'Check license headers'
[ "$POM_STATUS" = 'skip' ] || print_log pom.log 'Check sorting of pom.xml'
[ "$BOOTLINT_STATUS" = 'skip' ] || print_log bootlint.log 'Run bootlint'
[ "$RFLINT_STATUS" = 'skip' ] || print_log rflint.log 'Run robot framework lint'
[ "$SHELLCHECK_STATUS" = 'skip' ] || print_log shellcheck.log 'Run shellcheck'
[ "$JASMINE_STATUS" = 'skip' ] || print_log jasmine.log 'Run JavaScript unit tests'
[ "$HTML_STATUS" = 'skip' ] || print_log validator.log 'Run html5validator'
[ "$ENFORCER_STATUS" = 'skip' ] || print_log enforcer.log 'Run maven-enforcer-plugin'
[ "$TEST_STATUS" = 'skip' ] || print_log test.log 'Run unit tests'
[ "$CODENARC_STATUS" = 'skip' ] || print_log codenarc.log 'Run CodeNarc'
[ "$SPOTBUGS_STATUS" = 'skip' ] || print_log spotbugs.log 'Run SpotBugs'
[ "$CS_STATUS" = 'skip' ] || print_log cs.log 'Run CheckStyle'
[ "$PMD_STATUS" = 'skip' ] || print_log pmd.log 'Run PMD'
[ "$LICENSE_STATUS" = 'skip' ] || print_log license.log 'Check license headers'
[ "$POM_STATUS" = 'skip' ] || print_log pom.log 'Check sorting of pom.xml'
[ "$BOOTLINT_STATUS" = 'skip' ] || print_log bootlint.log 'Run bootlint'
[ "$RFLINT_STATUS" = 'skip' ] || print_log rflint.log 'Run robot framework lint'
[ "$SHELLCHECK_STATUS" = 'skip' ] || print_log shellcheck.log 'Run shellcheck'
[ "$JASMINE_STATUS" = 'skip' ] || print_log jasmine.log 'Run JavaScript unit tests'
[ "$HTML_STATUS" = 'skip' ] || print_log validator.log 'Run html5validator'
[ "$ENFORCER_STATUS" = 'skip' ] || print_log enforcer.log 'Run maven-enforcer-plugin'
[ "$TEST_STATUS" = 'skip' ] || print_log test.log 'Run unit tests'
[ "$CODENARC_STATUS" = 'skip' ] || print_log codenarc.log 'Run CodeNarc'
[ "$SPOTBUGS_STATUS" = 'skip' ] || print_log spotbugs.log 'Run SpotBugs'
[ "$ANSIBLE_LINT_STATUS" = 'skip' ] || print_log ansible_lint.log 'Run Ansible Lint'
fi

print_log verify.log 'Run integration tests'
Expand All @@ -255,8 +272,8 @@ if [ "$DANGER_STATUS" != 'skip' ]; then
print_log danger.log 'Run danger'
fi

rm -f cs.log pmd.log license.log pom.log bootlint.log rflint.log shellcheck.log jasmine.log validator.log enforcer.log test.log codenarc.log spotbugs.log verify-raw.log verify.log danger.log
rm -f cs.log pmd.log license.log pom.log bootlint.log rflint.log shellcheck.log jasmine.log validator.log enforcer.log test.log codenarc.log spotbugs.log verify-raw.log verify.log danger.log ansible_lint.log

if echo "$CS_STATUS$PMD_STATUS$LICENSE_STATUS$POM_STATUS$BOOTLINT_STATUS$RFLINT_STATUS$SHELLCHECK_STATUS$JASMINE_STATUS$HTML_STATUS$ENFORCER_STATUS$TEST_STATUS$CODENARC_STATUS$SPOTBUGS_STATUS$VERIFY_STATUS$DANGER_STATUS" | grep -Fqs 'fail'; then
if echo "$CS_STATUS$PMD_STATUS$LICENSE_STATUS$POM_STATUS$BOOTLINT_STATUS$RFLINT_STATUS$SHELLCHECK_STATUS$JASMINE_STATUS$HTML_STATUS$ENFORCER_STATUS$TEST_STATUS$CODENARC_STATUS$SPOTBUGS_STATUS$VERIFY_STATUS$DANGER_STATUS$ANSIBLE_LINT_STATUS" | grep -Fqs 'fail'; then
exit 1
fi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# @todo #399 mystamps-app: use systemd module
# (requires ansible 2.2+)
- name: Reloading systemd service
- name: Reloading systemd service # noqa 303
command:
systemctl daemon-reload

Expand Down