-
Notifications
You must be signed in to change notification settings - Fork 15
294 lines (283 loc) · 9.06 KB
/
php.yml
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
name: All Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
unit-tests:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- uses: shivammathur/[email protected]
with:
php-version: 8.0
extensions: xdebug
- name: Validate composer.json and install tools
run: |
composer validate
make tools
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md
- name: Run test suite
run: composer run-script test
- name: upload coverage
run: bash <(curl -s https://codecov.io/bash)
lint:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- uses: shivammathur/[email protected]
with:
php-version: 8.0
extensions: xdebug
- name: Validate composer.json and composer.lock
run: composer validate && make tools
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md
- name: Run test suite
run: composer run-script lint
build-integration-test-containers:
runs-on: ubuntu-latest
needs:
- lint
- unit-tests
strategy:
matrix:
image:
- caddy
- tests
- php-actor-service
- php-actor-http
- php-client-service
- php-client-http
- php-secrets-service
- php-secrets-http
- php-secret-client-service
- php-secret-client-http
- sail-app
include:
- image: caddy
dockerfile: images/caddy.Dockerfile
target: base
- image: tests
dockerfile: images/tests.Dockerfile
target: production
- image: php-actor-service
dockerfile: examples/images/service.Dockerfile
target: production
context: examples/actor
args: |
SERVICE=actor
- image: php-actor-http
dockerfile: examples/images/caddy.Dockerfile
target: base
context: examples/actor
args: |
SERVICE=actor
- image: php-client-service
dockerfile: examples/images/service.Dockerfile
target: production
context: examples/actor
args: |
SERVICE=client
- image: php-client-http
dockerfile: examples/images/caddy.Dockerfile
target: base
context: examples/actor
args: |
SERVICE=client
- image: php-secrets-service
dockerfile: examples/images/service.Dockerfile
target: production
context: examples/secrets
args: |
SERVICE=secrets
- image: php-secrets-http
dockerfile: examples/images/caddy.Dockerfile
target: base
context: examples/secrets
args: |
SERVICE=secrets
- image: php-secret-client-service
dockerfile: examples/images/service.Dockerfile
target: production
context: examples/secrets
args: |
SERVICE=client
- image: php-secret-client-http
dockerfile: examples/images/caddy.Dockerfile
target: base
context: examples/secrets
args: |
SERVICE=client
- image: sail-app
context: examples/laravel/vendor/laravel/sail/runtimes/8.0
dockerfile: examples/laravel/vendor/laravel/sail/runtimes/8.0/Dockerfile
args: |
WWWGROUP=1000
pre-built: |
cd examples/laravel
composer install
steps:
- uses: actions/checkout@v2
- uses: shivammathur/[email protected]
with:
php-version: 8.0
- name: Update examples
env:
GIT_BRANCH: ${{ github.head_ref || 'main' }}
run:
php update-examples.php
- name: Run Prebuild hook
run: ${{ matrix.pre-built }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
with:
install: true
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.${{ matrix.image }}-cache
key: ${{ runner.os }}-${{ matrix.image }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ matrix.image }}-
- name: Build and push
uses: docker/build-push-action@v2
with:
context: ${{ matrix.context || './' }}
file: ${{ matrix.dockerfile }}
push: false
pull: true
outputs: type=docker,dest=/tmp/${{ matrix.image }}.tar
target: ${{ matrix.target }}
tags: ${{ matrix.image }}:${{ github.sha }}
builder: ${{ steps.buildx.outputs.name }}
cache-from: type=local,src=/tmp/.${{ matrix.image }}-cache
cache-to: type=local,mode=max,dest=/tmp/.${{ matrix.image }}-cache
build-args: ${{ matrix.args || '' }}
- name: upload artifact
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.image }}
path: /tmp/${{ matrix.image }}.tar
integration-tests:
runs-on: ubuntu-latest
needs:
- build-integration-test-containers
timeout-minutes: 5
strategy:
matrix:
dapr-version: [ 1.5.2, 1.6.1, 1.7.0 ]
steps:
- name: Download Caddy Image
uses: actions/download-artifact@v2
with:
name: caddy
path: /tmp
- name: Download Tests Image
uses: actions/download-artifact@v2
with:
name: tests
path: /tmp
- name: Import images
run: |
docker load --input /tmp/caddy.tar
docker load --input /tmp/tests.tar
- uses: actions/checkout@v2
- uses: shivammathur/[email protected]
with:
php-version: 8.0
- name: Validate composer.json and composer.lock
run: composer validate
- name: Integration Environment Startup
env:
DAPR_VERSION: ${{ matrix.dapr-version }}
run: docker-compose up -d
- name: Wait for environment stabilization
run: sleep 10
- name: Execute Tests
run: |
STATUSCODE=$(curl --silent --output /tmp/test-results.json --write-out "%{http_code}" -H 'dapr-api-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' http://localhost:9502/do_tests)
cat /tmp/test-results.json | jq -C .
if test $STATUSCODE -ne 200; then
docker-compose logs dev
exit 1
fi
examples:
runs-on: ubuntu-latest
needs:
- build-integration-test-containers
timeout-minutes: 5
strategy:
matrix:
dapr-version:
- 1.5.2
- 1.6.1
- 1.7.0
example:
- actor
- secrets
- laravel
steps:
- uses: actions/checkout@v2
- uses: shivammathur/[email protected]
with:
php-version: 8.0
- name: Update examples
env:
GIT_BRANCH: ${{ github.head_ref || 'main' }}
run:
php update-examples.php
- name: Download images
uses: actions/download-artifact@v2
with:
path: /tmp/images
- name: Import images
run: |
ls -lah /tmp/images
for f in /tmp/images/*/*.tar; do
cat $f | docker load
done
- name: Start services
env:
DAPR_VERSION: ${{ matrix.dapr-version }}
GIT_SHA: ${{ github.sha }}
run: |
cd examples/${{ matrix.example }}
if [ -f start.php ]; then
php start.php
else
docker-compose -f docker-compose.yml -f ../docker-compose.common.yml up -d
fi
- name: Wait for stability
run: sleep 10
- name: Run tests
run: |
cd examples/${{ matrix.example }}
php test.php