Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.git/
.github/
.idea/
.vscode/
build/
vendor/
*.md
.env
.env.*
.phpunit.result.cache
79 changes: 39 additions & 40 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,52 @@
name: Pipeline
name: CI

on: [push, pull_request]

permissions:
contents: read

jobs:
run:
test:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['7.3', '7.4', '8.0']
name: PHP ${{ matrix.php-versions }}
php: ['8.2', '8.3', '8.4', '8.5']
steps:
- name: Checkout
uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring
coverage: pcov
- name: Build image
run: make PHP=${{ matrix.php }} build-svc

- name: Composer install
run: make PHP=${{ matrix.php }} install

- name: Lint
run: make PHP=${{ matrix.php }} lint

- name: Tests
run: make PHP=${{ matrix.php }} test

coverage:
name: Coverage
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4

- name: Build image
run: make PHP=8.4 build-svc

- name: Validate composer.json
run: composer validate
- name: Composer install
run: make PHP=8.4 install

- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Run tests with coverage
run: make PHP=8.4 test-coverage

- name: Cache dependencies
uses: actions/cache@v1
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --no-progress -o

- name: Check syntax
run: |
php -l src/
vendor/bin/phpcs --standard=psr2 --ignore=Tests src/

- name: Run tests
run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml

- name: Upload coverage results to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=build/logs/clover.xml -v
name: clover-coverage
path: build/logs/clover.xml
if-no-files-found: error
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/vendor/
/.phpunit.result.cache
/composer.lock
/build/
45 changes: 45 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
PHP ?= 8.4
SERVICE := php$(subst .,,$(PHP))
COMPOSE := $(shell docker compose version >/dev/null 2>&1 && echo "docker compose" || echo "docker-compose")
DC := $(COMPOSE) run --rm $(SERVICE)

.PHONY: build build-svc install update test test-coverage lint lint-fix analyse ci ci-full shell matrix clean

build:
$(COMPOSE) build

build-svc:
$(COMPOSE) build $(SERVICE)

install:
$(DC) composer install

update:
$(DC) composer update

test:
$(DC) vendor/bin/phpunit

test-coverage:
$(DC) vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml

lint:
$(DC) vendor/bin/phpcs --standard=psr2 --ignore=Tests src/

lint-fix:
$(DC) vendor/bin/phpcbf --standard=psr2 --ignore=Tests src/

analyse:
$(DC) vendor/bin/phpstan analyse --level=8 src/

ci: lint test
ci-full: lint analyse test

shell:
$(DC) bash

matrix:
@printf '8.2\n8.3\n8.4\n8.5\n' | xargs -n1 -P4 -I{} $(MAKE) PHP={} install ci

clean:
$(COMPOSE) down -v
55 changes: 55 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
services:
php82:
build:
context: .
dockerfile: docker/Dockerfile
args:
PHP_VERSION: '8.2'
working_dir: /app
volumes:
- .:/app
- composer-cache:/tmp/composer
- vendor-82:/app/vendor

php83:
build:
context: .
dockerfile: docker/Dockerfile
args:
PHP_VERSION: '8.3'
working_dir: /app
volumes:
- .:/app
- composer-cache:/tmp/composer
- vendor-83:/app/vendor

php84:
build:
context: .
dockerfile: docker/Dockerfile
args:
PHP_VERSION: '8.4'
working_dir: /app
volumes:
- .:/app
- composer-cache:/tmp/composer
- vendor-84:/app/vendor

php85:
build:
context: .
dockerfile: docker/Dockerfile
args:
PHP_VERSION: '8.5'
working_dir: /app
volumes:
- .:/app
- composer-cache:/tmp/composer
- vendor-85:/app/vendor

volumes:
composer-cache:
vendor-82:
vendor-83:
vendor-84:
vendor-85:
84 changes: 42 additions & 42 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
{
"name": "maxbanton/cwh",
"homepage": "https://github.com/maxbanton/cwh",
"type": "library",
"description": "AWS CloudWatch Handler for Monolog library",
"keywords": [
"aws",
"cloudwatch",
"monolog"
],
"license": "MIT",
"authors": [
{
"name": "Max Leonov",
"email": "hi@maxleonov.pw",
"homepage": "https://maxleonov.pw"
}
],
"support": {
"issues": "https://github.com/maxbanton/cwh/issues",
"source": "https://github.com/maxbanton/cwh"
},
"require": {
"php": "^7.2 || ^8",
"monolog/monolog": "^2.0",
"aws/aws-sdk-php": "^3.18"
},
"require-dev": {
"phpunit/phpunit": "^8.5 || ^9.4",
"squizlabs/php_codesniffer": "^3.5"
},
"suggest": {
"maxbanton/dd": "Minimalistic dump-and-die function for easy debugging"
},
"config": {
"preferred-install": "dist"
},
"autoload": {
"psr-4": {
"Maxbanton\\Cwh\\": "src"
}
},
"minimum-stability": "stable"
"name": "maxbanton/cwh",
"homepage": "https://github.com/maxbanton/cwh",
"type": "library",
"description": "AWS CloudWatch Handler for Monolog library",
"keywords": [
"aws",
"cloudwatch",
"monolog"
],
"license": "MIT",
"authors": [
{
"name": "Maksym Leonov",
"email": "ruses_entails4f@icloud.com",
"homepage": "https://maxbanton.github.io"
}
],
"support": {
"issues": "https://github.com/maxbanton/cwh/issues",
"source": "https://github.com/maxbanton/cwh"
},
"require": {
"php": "^7.2 || ^8",
"monolog/monolog": "^2.0",
"aws/aws-sdk-php": "^3.18"
},
"require-dev": {
"phpunit/phpunit": "^8.5 || ^9.4",
"squizlabs/php_codesniffer": "^3.5"
},
"suggest": {
"maxbanton/dd": "Minimalistic dump-and-die function for easy debugging"
},
"config": {
"preferred-install": "dist"
},
"autoload": {
"psr-4": {
"Maxbanton\\Cwh\\": "src"
}
},
"minimum-stability": "stable"
}
17 changes: 17 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ARG PHP_VERSION=8.4
FROM php:${PHP_VERSION}-cli

RUN apt-get update \
&& apt-get install -y --no-install-recommends git unzip \
&& pecl install pcov \
&& docker-php-ext-enable pcov \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

ENV COMPOSER_HOME=/tmp/composer \
COMPOSER_ALLOW_SUPERUSER=1 \
COMPOSER_NO_INTERACTION=1

WORKDIR /app
Loading