-
Notifications
You must be signed in to change notification settings - Fork 33
89 lines (73 loc) · 2.99 KB
/
testing.yml
File metadata and controls
89 lines (73 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Testing Tasks
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install compiler and CMake
run: sudo apt install -y cmake build-essential g++-14 libgtest-dev libgmock-dev
- name: Configure project
run: cmake -B build
- name: Build and run tests for changed tasks
run: |
# Проверяем, есть ли предыдущий коммит
if git rev-parse HEAD~1 > /dev/null 2>&1; then
changed_files=$(git diff --name-only HEAD~1 HEAD)
else
changed_files=$(git ls-files)
fi
echo "Changed files:"
echo "$changed_files"
tasks=("addition" "rms" "print_bits" "check_flags" "length_lit" "quadratic" "char_changer"
"swap_ptr" "func_array" "longest" "last_of_us" "little_big" "pretty_array"
"data_stats" "unique" "range" "minmax" "find_all" "os_overload" "easy_compare" "filter" "enum_operators"
"stack" "queue" "ring_buffer" "phasor"
"tracer" "string_view" "cow_string" "simple_vector"
"unique_ptr" "smart_ptr" "simple_list"
"make_unique" "array"
)
declare -i passed_count=0
declare -i failed_count=0
declare -i task_count=0
# task name arrays
passed_tasks=()
failed_tasks=()
echo "=== Starting tests for changed tasks ==="
for task in "${tasks[@]}"; do
if echo "$changed_files" | grep -q "tasks/$task/"; then
task_count+=1
echo "=== Processing $task ==="
if cmake --build build --target test_$task; then
echo "✅ test_$task built successfully"
if ./build/tasks/test_$task; then
echo "✅ test_$task PASSED"
passed_count+=1
passed_tasks+=("$task")
else
echo "❌ test_$task FAILED"
failed_count+=1
failed_tasks+=("$task")
fi
else
echo "❌ test_$task build FAILED"
failed_count+=1
failed_tasks+=("$task")
fi
fi
done
echo "=== Test Results Summary ==="
echo "Total tasks in list: ${#tasks[@]}"
echo "Processed: $task_count"
echo "✅ Passed: $passed_count [$(echo ${passed_tasks[@]} | tr ' ' ', ')]"
echo "❌ Failed: $failed_count [$(echo ${failed_tasks[@]} | tr ' ' ', ')]"
if [ $failed_count -gt 0 ]; then
echo "❌ Some tasks failed!"
exit 1
elif [ $task_count -eq 0 ]; then
echo "No tasks were processed (no changes)"
exit 0
else
echo "✅ All processed tasks passed!"
exit 0
fi