Skip to content

Commit 8b6470f

Browse files
Update Actors Example to 1.2 (#105)
* Require middleware psr * Allow app to function as middleware * Test with a production implementation * Fix tests * Start building examples * Fix build args * ok, actually fix them? * Track images * ADd actor caddy image * Add client service * Add client * Start running examples * Try a forloop * Start containers * Include git sha * Checkout code * Add test * Start auto-syncing examples * Auto commit examples in branches * Commit all changes * Fix yaml * Commit to correct branch * Commit only composer files in examples * Update examples Commit made by Github Actions https://github.com/dapr/php-sdk/actions/runs/1064895473 * Don't commit sha * Update examples Commit made by Github Actions https://github.com/dapr/php-sdk/actions/runs/1064899244 * Wait for actors to be registered * Update examples Commit made by Github Actions https://github.com/dapr/php-sdk/actions/runs/1064915195 * Wait for examples to updated * Update examples Commit made by Github Actions https://github.com/dapr/php-sdk/actions/runs/1064919313 * Compile container * Use http method attributes * Update examples Commit made by Github Actions https://github.com/dapr/php-sdk/actions/runs/1064998455 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 648006f commit 8b6470f

29 files changed

+1555
-206
lines changed

.github/workflows/php.yml

Lines changed: 99 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@ on:
77
branches: [ main ]
88

99
jobs:
10+
update-examples:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 5
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: shivammathur/setup-php@2.9.0
16+
with:
17+
php-version: 8.0
18+
- name: Update examples
19+
env:
20+
GIT_BRANCH: ${{ github.head_ref || 'main' }}
21+
run:
22+
php update-examples.php
23+
- name: Commit examples
24+
uses: quizlet/commit-changes@v0.2.3
25+
with:
26+
message: Update examples
27+
glob-patterns: |
28+
**/composer.json
29+
**/composer.lock
30+
branch: ${{ github.head_ref || 'main' }}
1031
unit-tests:
1132
runs-on: ubuntu-latest
1233
timeout-minutes: 5
@@ -77,16 +98,47 @@ jobs:
7798
needs:
7899
- lint
79100
- unit-tests
101+
- update-examples
80102
strategy:
81103
matrix:
82-
image: [ 'caddy', 'tests' ]
104+
image:
105+
- caddy
106+
- tests
107+
- php-actor-service
108+
- php-actor-http
109+
- php-client-service
110+
- php-client-http
83111
include:
84112
- image: caddy
85113
dockerfile: images/caddy.Dockerfile
86114
target: base
87115
- image: tests
88116
dockerfile: images/tests.Dockerfile
89117
target: production
118+
- image: php-actor-service
119+
dockerfile: examples/images/service.Dockerfile
120+
target: production
121+
context: examples/actor
122+
args: |
123+
SERVICE=actor
124+
- image: php-actor-http
125+
dockerfile: examples/images/caddy.Dockerfile
126+
target: base
127+
context: examples/actor
128+
args: |
129+
SERVICE=actor
130+
- image: php-client-service
131+
dockerfile: examples/images/service.Dockerfile
132+
target: production
133+
context: examples/actor
134+
args: |
135+
SERVICE=client
136+
- image: php-client-http
137+
dockerfile: examples/images/caddy.Dockerfile
138+
target: base
139+
context: examples/actor
140+
args: |
141+
SERVICE=client
90142
steps:
91143
- uses: actions/checkout@v2
92144
- name: Set up Docker Buildx
@@ -109,7 +161,7 @@ jobs:
109161
- name: Build and push
110162
uses: docker/build-push-action@v2
111163
with:
112-
context: ./
164+
context: ${{ matrix.context || './' }}
113165
file: ${{ matrix.dockerfile }}
114166
push: false
115167
pull: true
@@ -119,6 +171,7 @@ jobs:
119171
builder: ${{ steps.buildx.outputs.name }}
120172
cache-from: type=local,src=/tmp/.${{ matrix.image }}-cache
121173
cache-to: type=local,mode=max,dest=/tmp/.${{ matrix.image }}-cache
174+
build-args: ${{ matrix.args || '' }}
122175
- name: upload artifact
123176
uses: actions/upload-artifact@v2
124177
with:
@@ -167,3 +220,47 @@ jobs:
167220
docker-compose logs dev
168221
exit 1
169222
fi
223+
examples:
224+
runs-on: ubuntu-latest
225+
needs:
226+
- build-integration-test-containers
227+
timeout-minutes: 5
228+
strategy:
229+
matrix:
230+
dapr-version:
231+
- 1.3.0-rc.4
232+
- 1.2.0
233+
- 1.2.1
234+
- 1.2.2
235+
example:
236+
- actor
237+
include:
238+
- example: actor
239+
steps:
240+
- uses: actions/checkout@v2
241+
- uses: shivammathur/setup-php@2.9.0
242+
with:
243+
php-version: 8.0
244+
- name: Download images
245+
uses: actions/download-artifact@v2
246+
with:
247+
path: /tmp/images
248+
- name: Import images
249+
run: |
250+
ls -lah /tmp/images
251+
for f in /tmp/images/*/*.tar; do
252+
cat $f | docker load
253+
done
254+
- name: Start services
255+
env:
256+
DAPR_VERSION: ${{ matrix.dapr-version }}
257+
GIT_SHA: ${{ github.sha }}
258+
run: |
259+
cd examples/${{ matrix.example }}
260+
docker-compose -f docker-compose.yml -f ../docker-compose.common.yml up -d
261+
- name: Wait for stability
262+
run: sleep 10
263+
- name: Run tests
264+
run: |
265+
cd examples/${{ matrix.example }}
266+
php test.php

composer.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,22 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^8.0",
13+
"ext-curl": "*",
1414
"ext-json": "*",
1515
"ext-mbstring": "*",
16-
"ext-curl": "*",
17-
"psr/log": "^1.1",
18-
"nette/php-generator": "^3.5",
19-
"php-di/php-di": "^6.3",
16+
"guzzlehttp/guzzle": "^7.3",
17+
"laminas/laminas-httphandlerrunner": "^1.3",
2018
"monolog/monolog": "^2.2",
19+
"nette/php-generator": "^3.5",
2120
"nikic/fast-route": "^1.3",
2221
"nyholm/psr7": "^1.3",
2322
"nyholm/psr7-server": "^1.0",
23+
"php": "^8.0",
2424
"php-di/invoker": "^2.3",
25-
"laminas/laminas-httphandlerrunner": "^1.3",
26-
"guzzlehttp/guzzle": "^7.3"
25+
"php-di/php-di": "^6.3",
26+
"psr/log": "^1.1",
27+
"psr/http-server-middleware": ">=1.0.1",
28+
"jetbrains/phpstorm-attributes": "1.0"
2729
},
2830
"require-dev": {
2931
"ext-xdebug": "*",

composer.lock

Lines changed: 102 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/actor/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
DOCKER_USER=withinboredom
2+
DAPR_VERSION=1.2.0

examples/actor/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
vendor/
2-
images/
32
.idea/

examples/actor/Makefile

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,27 @@ SHELL := /bin/bash
22

33
include .env
44
export $(shell sed 's/=.*//' .env)
5+
export GIT_SHA=$(shell git rev-parse HEAD)
56

67
.PHONY: deps
7-
deps: images/fpm.conf images/opcache.ini images/xdebug.ini images/Caddyfile docker-compose.yml
8-
DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker-compose build
8+
deps: service/actor-http service/actor-service service/client-http service/client-service
9+
@echo 'all done: run `make start` to get started'
10+
11+
.PHONY: service/actor-service
12+
service/actor-service: images/opcache.ini images/fpm.conf
13+
docker build --pull --build-arg SERVICE=actor -f ../images/service.Dockerfile --target production -t php-actor-service:${GIT_SHA} .
14+
15+
.PHONY: service/actor-http
16+
service/actor-http: images/Caddyfile
17+
docker build --pull --build-arg SERVICE=actor -f ../images/caddy.Dockerfile --target base -t php-actor-http:${GIT_SHA} .
18+
19+
.PHONY: service/client-service
20+
service/client-service: images/opcache.ini images/opcache.ini
21+
docker build --pull --build-arg SERVICE=client -f ../images/service.Dockerfile --target production -t php-client-service:${GIT_SHA} .
22+
23+
.PHONY: service/client-http
24+
service/client-http: images/Caddyfile
25+
docker build --pull --build-arg SERICE=client -f ../images/caddy.Dockerfile --target base -t php-client-http:${GIT_SHA} .
926

1027
.PHONY: start
1128
start:
@@ -18,11 +35,10 @@ stop:
1835
.PHONY: clean
1936
clean: stop
2037
docker-compose -f docker-compose.yml -f ../docker-compose.common.yml rm -f
21-
rm -rf images
2238

23-
.PHONY: push
24-
push: deps
25-
docker-compose push
39+
.PHONY: logs
40+
logs:
41+
docker-compose -f docker-compose.yml -f ../docker-compose.common.yml logs
2642

2743
images/fpm.conf: ../images/fpm.conf
2844
mkdir -p images

examples/actor/composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "dapr/actor-example",
3-
"license": "MIT",
4-
"description": "A basic example demonstrating actors",
5-
"require": {
6-
"dapr/php-sdk": "^1.0"
7-
}
2+
"name": "dapr/actor-example",
3+
"license": "MIT",
4+
"description": "A basic example demonstrating actors",
5+
"require": {
6+
"dapr/php-sdk": "dev-add/psr-middleware"
7+
}
88
}

0 commit comments

Comments
 (0)