File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Philosophers CI
2+
3+ on :
4+ push :
5+ branches : [ "main" ]
6+ pull_request :
7+ branches : [ "main" ]
8+
9+ jobs :
10+ build-and-test :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - uses : actions/checkout@v3
15+
16+ - name : Install dependencies
17+ run : sudo apt-get update && sudo apt-get install -y make gcc
18+
19+ - name : Compile project
20+ run : |
21+ cd philo
22+ make re
23+
24+ - name : Run basic tests
25+ run : |
26+ cd philo
27+ # Test 1: 4 philosophers
28+ timeout 5s ./philo 4 800 200 200
29+ [ $? -eq 124 ] && echo "✅ Test 1 Passed (4 philo run)" || (echo "❌ Test 1 Failed" && exit 1)
30+
31+ # Test 2: Meal limit
32+ ./philo 3 1000 200 200 5 > meals.txt
33+ grep -q "is eating" meals.txt
34+ [ $? -eq 0 ] && echo "✅ Test 2 Passed (meal limit)" || (echo "❌ Test 2 Failed" && exit 1)
35+
36+ # Test 3: Single philosopher
37+ ./philo 1 800 200 200 > single.txt
38+ grep -q "died" single.txt
39+ [ $? -eq 0 ] && echo "✅ Test 3 Passed (single philo)" || (echo "❌ Test 3 Failed" && exit 1)
You can’t perform that action at this time.
0 commit comments