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