Skip to content

Commit

Permalink
Update Actors Example to 1.2 (#105)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
withinboredom and github-actions[bot] authored Jul 25, 2021
1 parent 648006f commit 8b6470f
Show file tree
Hide file tree
Showing 29 changed files with 1,555 additions and 206 deletions.
101 changes: 99 additions & 2 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ on:
branches: [ main ]

jobs:
update-examples:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@2.9.0
with:
php-version: 8.0
- name: Update examples
env:
GIT_BRANCH: ${{ github.head_ref || 'main' }}
run:
php update-examples.php
- name: Commit examples
uses: quizlet/commit-changes@v0.2.3
with:
message: Update examples
glob-patterns: |
**/composer.json
**/composer.lock
branch: ${{ github.head_ref || 'main' }}
unit-tests:
runs-on: ubuntu-latest
timeout-minutes: 5
Expand Down Expand Up @@ -77,16 +98,47 @@ jobs:
needs:
- lint
- unit-tests
- update-examples
strategy:
matrix:
image: [ 'caddy', 'tests' ]
image:
- caddy
- tests
- php-actor-service
- php-actor-http
- php-client-service
- php-client-http
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
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
Expand All @@ -109,7 +161,7 @@ jobs:
- name: Build and push
uses: docker/build-push-action@v2
with:
context: ./
context: ${{ matrix.context || './' }}
file: ${{ matrix.dockerfile }}
push: false
pull: true
Expand All @@ -119,6 +171,7 @@ jobs:
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:
Expand Down Expand Up @@ -167,3 +220,47 @@ jobs:
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.3.0-rc.4
- 1.2.0
- 1.2.1
- 1.2.2
example:
- actor
include:
- example: actor
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@2.9.0
with:
php-version: 8.0
- 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 }}
docker-compose -f docker-compose.yml -f ../docker-compose.common.yml up -d
- name: Wait for stability
run: sleep 10
- name: Run tests
run: |
cd examples/${{ matrix.example }}
php test.php
16 changes: 9 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@
}
],
"require": {
"php": "^8.0",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-curl": "*",
"psr/log": "^1.1",
"nette/php-generator": "^3.5",
"php-di/php-di": "^6.3",
"guzzlehttp/guzzle": "^7.3",
"laminas/laminas-httphandlerrunner": "^1.3",
"monolog/monolog": "^2.2",
"nette/php-generator": "^3.5",
"nikic/fast-route": "^1.3",
"nyholm/psr7": "^1.3",
"nyholm/psr7-server": "^1.0",
"php": "^8.0",
"php-di/invoker": "^2.3",
"laminas/laminas-httphandlerrunner": "^1.3",
"guzzlehttp/guzzle": "^7.3"
"php-di/php-di": "^6.3",
"psr/log": "^1.1",
"psr/http-server-middleware": ">=1.0.1",
"jetbrains/phpstorm-attributes": "1.0"
},
"require-dev": {
"ext-xdebug": "*",
Expand Down
105 changes: 102 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/actor/.env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
DOCKER_USER=withinboredom
DAPR_VERSION=1.2.0
1 change: 0 additions & 1 deletion examples/actor/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
vendor/
images/
.idea/
28 changes: 22 additions & 6 deletions examples/actor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,27 @@ SHELL := /bin/bash

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

.PHONY: deps
deps: images/fpm.conf images/opcache.ini images/xdebug.ini images/Caddyfile docker-compose.yml
DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker-compose build
deps: service/actor-http service/actor-service service/client-http service/client-service
@echo 'all done: run `make start` to get started'

.PHONY: service/actor-service
service/actor-service: images/opcache.ini images/fpm.conf
docker build --pull --build-arg SERVICE=actor -f ../images/service.Dockerfile --target production -t php-actor-service:${GIT_SHA} .

.PHONY: service/actor-http
service/actor-http: images/Caddyfile
docker build --pull --build-arg SERVICE=actor -f ../images/caddy.Dockerfile --target base -t php-actor-http:${GIT_SHA} .

.PHONY: service/client-service
service/client-service: images/opcache.ini images/opcache.ini
docker build --pull --build-arg SERVICE=client -f ../images/service.Dockerfile --target production -t php-client-service:${GIT_SHA} .

.PHONY: service/client-http
service/client-http: images/Caddyfile
docker build --pull --build-arg SERICE=client -f ../images/caddy.Dockerfile --target base -t php-client-http:${GIT_SHA} .

.PHONY: start
start:
Expand All @@ -18,11 +35,10 @@ stop:
.PHONY: clean
clean: stop
docker-compose -f docker-compose.yml -f ../docker-compose.common.yml rm -f
rm -rf images

.PHONY: push
push: deps
docker-compose push
.PHONY: logs
logs:
docker-compose -f docker-compose.yml -f ../docker-compose.common.yml logs

images/fpm.conf: ../images/fpm.conf
mkdir -p images
Expand Down
12 changes: 6 additions & 6 deletions examples/actor/composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "dapr/actor-example",
"license": "MIT",
"description": "A basic example demonstrating actors",
"require": {
"dapr/php-sdk": "^1.0"
}
"name": "dapr/actor-example",
"license": "MIT",
"description": "A basic example demonstrating actors",
"require": {
"dapr/php-sdk": "dev-add/psr-middleware"
}
}
Loading

0 comments on commit 8b6470f

Please sign in to comment.