-
-
Notifications
You must be signed in to change notification settings - Fork 21
138 lines (121 loc) · 4.15 KB
/
tests.yaml
File metadata and controls
138 lines (121 loc) · 4.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: "Tests"
on:
pull_request:
branches:
- main
paths:
- '**.php'
- 'composer.json'
- 'composer.lock'
- 'phpunit.xml'
- '.github/workflows/tests.yaml'
push:
branches:
- main
paths:
- '**.php'
- 'composer.json'
- 'composer.lock'
- 'phpunit.xml'
- '.github/workflows/tests.yaml'
env:
CONSUL_HTTP_ADDR: "127.0.0.1:8500"
CONSUL_VERSION: '1.20.5'
jobs:
tests:
runs-on: ubuntu-22.04
strategy:
matrix:
php-version:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
name: Tests - PHP ${{ matrix.php-version }}
steps:
- uses: actions/checkout@v6
- name: 'Define vars'
id: vars
shell: bash -e {0}
# language=sh
run: |
_phpunit_version=
case "${{ matrix.php-version }}" in
8.1) _phpunit_version='10.5' ;;
8.2) _phpunit_version='11.1' ;;
8.3) _phpunit_version='11.1' ;;
8.4) _phpunit_version='11.1' ;;
*) echo "Unsupported PHP version: ${{ matrix.php-version }}" && exit 1 ;;
esac
echo "phpunit-version=${_phpunit_version}" >> $GITHUB_OUTPUT
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: json
ini-values: precision=14,serialize_precision=-1
- name: 'Install jq'
uses: dcarbone/install-jq-action@v3
with:
force: true
- name: 'Set composer dep versions'
shell: bash -e {0}
# language=sh
run: |
tmpf="$(mktemp)"
jq -rcM '."require-dev"."phpunit/phpunit" = "^${{ steps.vars.outputs.phpunit-version }}"' composer.json > "${tmpf}"
mv "${tmpf}" composer.json
- name: 'Get composer cache directory'
id: composer-cache
shell: bash -e {0}
# language=sh
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: 'Init composer dep cache'
id: cache
uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: "composer-${{ runner.os }}-${{ matrix.php-version }}-${{ steps.vars.outputs.phpunit-version }}-${{ hashFiles('composer.lock') }}"
- name: 'Install composer deps'
shell: bash -e {0}
# language=sh
run: |
rm composer.lock
composer update --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: 'Save composer dep cache'
if: steps.cache.outputs.cache-hit != 'true' && steps.cache.outputs.cache-hit != true
uses: actions/cache/save@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: "composer-${{ runner.os }}-${{ matrix.php-version }}-${{ steps.vars.outputs.phpunit-version }}-${{ hashFiles('composer.lock') }}"
- name: 'Restore consul ${{ env.CONSUL_VERSION }}'
id: consul-cache
uses: actions/cache/restore@v5
with:
path: '${{ runner.tool_cache }}/consul'
key: 'consul-${{ env.CONSUL_VERSION }}'
- name: 'Install consul ${{ env.CONSUL_VERSION }}'
if: '! steps.consul-cache.outputs.cache-hit'
working-directory: '${{ runner.temp }}'
# language=bash
run: |
mkdir consul
wget -O consul.zip https://releases.hashicorp.com/consul/${{ env.CONSUL_VERSION }}/consul_${{ env.CONSUL_VERSION }}_linux_amd64.zip
unzip 'consul.zip' consul -d consul/
rm consul.zip
chmod +x consul/consul
- name: 'Install consul ${{ env.CONSUL_VERSION }} into tool cache'
uses: AnimMouse/tool-cache@v1
with:
folder_name: consul
cache_hit: ${{ steps.consul-cache.outputs.cache-hit }}
- name: 'Save consul ${{ env.CONSUL_VERSION }} cache'
if: '! steps.consul-cache.outputs.cache-hit'
uses: actions/cache/save@v5
with:
path: '${{ runner.tool_cache }}/consul'
key: 'consul-${{ env.CONSUL_VERSION }}'
- name: 'Execute tests'
# language=bash
run: |
./vendor/bin/phpunit -c phpunit.xml