Skip to content

Commit

Permalink
Adds support for Laravel 9 (#28)
Browse files Browse the repository at this point in the history
- Update dependencies
- Update publish.yml
- Removes support for versions older than PHP 8.0
- Removes support for versions older than Laravel 9
  • Loading branch information
roquerodrigo authored May 19, 2022
1 parent 3c715a3 commit 5ed64a4
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PHP_VERSION="7.3"
ARG PHP_VERSION="8.1"

FROM php:${PHP_VERSION}-cli

Expand Down
34 changes: 12 additions & 22 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Unit Tests

on:
pull_request:
Expand All @@ -9,30 +9,20 @@ jobs:
build:
strategy:
matrix:
php: ["7.2", "7.3", "7.4", "8.0"]
php: [ "8.0", "8.1" ]
runs-on: ubuntu-latest
container: arquivei/laravel-prometheus-exporter:${{ matrix.php }}

steps:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v2

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install composer dependencies
run: composer install
php-version: ${{ matrix.php }}

- name: Run checks
run: php vendor/bin/phpunit
- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction

- name: Run checks in lower versions
run: |
composer update --prefer-lowest --prefer-dist --prefer-stable --no-interaction
php vendor/bin/phpunit
- name: PHPUnit
run: php vendor/bin/phpunit
24 changes: 0 additions & 24 deletions .github/workflows/publish.yml

This file was deleted.

22 changes: 5 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
PHP_VERSION ?= 7.3
PHP_VERSION ?= 8.1
PHP ?= bin/php -d "xdebug.mode=off"
COMPOSER ?= bin/composer

.PHONY: setup
setup:
DOCKER_BUILDKIT=1 docker build -f .docker/Dockerfile -t laravel-prometheus-exporter:7.2 --build-arg PHP_VERSION=7.2 .
DOCKER_BUILDKIT=1 docker build -f .docker/Dockerfile -t laravel-prometheus-exporter:7.3 --build-arg PHP_VERSION=7.3 .
DOCKER_BUILDKIT=1 docker build -f .docker/Dockerfile -t laravel-prometheus-exporter:7.4 --build-arg PHP_VERSION=7.4 .
DOCKER_BUILDKIT=1 docker build -f .docker/Dockerfile -t laravel-prometheus-exporter:8.0 --build-arg PHP_VERSION=8.0 .

.PHONY: publish
publish: publish-7.2 publish-7.3 publish-7.4 publish-8.0

.PHONY: publish-%
publish-%:
docker tag laravel-prometheus-exporter:${*} arquivei/laravel-prometheus-exporter:${*}
docker push arquivei/laravel-prometheus-exporter:${*}
DOCKER_BUILDKIT=1 docker build -f .docker/Dockerfile -t laravel-prometheus-exporter:8.1 --build-arg PHP_VERSION=8.1 .

.PHONY: vendor
vendor:
Expand All @@ -26,13 +16,11 @@ tests:
PHP_VERSION=$(PHP_VERSION) $(PHP) vendor/bin/phpunit

.PHONY: ci-local
ci-local: ci-local-7.2 ci-local-7.3 ci-local-7.4 ci-local-8.0
ci-local: ci-local-8.0 ci-local-8.1

.PHONY: ci-local-%
ci-local-%:
rm -rf composer.lock vendor/
rm -rf composer.lock vendor/ .phpunit.cache/

PHP_VERSION=${*} $(COMPOSER) install
PHP_VERSION=${*} $(PHP) vendor/bin/phpunit

PHP_VERSION=${*} $(COMPOSER) update --prefer-lowest --prefer-dist --prefer-stable --no-interaction
PHP_VERSION=${*} $(PHP) vendor/bin/phpunit
3 changes: 1 addition & 2 deletions bin/composer
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ USER=${USER:-$( id -un )}
GROUP=${GROUP:-$( id -gn )}
COMPOSER_HOME=${COMPOSER_HOME:-${HOME}/.composer}
DOCKER_OPTS=${DOCKER_OPTS:-'-it'}
PHP_VERSION=${PHP_VERSION:-7.3}
PHP_VERSION=${PHP_VERSION:-8.1}

exec docker run ${DOCKER_OPTS} --rm \
-u $( id -u ${USER} ):$( id -g ${USER} ) \
Expand All @@ -19,4 +19,3 @@ exec docker run ${DOCKER_OPTS} --rm \
--net=host --sig-proxy=true --pid=host \
--entrypoint="php" \
laravel-prometheus-exporter:"${PHP_VERSION}" -d "xdebug.mode=off" /usr/bin/composer "${@}"

3 changes: 1 addition & 2 deletions bin/php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ command -v docker >/dev/null 2>&1 || { echo "docker is required to run this bina
USER=${USER:-$( id -un )}
GROUP=${GROUP:-$( id -gn )}
DOCKER_OPTS=${DOCKER_OPTS:-'-it'}
PHP_VERSION=${PHP_VERSION:-7.3}
PHP_VERSION=${PHP_VERSION:-8.1}

exec docker run ${DOCKER_OPTS} --rm \
-u $( id -u ${USER} ):$( id -g ${USER} ) \
Expand All @@ -17,4 +17,3 @@ exec docker run ${DOCKER_OPTS} --rm \
--net=host --sig-proxy=true --pid=host \
--entrypoint="php" \
laravel-prometheus-exporter:"${PHP_VERSION}" "${@}"

63 changes: 33 additions & 30 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
{
"name": "arquivei/laravel-prometheus-exporter",
"description": "A Prometheus exporter for Laravel and Lumen",
"license": "MIT",
"authors": [
{
"name": "Arquivei"
}
],
"require": {
"php": "^7.2.5 || ^8.0",
"illuminate/support": "^6.0 || ^7.0 || ^8.0",
"illuminate/routing": "^6.0 || ^7.0 || ^8.0",
"promphp/prometheus_client_php": "^2.2.1",
"guzzlehttp/guzzle": "^6.3 || ^7.0"
},
"autoload": {
"psr-4": {
"Arquivei\\LaravelPrometheusExporter\\": "src/",
"Arquivei\\LaravelPrometheusExporter\\Tests\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"require-dev": {
"phpunit/phpunit": "^8.0 || ^9.0",
"mockery/mockery": "^1.3.3",
"orchestra/testbench": "^4.0 || ^5.0 || ^6.0"
"name": "arquivei/laravel-prometheus-exporter",
"description": "A Prometheus exporter for Laravel and Lumen",
"license": "MIT",
"authors": [
{
"name": "Arquivei"
}
],
"require": {
"php": "^8.0 || ^8.1",
"guzzlehttp/guzzle": "^7.4.2",
"illuminate/routing": "^9.0",
"illuminate/support": "^9.0",
"promphp/prometheus_client_php": "^2.6.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5.20",
"mockery/mockery": "^1.5.0",
"orchestra/testbench": "^7.5.0"
},
"autoload": {
"psr-4": {
"Arquivei\\LaravelPrometheusExporter\\": "src/",
"Arquivei\\LaravelPrometheusExporter\\Tests\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"config": {
"sort-packages": true
}
}
20 changes: 14 additions & 6 deletions tests/StorageAdapterFactoryTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

declare(strict_types = 1);
declare(strict_types=1);

namespace Arquivei\LaravelPrometheusExporter\Tests;

use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use Prometheus\Exception\StorageException;
use Prometheus\Storage\APC;
use Prometheus\Storage\InMemory;
use Prometheus\Storage\Redis;
Expand All @@ -21,31 +22,38 @@ class StorageAdapterFactoryTest extends TestCase
*/
private $factory;

public function setUp() : void
public function setUp(): void
{
parent::setUp();
$this->factory = new StorageAdapterFactory();
}

public function testMakeMemoryAdapter() : void
public function testMakeMemoryAdapter(): void
{
$adapter = $this->factory->make('memory');
$this->assertInstanceOf(InMemory::class, $adapter);
}

public function testMakeApcAdapter() : void
public function testMakeApcAdapter(): void
{
if (!extension_loaded('apcu')) {
$this->expectExceptionObject(new StorageException('APCu extension is not loaded'));
}
if (\function_exists('apcu_enabled') && !apcu_enabled()) {
$this->expectExceptionObject(new StorageException('APCu is not enabled'));
}

$adapter = $this->factory->make('apc');
$this->assertInstanceOf(APC::class, $adapter);
}

public function testMakeRedisAdapter() : void
public function testMakeRedisAdapter(): void
{
$adapter = $this->factory->make('redis');
$this->assertInstanceOf(Redis::class, $adapter);
}

public function testMakeInvalidAdapter() : void
public function testMakeInvalidAdapter(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('The driver [moo] is not supported.');
Expand Down

0 comments on commit 5ed64a4

Please sign in to comment.