@@ -3,7 +3,7 @@ name: "Tests"
33on :
44 pull_request :
55 branches :
6- - master
6+ - main
77 paths :
88 - ' **.php'
99 - ' composer.json'
1212 - ' .github/workflows/tests.yaml'
1313 push :
1414 branches :
15- - master
15+ - main
1616 paths :
1717 - ' **.php'
1818 - ' composer.json'
2222
2323env :
2424 CONSUL_HTTP_ADDR : " 127.0.0.1:8500"
25- CONSUL_VERSION : ' 1.17.2 '
25+ CONSUL_VERSION : ' 1.20.5 '
2626
2727jobs :
2828 tests :
2929 runs-on : ubuntu-22.04
3030 strategy :
3131 matrix :
32- php-version : ["8.0", "8.1", "8.2"]
32+ php-version :
33+ - ' 8.1'
34+ - ' 8.2'
35+ - ' 8.3'
36+ - ' 8.4'
3337
3438 name : Tests - PHP ${{ matrix.php-version }}
3539 steps :
3640 - uses : actions/checkout@v4
3741
42+ - name : ' Define vars'
43+ id : vars
44+ shell : bash -e {0}
45+ # language=sh
46+ run : |
47+ _phpunit_version=
48+ case "${{ matrix.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: ${{ matrix.php-version }}" && exit 1 ;;
54+ esac
55+ echo "phpunit-version=${_phpunit_version}" >> $GITHUB_OUTPUT
56+
3857 - uses : shivammathur/setup-php@v2
3958 with :
4059 php-version : ${{ matrix.php-version }}
4160 extensions : json
4261 ini-values : precision=14,serialize_precision=-1
4362
44- - name : ' Composer update'
45- # 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
4671 run : |
47- composer update \
48- --no-ansi \
49- --no-interaction \
50- --no-scripts \
51- --no-progress
72+ tmpf="$(mktemp)"
73+ jq -rcM '."require-dev"."phpunit/phpunit" = "^${{ steps.vars.outputs.phpunit-version }}"' composer.json > "${tmpf}"
74+ mv "${tmpf}" composer.json
5275
53- - name : ' Install Consul'
76+ - name : ' Get composer cache directory'
77+ id : composer-cache
78+ shell : bash -e {0}
79+ # language=sh
80+ run : |
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 }}-${{ matrix.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 }}-${{ matrix.php-version }}-${{ steps.vars.outputs.phpunit-version }}-${{ hashFiles('composer.lock') }}"
103+
104+ - name : ' Restore consul ${{ env.CONSUL_VERSION }}'
105+ id : consul-cache
106+ uses : actions/cache/restore@v4
107+ with :
108+ path : ' ${{ runner.tool_cache }}/consul'
109+ key : ' consul-${{ env.CONSUL_VERSION }}'
110+
111+ - name : ' Install consul ${{ env.CONSUL_VERSION }}'
112+ if : ' ! steps.consul-cache.outputs.cache-hit'
113+ working-directory : ' ${{ runner.temp }}'
54114 # language=bash
55115 run : |
56- wget https://releases.hashicorp.com/consul/${{ env.CONSUL_VERSION }}/consul_${{ env.CONSUL_VERSION }}_linux_amd64.zip
57- unzip consul_${{ env.CONSUL_VERSION }}_linux_amd64.zip -d /usr/local/bin/
58- rm consul_${{ env.CONSUL_VERSION }}_linux_amd64.zip
59- chmod +x /usr/local/bin/consul
60- consul --version
116+ mkdir consul
117+ wget -O consul.zip https://releases.hashicorp.com/consul/${{ env.CONSUL_VERSION }}/consul_${{ env.CONSUL_VERSION }}_linux_amd64.zip
118+ unzip 'consul.zip' consul -d consul/
119+ rm consul.zip
120+ chmod +x consul/consul
121+
122+ - name : ' Install consul ${{ env.CONSUL_VERSION }} into tool cache'
123+ uses : AnimMouse/tool-cache@v1
124+ with :
125+ folder_name : consul
126+ cache_hit : ${{ steps.consul-cache.outputs.cache-hit }}
127+
128+ - name : ' Save consul ${{ env.CONSUL_VERSION }} cache'
129+ if : ' ! steps.consul-cache.outputs.cache-hit'
130+ uses : actions/cache/save@v4
131+ with :
132+ path : ' ${{ runner.tool_cache }}/consul'
133+ key : ' consul-${{ env.CONSUL_VERSION }}'
61134
62135 - name : ' Execute tests'
63136 # language=bash
0 commit comments