Skip to content

Merge pull request #138 from AaronCrawfis/aacrawfi/docs-metadata #395

Merge pull request #138 from AaronCrawfis/aacrawfi/docs-metadata

Merge pull request #138 from AaronCrawfis/aacrawfi/docs-metadata #395

Workflow file for this run

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/setup-php@2.9.0
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/setup-php@2.9.0
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/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: 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/setup-php@2.9.0
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/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: 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