Skip to content

Commit

Permalink
ci: migrate checking by ansible-lint from TravisCI to GitHub Actions
Browse files Browse the repository at this point in the history
Part of #1154
  • Loading branch information
php-coder committed Dec 3, 2022
1 parent ed24277 commit 10eada3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 28 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,20 @@ jobs:
run: pip3 install --user html5validator==0.4.2
- name: Run html5validator
run: ./src/main/scripts/execute-command.sh html5validator
run-ansible-lint:
name: Run ansible-lint
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on
runs-on: ubuntu-20.04
steps:
- name: Clone source code
uses: actions/[email protected] # https://github.com/actions/checkout
with:
# Whether to configure the token or SSH key with the local git config. Default: true
persist-credentials: false
- name: Install ansible-lint
run: pip3 install --user ansible-lint==4.2.0
- name: Run ansible-lint
run: ./src/main/scripts/execute-command.sh ansible-lint
run-enforcer:
name: Run maven-enforcer-plugin
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on
Expand Down
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ before_script:
sudo apt-get -qq update;
sudo apt-get install -y python3.6 python3-pip;
curl https://bootstrap.pypa.io/pip/3.6/get-pip.py | sudo -H python3.6;
pip3 install --user \
ansible==2.9.2 \
ansible-lint==4.2.0;
pip3 install --user ansible==2.9.2;
if [ "$TRAVIS_PULL_REQUEST" != 'false' ]; then
gem install danger:8.2.2 nokogiri:1.10.10 --no-document;
fi;
Expand Down
2 changes: 1 addition & 1 deletion docs/external-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
| JDK | OracleJDK 8u151 | Adopt OpenJDK 8u292 | OpenJDK 8u121-jre on Debian 8.11 (Jessy) |
| MySQL | 5.7.27 | | 5.7.20 on Debian 8.11 (Jessy) |
| PostgreSQL | | | 11.3 on Debian 9.13 (Stretch) |
| Python | 2.7.12, 3.5.2 | | |
| Python | 2.7.12, 3.5.2 | 3.8.10 | |
| bash | 4.3.14 | | |
| duplicity | 0.7.06 | | |
| maven | | 3.8.6 | |
Expand Down
26 changes: 2 additions & 24 deletions src/main/scripts/ci/check-build-and-verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,13 @@ if [ "${1:-}" = '--only-integration-tests' ]; then
fi

VERIFY_STATUS=
ANSIBLE_LINT_STATUS=

DANGER_STATUS=skip
if [ "${SPRING_PROFILES_ACTIVE:-}" = 'travis' ] && [ "${TRAVIS_PULL_REQUEST:-false}" != 'false' ]; then
DANGER_STATUS=
fi

VERIFY_TIME=0
ANSIBLE_LINT_TIME=0
DANGER_TIME=0

CURDIR="$(dirname "$0")"
Expand All @@ -88,15 +86,6 @@ if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
MODIFIED_FILES="$(git --no-pager diff --name-only "$TRAVIS_COMMIT_RANGE" -- 2>/dev/null || :)"

if [ -n "$MODIFIED_FILES" ]; then
AFFECTS_TRAVIS_CFG="$(echo "$MODIFIED_FILES" | grep -Fxq '.travis.yml' || echo 'no')"
AFFECTS_PLAYBOOKS="$(echo "$MODIFIED_FILES" | grep -Eq '(vagrant|prod|deploy|bootstrap|/roles/.+)\.yml$' || echo 'no')"

if [ "$AFFECTS_TRAVIS_CFG" = 'no' ]; then
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 All @@ -108,13 +97,6 @@ if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
fi

echo

if [ "$ANSIBLE_LINT_STATUS" != 'skip' ]; then
START_TIME=$SECONDS
"$EXEC_CMD" ansible-lint >ansible_lint.log 2>&1 || ANSIBLE_LINT_STATUS=fail
ANSIBLE_LINT_TIME=$((SECONDS - START_TIME))
fi
print_status "$ANSIBLE_LINT_STATUS" $ANSIBLE_LINT_TIME 'Run Ansible Lint'
fi

START_TIME=$SECONDS
Expand All @@ -131,18 +113,14 @@ if [ "$DANGER_STATUS" != 'skip' ]; then
fi
print_status "$DANGER_STATUS" "$DANGER_TIME" 'Run danger'

if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
[ "$ANSIBLE_LINT_STATUS" = 'skip' ] || print_log ansible_lint.log 'Run Ansible Lint'
fi

print_log verify.log 'Run integration tests'

if [ "$DANGER_STATUS" != 'skip' ]; then
print_log danger.log 'Run danger'
fi

rm -f verify.log danger.log ansible_lint.log
rm -f verify.log danger.log

if echo "$VERIFY_STATUS$DANGER_STATUS$ANSIBLE_LINT_STATUS" | grep -Fqs 'fail'; then
if echo "$VERIFY_STATUS$DANGER_STATUS" | grep -Fqs 'fail'; then
exit 1
fi

0 comments on commit 10eada3

Please sign in to comment.