From bf565812b1e66ca99e60a45426584c9b7a22ccdd 2024-09-09 22:09:27 From: Branko Majic Date: 2024-09-09 22:09:27 Subject: [PATCH] MAR-218: Reimplement linting supports in test runner scrupt: - Molecule no longer has command for running the linters, so a small wrapper around linters has to be implemented. --- diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index 0c1c3b5df6de1fdd0344f98a3038711f0ca9543f..867955d753129e7c39e5dcd78e3a7f372c14a02a 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -284,14 +284,31 @@ for role in "${roles_to_test[@]}"; do fi info "Running tests for: $role" + molecule_result=0 if [[ $tests == all ]]; then + molecule test --destroy always 2>&1 | tee "$report_file" + last_pipe_status="${PIPESTATUS[0]}" + [[ $last_pipe_status == 0 ]] || molecule_result="$last_pipe_status" + elif [[ $tests == lint ]]; then - molecule lint 2>&1 | tee "$report_file" + + flake8 . 2>&1 | tee "$report_file" + last_pipe_status="${PIPESTATUS[0]}" + [[ $last_pipe_status == 0 ]] || molecule_result="$last_pipe_status" + + yamllint . 2>&1 | tee "$report_file" + last_pipe_status="${PIPESTATUS[0]}" + [[ $last_pipe_status == 0 ]] || molecule_result="$last_pipe_status" + + ansible-lint --quiet . 2>&1 | tee "$report_file" + last_pipe_status="${PIPESTATUS[0]}" + [[ $last_pipe_status == 0 ]] || molecule_result="$last_pipe_status" + fi # Determine result. - if [[ "${PIPESTATUS[0]}" == 0 ]]; then + if [[ $molecule_result == 0 ]]; then passed_roles+=("$role") # Log failure in summary if requested.