Skip to content

Commit

Permalink
Merge pull request #157 from buggregator/feature/147
Browse files Browse the repository at this point in the history
Prometheus metrics support
  • Loading branch information
butschster committed Apr 30, 2024
2 parents 4cb258a + 850c601 commit a8f4eee
Show file tree
Hide file tree
Showing 144 changed files with 904 additions and 381 deletions.
1 change: 1 addition & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ ENV ENCRYPTER_KEY=def00000232ae92c8e8ec0699093fa06ce014cd48d39c3c62c279dd947db08
ENV TOKENIZER_CACHE_TARGETS=true
ENV AUTH_TOKEN_STORAGE=jwt
ENV AUTH_TOKEN_TRANSPORT=header
ENV METRICS_DRIVER=roadrunner

LABEL org.opencontainers.image.source=$REPOSITORY
LABEL org.opencontainers.image.description="Buggregator"
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
on:
pull_request: null
push:
branches:
- '*.*'

name: Code style

jobs:
cs:
uses: buggregator/gh-actions/.github/workflows/cs.yml@master
with:
os: >-
['ubuntu-latest']
21 changes: 0 additions & 21 deletions .github/workflows/phpunit-database.yml

This file was deleted.

72 changes: 58 additions & 14 deletions .github/workflows/phpunit-memory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,62 @@ on:

name: phpunit

env:
PERSISTENCE_DRIVER: memory

jobs:
phpunit-memory:
uses: spiral/gh-actions/.github/workflows/phpunit.yml@master
with:
extensions: >-
['sockets', 'mongodb', 'pgsql', 'pdo_pgsql', 'pdo_mysql']
os: >-
['ubuntu-latest']
php: >-
['8.3']
stability: >-
['prefer-stable']
phpunit:
name: "[In memory] PHP 8.3-${{ matrix.os }}, ${{ matrix.stability }}"
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
php: [ '8.3' ]
os: [ 'ubuntu-latest' ]
stability: [ 'prefer-stable' ]

steps:
# General Steps
- name: Set Git To Use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v3

- name: Configure environment
run: |
export COMPOSER_ROOT_VERSION=$(/usr/bin/jq --null-input --raw-output 'first(inputs["extra"]["branch-alias"])[]' composer.json)
echo COMPOSER_ROOT_VERSION=$COMPOSER_ROOT_VERSION >> $GITHUB_ENV
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: sockets,mongodb,pgsql,pdo_pgsql,pdo_mysql
tools: pecl

- name: Validate Composer
run: composer validate

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Restore Composer Cache
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer

- name: Install Dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

- name: Execute Tests
run: vendor/bin/phpunit
env:
PERSISTENCE_DRIVER: memory
82 changes: 82 additions & 0 deletions .github/workflows/phpunit-mongo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
on:
pull_request: null

name: phpunit

jobs:
phpunit:
name: "[Mongo DB] PHP 8.3-${{ matrix.os }}, ${{ matrix.stability }}"
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
php: [ '8.3' ]
os: [ 'ubuntu-latest' ]
stability: [ 'prefer-stable' ]

services:
mongodb:
image: mongo
env:
MONGO_INITDB_ROOT_USERNAME: mongo
MONGO_INITDB_ROOT_PASSWORD: secret
MONGO_INITDB_DATABASE: buggregator
ports:
- 27017:27017
# options: >-
# --health-cmd mongo
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5

steps:
# General Steps
- name: Set Git To Use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v3

- name: Configure environment
run: |
export COMPOSER_ROOT_VERSION=$(/usr/bin/jq --null-input --raw-output 'first(inputs["extra"]["branch-alias"])[]' composer.json)
echo COMPOSER_ROOT_VERSION=$COMPOSER_ROOT_VERSION >> $GITHUB_ENV
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: sockets,mongodb,pgsql,pdo_pgsql,pdo_mysql
tools: pecl

- name: Validate Composer
run: composer validate

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Restore Composer Cache
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer

- name: Install Dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

# Execution mongo
- name: Execute Tests on Mongo
run: vendor/bin/phpunit
env:
PERSISTENCE_DRIVER: mongodb
MONGODB_CONNECTION: mongodb://mongo:secret@127.0.0.1:27017
MONGODB_DATABASE: buggregator
88 changes: 88 additions & 0 deletions .github/workflows/phpunit-mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
on:
pull_request: null

name: phpunit

jobs:
phpunit:
name: "[MySQL:${{ matrix.mysql-version }}] PHP 8.3-${{ matrix.os }}, ${{ matrix.stability }}"
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
php: [ '8.3' ]
os: [ 'ubuntu-latest' ]
stability: [ 'prefer-stable' ]
mysql-version: [ '5', '8' ]

services:
mysql:
image: mysql:${{ matrix.mysql-version }}
env:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: buggregator
MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping -ppass"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
steps:
# General Steps
- name: Set Git To Use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v3

- name: Configure environment
run: |
export COMPOSER_ROOT_VERSION=$(/usr/bin/jq --null-input --raw-output 'first(inputs["extra"]["branch-alias"])[]' composer.json)
echo COMPOSER_ROOT_VERSION=$COMPOSER_ROOT_VERSION >> $GITHUB_ENV
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: sockets,mongodb,pgsql,pdo_pgsql,pdo_mysql
tools: pecl

- name: Validate Composer
run: composer validate

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Restore Composer Cache
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer

- name: Install Dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

# Execution mysql
- name: Execute Tests on MySQL
run: vendor/bin/phpunit
env:
PERSISTENCE_DRIVER: db
DB_DRIVER: mysql
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_DATABASE: buggregator
DB_USERNAME: root
DB_PASSWORD: secret
86 changes: 86 additions & 0 deletions .github/workflows/phpunit-pgsql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
on:
pull_request: null

name: phpunit

jobs:
phpunit:
name: "[Postgres:${{ matrix.pgsql-version }}] PHP 8.3-${{ matrix.os }}, ${{ matrix.stability }}"
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
php: [ '8.3' ]
os: [ 'ubuntu-latest' ]
stability: [ 'prefer-stable' ]
pgsql-version: [ '14','15','16' ]

services:
postgres:
image: postgres:${{ matrix.pgsql-version }}
env:
POSTGRES_PASSWORD: secret
POSTGRES_DB: buggregator
ports:
- 15432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
# General Steps
- name: Set Git To Use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v3

- name: Configure environment
run: |
export COMPOSER_ROOT_VERSION=$(/usr/bin/jq --null-input --raw-output 'first(inputs["extra"]["branch-alias"])[]' composer.json)
echo COMPOSER_ROOT_VERSION=$COMPOSER_ROOT_VERSION >> $GITHUB_ENV
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: sockets,mongodb,pgsql,pdo_pgsql,pdo_mysql
tools: pecl

- name: Validate Composer
run: composer validate

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Restore Composer Cache
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer

- name: Install Dependencies
uses: nick-invision/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress

# Execution pgsql
- name: Execute Tests on Postgres
run: vendor/bin/phpunit
env:
PERSISTENCE_DRIVER: db
DB_DRIVER: pgsql
DB_HOST: 127.0.0.1
DB_PORT: 15432
DB_DATABASE: buggregator
DB_USERNAME: postgres
DB_PASSWORD: secret
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ protoc-gen-php-grpc*
.php-cs-fixer.cache
.deptrac.cache
.phpunit.cache
build
.cache
Loading

0 comments on commit a8f4eee

Please sign in to comment.