Skip to content
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

fix(workflow) fix search prev tag script #1874

Merged
merged 1 commit into from
Feb 1, 2024
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
134 changes: 77 additions & 57 deletions .github/workflows/scripts/prev_tag-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,77 +91,97 @@ test_fail_count=0

# Function to run a single test case
run_test() {
input_tag=$1
expected_output=$2

output=$(bash ../prev_tag.sh $input_tag)
if [[ $output == *"$expected_output"* ]]; then
passed_tests_results+="Test passed for input $input_tag: Expected and got $expected_output\n"
((test_passed_count++))
else
fail_test_results+="Test failed for input $input_tag: Expected $expected_output, got $output\n"
((test_fail_count++))
fi
local input_tag=$1
local expected_output=$2
local expected_type=$3

# Run the prev_tag.sh script and capture its output
local script_output=$(bash ../prev_tag.sh "$input_tag")
# Check if the script output indicates an invalid tag format
if [[ "$script_output" == "Release tag is invalid" ]]; then
if [[ "$expected_output" == "Release tag is invalid" ]]; then
passed_tests_results+="Test passed for input $input_tag: Expected Type: $expected_type, Prev Tag: $expected_output. Got Type: $script_output, Prev Tag: $script_output\n"
((test_passed_count++))
else
fail_test_results+="Test failed for input $input_tag: Expected Type: $expected_type, Prev Tag: $expected_output. Got Type: $script_output, Prev Tag: $script_output\n"
((test_fail_count++))
fi
else
# Extract the type and previous tag from the script output
local script_output_type=$(echo "$script_output" | awk '{print $1}')
local script_output_prev_tag=$(echo "$script_output" | awk '{print $2}')

# Compare the extracted values with the expected ones
if [[ "$script_output_type" == "$expected_type" ]] && [[ "$script_output_prev_tag" == "$expected_output" ]]; then
passed_tests_results+="Test passed for input $input_tag: Expected Type: $expected_type, Prev Tag: $expected_output. Got Type: $script_output_type, Prev Tag: $script_output_prev_tag\n"
((test_passed_count++))
else
fail_test_results+="Test failed for input $input_tag: Expected Type: $expected_type, Prev Tag: $expected_output. Got Type: $script_output_type, Prev Tag: $script_output_prev_tag\n"
((test_fail_count++))
fi
fi

}


# Main test logic
setup_mock_repo
# input : arg 1 -> input tag, arg 2-> expected output
run_test "8.4.0" "8.3.0" # Normal release, next lower tag in the same minor series
run_test "8.3.0" "8.2.0"
run_test "8.3.3" "8.3.2" # Normal release, next lower tag
run_test "8.3.1" "8.3.0" # Normal release, next lower tag
run_test "8.4.0" "8.3.0" "NORMAL" # Normal release, next lower tag in the same minor series
run_test "8.3.0" "8.2.0" "NORMAL"
run_test "8.3.3" "8.3.2" "NORMAL" # Normal release, next lower tag
run_test "8.3.1" "8.3.0" "NORMAL" # Normal release, next lower tag

run_test "8.4.0-alpha2" "8.4.0-alpha1" # Alpha version, next lower alpha tag
run_test "8.3.0-alpha1" "8.2.0" # First alpha of a new minor version
run_test "8.4.0-alpha2" "8.4.0-alpha1" "ALPHA" # Alpha version, next lower alpha tag
run_test "8.3.0-alpha1" "8.2.0" "ALPHA" # First alpha of a new minor version

run_test "8.4.0-alpha2-rc3" "8.4.0-alpha2-rc2" # Alpha RC, next lower alpha RC tag
run_test "8.4.0-alpha2-rc2" "8.4.0-alpha2-rc1" # Alpha RC, next lower alpha RC tag
run_test "8.4.0-alpha2-rc1" "8.4.0-alpha1" # First alpha RC of a new alpha version
run_test "9.0.0-alpha2-rc1" "9.0.0-alpha1" # First alpha RC of a new alpha version
run_test "9.0.0-alpha3-rc1" "9.0.0-alpha2" # First alpha RC of a new alpha version
run_test "8.4.0-alpha1" "8.3.0" # First alpha of a new alpha version
run_test "8.4.0-alpha2-rc3" "8.4.0-alpha2-rc2" "RC" # Alpha RC, next lower alpha RC tag
run_test "8.4.0-alpha2-rc2" "8.4.0-alpha2-rc1" "RC" # Alpha RC, next lower alpha RC tag
run_test "8.4.0-alpha2-rc1" "8.4.0-alpha1" "RC" # First alpha RC of a new alpha version
run_test "9.0.0-alpha2-rc1" "9.0.0-alpha1" "RC" # First alpha RC of a new alpha version
run_test "9.0.0-alpha3-rc1" "9.0.0-alpha2" "RC" # First alpha RC of a new alpha version
run_test "8.4.0-alpha1" "8.3.0" "ALPHA" # First alpha of a new alpha version

run_test "8.4.1-alpha1" "8.4.0" # First alpha of a new alpha version
run_test "8.4.2-alpha1" "8.4.1" # First alpha of a new alpha version
run_test "8.4.1-alpha1" "8.4.0" "ALPHA" # First alpha of a new alpha version
run_test "8.4.2-alpha1" "8.4.0" "ALPHA" # First alpha of a new alpha version

run_test "8.3.2-rc1" "8.3.1" # RC for normal release, next lower normal tag
run_test "8.3.2-rc2" "8.3.2-rc1" # Next RC in series
run_test "8.3.2-rc5" "8.3.2-rc2" # Next RC in series
run_test "8.3.2-rc1" "8.3.1" "RC" # RC for normal release, next lower normal tag
run_test "8.3.2-rc2" "8.3.2-rc1" "RC" # Next RC in series
run_test "8.3.2-rc5" "8.3.2-rc2" "RC" # Next RC in series

run_test "8.4.0-rc1" "8.3.0" # RC for normal release, next lower normal tag
run_test "8.4.0-rc2" "8.4.0-rc1" # Next RC in series
run_test "8.4.0-rc3" "8.4.0-rc2" # Next RC in series
run_test "8.4.0-rc1" "8.3.0" "RC" # RC for normal release, next lower normal tag
run_test "8.4.0-rc2" "8.4.0-rc1" "RC" # Next RC in series
run_test "8.4.0-rc3" "8.4.0-rc2" "RC" # Next RC in series

run_test "8.4.0-alpha2" "8.4.0-alpha1" # Next alpha in series
run_test "8.4.0-alpha2" "8.4.0-alpha1" "ALPHA" # Next alpha in series

run_test "9.0.0" "8.4.0" # First release in a new major version
run_test "9.1.0" "9.0.0" # First release in a new minor version after a major version
run_test "9.0.0" "8.4.0" "NORMAL" # First release in a new major version
run_test "9.1.0" "9.0.0" "NORMAL" # First release in a new minor version after a major version

#additional test cases
run_test "9.2.0-alpha2" "9.1.0" # Missed alpha1
run_test "9.2.0-rc2" "9.1.0" # Missed rc1
run_test "8.2.0" "7.4.0"
run_test "7.4.0" "0.23.2"
run_test "0.23.2" "0.11.0"
run_test "0.11.0" "0.7.3"
run_test "0.7.3" "0.5.1"
run_test "12.0.0" "11.2.0"
run_test "15.0.0" "12.2.0"
run_test "15.0.0-rc1" "12.2.0"
run_test "15.0.3-rc2" "5.0.0"
run_test "16.0.0-rc2" "15.0.0"
run_test "19.0.0-alpha3" "15.0.0"
run_test "19.0.3-alpha3" "15.0.0"
run_test "19.0.3-rc3" "15.0.0"
run_test "19.0.4-alpha11" "19.0.4-alpha6"
run_test "20.3.1-alpha5" "20.3.1-alpha2"
run_test "20.3.1-alpha23" "20.3.1-alpha11"
run_test "20.4.1-alpha1-rc20" "20.4.1-alpha1-rc11"
run_test "20.4.1-alpha1-rc11" "20.4.1-alpha1-rc3"
run_test "20.4.1-alpha1-rc3" "20.3.0"
run_test "20.4.1-alpha30-rc1" "20.4.1-alpha11"
run_test "20.4.1-alpha2-rc1" "20.3.0"
run_test "9.2.0-alpha2" "9.1.0" "ALPHA" # Missed alpha1
run_test "9.2.0-rc2" "9.1.0" "RC" # Missed rc1
run_test "8.2.0" "7.4.0" "NORMAL"
run_test "7.4.0" "0.11.0" "NORMAL"
run_test "0.23.2" "0.11.0" "NORMAL"
run_test "0.11.0" "0.7.3" "NORMAL"
run_test "0.7.3" "0.5.1" "NORMAL"
run_test "12.0.0" "11.2.0" "NORMAL"
run_test "15.0.0" "12.2.0" "NORMAL"
run_test "15.0.0-rc1" "12.2.0" "RC"
run_test "15.0.3-rc2" "15.0.0" "RC"
run_test "16.0.0-rc2" "15.0.0" "RC"
run_test "19.0.0-alpha3" "15.0.0" "ALPHA"
run_test "19.0.3-alpha3" "15.0.0" "ALPHA"
run_test "19.0.3-rc3" "15.0.0" "RC"
run_test "19.0.4-alpha11" "19.0.4-alpha6" "ALPHA"
run_test "20.3.1-alpha5" "20.3.1-alpha2" "ALPHA"
run_test "20.3.1-alpha23" "20.3.1-alpha11" "ALPHA"
run_test "20.4.1-alpha1-rc20" "20.4.1-alpha1-rc11" "RC"
run_test "20.4.1-alpha1-rc11" "20.4.1-alpha1-rc3" "RC"
run_test "20.4.1-alpha1-rc3" "20.3.0" "RC"
run_test "20.4.1-alpha30-rc1" "20.4.1-alpha11" "RC"
run_test "20.4.1-alpha2-rc1" "20.3.0" "RC"

# Invalid Tag Format
run_test "invalid-tag" "Release tag is invalid" # Invalid tag format
Expand Down
Loading
Loading