@@ -39,20 +39,67 @@ jobs:
39
39
steps :
40
40
- uses : actions/checkout@v4
41
41
42
+ - name : ' Define vars'
43
+ id : vars
44
+ shell : bash -e {0}
45
+ # language=sh
46
+ run : |
47
+ _phpunit_version=
48
+ case "${{ inputs.php-version }}" in
49
+ 8.1) _phpunit_version='10.5' ;;
50
+ 8.2) _phpunit_version='11.1' ;;
51
+ 8.3) _phpunit_version='11.1' ;;
52
+ 8.4) _phpunit_version='11.1' ;;
53
+ *) echo "Unsupported PHP version: ${{ inputs.php-version }}" && exit 1 ;;
54
+ esac
55
+ echo "phpunit-version=${_phpunit_version}" >> $GITHUB_OUTPUT
56
+
42
57
- uses : shivammathur/setup-php@v2
43
58
with :
44
59
php-version : ${{ matrix.php-version }}
45
60
extensions : json
46
61
ini-values : precision=14,serialize_precision=-1
47
62
48
- - name : ' Composer update'
49
- # language=bash
63
+ - name : ' Install jq'
64
+ uses : dcarbone/install-jq-action@v3
65
+ with :
66
+ force : true
67
+
68
+ - name : ' Set composer dep versions'
69
+ shell : bash -e {0}
70
+ # language=sh
71
+ run : |
72
+ tmpf="$(mktemp)"
73
+ jq -rcM '."require-dev"."phpunit/phpunit" = "^${{ steps.vars.outputs.phpunit-version }}"' composer.json > "${tmpf}"
74
+ mv "${tmpf}" composer.json
75
+
76
+ - name : ' Get composer cache directory'
77
+ id : composer-cache
78
+ shell : bash -e {0}
79
+ # language=sh
50
80
run : |
51
- composer update \
52
- --no-ansi \
53
- --no-interaction \
54
- --no-scripts \
55
- --no-progress
81
+ echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
82
+
83
+ - name : ' Init composer dep cache'
84
+ id : cache
85
+ uses : actions/cache@v4
86
+ with :
87
+ path : ${{ steps.composer-cache.outputs.dir }}
88
+ key : " composer-${{ runner.os }}-${{ inputs.php-version }}-${{ steps.vars.outputs.phpunit-version }}-${{ hashFiles('composer.lock') }}"
89
+
90
+ - name : ' Install composer deps'
91
+ shell : bash -e {0}
92
+ # language=sh
93
+ run : |
94
+ rm composer.lock
95
+ composer update --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
96
+
97
+ - name : ' Save composer dep cache'
98
+ if : steps.cache.outputs.cache-hit != 'true' && steps.cache.outputs.cache-hit != true
99
+ uses : actions/cache/save@v4
100
+ with :
101
+ path : ${{ steps.composer-cache.outputs.dir }}
102
+ key : " composer-${{ runner.os }}-${{ inputs.php-version }}-${{ steps.vars.outputs.phpunit-version }}-${{ hashFiles('composer.lock') }}"
56
103
57
104
- name : ' Install Consul'
58
105
# language=bash
0 commit comments