Changeset - bf565812b1e6
[Not reviewed]
0 1 0
Branko Majic (branko) - 18 days ago 2024-09-09 22:09:27
branko@majic.rs
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.
1 file changed with 19 insertions and 2 deletions:
0 comments (0 inline, 0 general)
scripts/run_tests.sh
Show inline comments
 
@@ -275,32 +275,49 @@ for role in "${roles_to_test[@]}"; do
 
    role_dir="$work_dir/roles/$role"
 

	
 
    # Run tests.
 
    cd "$role_dir"
 

	
 
    if [[ $report == 1 ]]; then
 
        report_file="$report_directory/role-${role}.txt"
 
    else
 
        report_file="/dev/null"
 
    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.
 
        [[ $report == 1 ]] && echo "[PASS] $role" >> "$report_summary"
 
    else
 
        test_result=$ERROR_FAILED_ROLES
 
        failed_roles+=("$role")
 

	
 
        # Log failure in summary if requested.
 
        [[ $report == 1 ]] && echo "[FAIL] $role" >> "$report_summary"
 
    fi
 

	
0 comments (0 inline, 0 general)