9
9
jobs :
10
10
tests :
11
11
runs-on : ubuntu-24.04
12
+ timeout-minutes : 20
12
13
13
14
strategy :
14
- fail-fast : true
15
+ fail-fast : false
15
16
matrix :
16
17
php : ['8.2', '8.3']
17
18
stability : ['prefer-lowest', 'prefer-stable']
@@ -31,48 +32,80 @@ jobs:
31
32
php-version : ${{ matrix.php }}
32
33
extensions : dom, curl, libxml, mbstring, zip, json
33
34
coverage : none
35
+ tools : composer:v2.8.6
36
+
37
+ - name : Get Composer Cache Directory
38
+ id : composer-cache
39
+ run : |
40
+ echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
41
+
42
+ - name : Cache Composer dependencies
43
+ uses : actions/cache@v4
44
+ with :
45
+ path : ${{ steps.composer-cache.outputs.dir }}
46
+ key : ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.stability }}-${{ hashFiles('**/composer.json') }}
47
+ restore-keys : |
48
+ ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.stability }}-
49
+ ${{ runner.os }}-composer-${{ matrix.php }}-
50
+ ${{ runner.os }}-composer-
34
51
35
52
- name : Set up Docker
53
+ timeout-minutes : 5
36
54
run : |
37
55
docker-compose up -d rabbitmq
38
56
39
57
- name : Install dependencies
58
+ timeout-minutes : 5
40
59
run : |
41
60
composer update --with='laravel/framework:${{matrix.laravel}}' --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
42
61
43
62
- name : Run Laravel Pint
63
+ timeout-minutes : 2
44
64
run : ./vendor/bin/pint --test
45
65
46
66
- name : Wait for RabbitMQ
67
+ timeout-minutes : 2
47
68
run : |
48
- timeout=30
49
- until docker exec $(docker ps -qf "name=rabbitmq") rabbitmqctl status >/dev/null 2>&1 || [ $timeout -eq 0 ]; do
50
- echo "Waiting for RabbitMQ to be ready... ($timeout seconds left)"
69
+ echo "Waiting for RabbitMQ to be ready..."
70
+ for i in {1..30}; do
71
+ if docker exec $(docker ps -qf "name=rabbitmq") rabbitmqctl status >/dev/null 2>&1; then
72
+ echo "RabbitMQ is ready!"
73
+ exit 0
74
+ fi
75
+ echo "Attempt $i/30 - Waiting for RabbitMQ..."
51
76
sleep 1
52
- ((timeout--))
53
77
done
54
- if [ $timeout -eq 0 ]; then
55
- echo "Timeout waiting for RabbitMQ"
56
- exit 1
57
- fi
58
- echo "RabbitMQ is ready!"
78
+ echo "RabbitMQ failed to start"
79
+ docker ps
80
+ docker logs $(docker ps -qf "name=rabbitmq")
81
+ exit 1
59
82
60
83
- name : Execute tests
61
- run : vendor/bin/phpunit
84
+ timeout-minutes : 5
85
+ run : vendor/bin/phpunit --verbose
62
86
env :
63
87
HOST : localhost
64
88
PORT : 5672
65
89
RABBITMQ_USER : guest
66
90
RABBITMQ_PASSWORD : guest
67
91
RABBITMQ_VHOST : /
92
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
68
93
69
94
- name : Store test logs
70
95
if : failure()
71
96
uses : actions/upload-artifact@v4
97
+ timeout-minutes : 1
72
98
with :
73
- name : test-logs-php ${{ matrix.php }}-laravel ${{ matrix.laravel }}-${{ github.sha }}
99
+ name : test-logs-${{ matrix.php }}-${{ matrix.stability }}-${{ github.sha }}
74
100
path : |
75
101
./storage/logs
76
102
./phpunit.xml
77
103
./.env.testing
104
+ ./docker-compose.logs
78
105
retention-days : 5
106
+
107
+ - name : Cleanup
108
+ if : always()
109
+ run : |
110
+ docker-compose down -v
111
+ docker system prune -f
0 commit comments