1+ name : Testing Tasks Week 06
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ tasks :
7+ description : ' Select tasks to test'
8+ required : true
9+ type : choice
10+ default : ' all'
11+ options :
12+ - all
13+ - unique_ptr
14+ - smart_ptr
15+ - simple_list
16+
17+ schedule :
18+ - cron : ' 59 20 23 02 *' # UTC: 20:59 = 23:59 MSK 23 February
19+
20+ jobs :
21+ test :
22+ runs-on : ubuntu-latest
23+ steps :
24+ - uses : actions/checkout@v4
25+
26+ - name : Install compiler and CMake
27+ run : sudo apt install -y cmake build-essential g++-14 libgtest-dev libgmock-dev
28+
29+ - name : Configure project
30+ run : cmake -B build
31+
32+ - name : Determine tasks to run
33+ id : get-tasks
34+ run : |
35+ if [[ "${{ github.event_name }}" = "schedule" ]] ||
36+ [[ "${{ github.event.inputs.tasks }}" = "all" ]]; then
37+ # Find all tasks
38+ TASKS=()
39+ for dir in 06_week/tasks/*/; do
40+ task=$(basename "$dir")
41+ TASKS+=("$task")
42+ done
43+ echo "tasks=${TASKS[*]}" >> $GITHUB_OUTPUT
44+ else
45+ # Используем указанную задачу
46+ echo "tasks=${{ github.event.inputs.tasks }}" >> $GITHUB_OUTPUT
47+ fi
48+
49+ - name : Build and run tests for selected tasks
50+ run : |
51+ echo "Event: ${{ github.event_name }}"
52+ echo "Tasks to test: '${{ steps.get-tasks.outputs.tasks }}'"
53+
54+ IFS=' ' read -ra tasks <<< "${{ steps.get-tasks.outputs.tasks }}"
55+
56+ declare -i passed_count=0
57+ declare -i failed_count=0
58+ declare -i task_count=0
59+
60+ # task name arrays
61+ passed_tasks=()
62+ failed_tasks=()
63+
64+ echo "=== Starting tests for selected tasks ==="
65+
66+ for task in "${tasks[@]}"; do
67+ task_count+=1
68+ echo "=== Processing $task ==="
69+
70+ if cmake --build build --target test_$task; then
71+ echo "✅ test_$task built successfully"
72+
73+ if ./build/tasks/test_$task; then
74+ echo "✅ test_$task PASSED"
75+ passed_count+=1
76+ passed_tasks+=("$task")
77+ else
78+ echo "❌ test_$task FAILED"
79+ failed_count+=1
80+ failed_tasks+=("$task")
81+ fi
82+ else
83+ echo "❌ test_$task build FAILED"
84+ failed_count+=1
85+ failed_tasks+=("$task")
86+ fi
87+ done
88+
89+ echo "=== Test Results Summary ==="
90+ echo "Total tasks in list: ${#tasks[@]}"
91+ echo "Processed: $task_count"
92+ echo "✅ Passed: $passed_count [$(echo ${passed_tasks[@]} | tr ' ' ', ')]"
93+ echo "❌ Failed: $failed_count [$(echo ${failed_tasks[@]} | tr ' ' ', ')]"
94+
95+ if [ $failed_count -gt 0 ]; then
96+ echo "❌ Some tasks failed!"
97+ exit 1
98+ elif [ $task_count -eq 0 ]; then
99+ echo "No tasks were processed (no changes)"
100+ exit 0
101+ else
102+ echo "✅ All processed tasks passed!"
103+ exit 0
104+ fi
0 commit comments