Skip to content

Commit

Permalink
3.0.0 candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
vasa-c committed Mar 15, 2023
1 parent 6975f34 commit bb685c3
Show file tree
Hide file tree
Showing 84 changed files with 226 additions and 400 deletions.
14 changes: 2 additions & 12 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2

[*.{diff,md}]
trim_trailing_whitespace = false

[*.{php,xml,json}]
indent_size = 4
trim_trailing_whitespace = true
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Tests

on: push

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
php: [8.1, 8.2]

name: 'PHP ${{ matrix.php }}'
steps:
- uses: actions/checkout@master

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
tools: phpunit, composer:v2
ini-values: display_errors=E_ALL

- name: Install Composer dependencies
run: composer install

- name: Run tests
if: ${{ matrix.php != '8.2' }}
run: vendor/bin/phpunit -c phpunit.xml.dist

- name: Run tests with coverage
if: ${{ matrix.php == '8.2' }}
run: vendor/bin/phpunit --coverage-clover local/clover.xml

- name: Upload coverage results to Coveralls
if: ${{ matrix.php == '8.2' }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=local/clover.xml -v --json_path=local/clover.json
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
composer.lock
vendor
.idea
phpunit.xml
phpmd.xml
/vendor
/composer.lock
/phpunit.xml
/.idea
.phpunit.result.cache
/local
/format.json
65 changes: 0 additions & 65 deletions .travis.yml

This file was deleted.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### dev

* PHP 8.1
* Change structure and docker for development

### 2.1.0 (15.04.2022)

* #4: PHP 8.1 compatibility
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2013-2019 Oleg Grigoriev
Copyright (c) 2013-2023 Oleg Grigoriev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 3 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,11 @@
Helper for define exception classes (PHP).

[![Latest Stable Version](https://img.shields.io/packagist/v/axy/errors.svg?style=flat-square)](https://packagist.org/packages/axy/errors)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.1-8892BF.svg?style=flat-square)](https://php.net/)
[![Build Status](https://img.shields.io/travis/axypro/errors/master.svg?style=flat-square)](https://travis-ci.org/axypro/errors)
[![Coverage Status](https://coveralls.io/repos/axypro/errors/badge.svg?branch=master&service=github)](https://coveralls.io/github/axypro/errors?branch=master)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.1-8892BF.svg?style=flat-square)](https://php.net/)
[![Tests](https://github.com/axypro/errors/actions/workflows/test.yml/badge.svg)](https://github.com/axypro/errors/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/axypro/errors/badge.svg?branch=master)](https://coveralls.io/github/axypro/errors?branch=master)
[![License](https://poser.pugx.org/axy/errors/license)](LICENSE)

* The library does not require any dependencies (except composer packages).
* Tested on PHP 5.4+, PHP 7, HHVM (on Linux), PHP 5.5 (on Windows).
* Install: `composer require axy/errors`.
* License: [MIT](LICENSE).

### Legacy (PHP5.4+, branch php5)

[![Latest Stable Version](https://img.shields.io/packagist/v/axy/errors.svg?style=flat-square)](https://packagist.org/packages/axy/errors)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%205.4-8892BF.svg?style=flat-square)](https://php.net/)
[![Build Status](https://img.shields.io/travis/axypro/errors/php5.svg?style=flat-square)](https://travis-ci.org/axypro/errors)

* Install: `composer require axy/errors=^1.
* Tested on PHP 5.4+, PHP 7, HHVM (on Linux), PHP 5.5 (on Windows).

### Documentation

* [Common organization of exceptions](doc/org.md)
Expand Down
31 changes: 14 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,27 @@
}
],
"require": {
"php": ">=7.3",
"axy/backtrace": "~2.0.0"
"php": ">=8.1",
"axy/backtrace": "~3.0.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"squizlabs/php_codesniffer": "^3.4",
"phpmd/phpmd": "^2.6"
"phpunit/phpunit": "~10.0.15",
"squizlabs/php_codesniffer": "=3.7.1"
},
"autoload": {
"psr-4": {
"axy\\errors\\": "src/"
"axy\\errors\\": "src",
"axy\\errors\\tests\\": "tests"
}
},
"autoload-dev": {
"psr-4": {
"axy\\errors\\tests\\": "tests/"
}
},
"scripts": {
"test": "phpunit -c phpunit.xml.dist",
"md": "phpmd --exclude vendor . text phpmd.xml.dist",
"cs": "phpcs --standard=PSR2 --encoding=utf-8 --ignore=vendor ."
},
"archive": {
"exclude": ["/tests/*", "/doc/*", "/cs.sh", "/phpmd.sh", "/*.xml.dist", "/CHANGELOG.md"]
"exclude": [
"/tests/*",
"/devops/*",
"/doc/*",
"/*.sh",
"/*.xml.dist",
"/CHANGELOG.md"
]
}
}
8 changes: 8 additions & 0 deletions composer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
# Runs a composer command.
# Arguments and options are equal to composer ("./composer.sh --no-cache install" for example).
# Host script that executes internal script (inside docker container)

. $(dirname "$0")/docker/scripts/boot_host.sh

docker-compose run -T --rm php /bin/sh -c "/bin/sh /app/docker/scripts/composer.sh $*"
9 changes: 9 additions & 0 deletions coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
# Runs unit tests with coverage.
# Arguments and options are equal to phpunit.
# Without arguments runs all tests inside /tests/ directory.
# Host script that executes internal script (inside docker container)

. $(dirname "$0")/docker/scripts/boot_host.sh

docker-compose run --rm php /bin/sh -c "/bin/sh /app/docker/scripts/coverage.sh $*"
10 changes: 8 additions & 2 deletions cs.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#!/bin/bash
#!/usr/bin/env bash
# Checks code style.
# Arguments and options are equal to phpcs.
# Without arguments checks /src/ and /tests/ directories.
# Host script that executes internal script (inside docker container)

./vendor/bin/phpcs "$@"
. "$(dirname "$0")/docker/scripts/boot_host.sh"

docker-compose run -T --rm php /bin/sh /app/docker/scripts/cs.sh "$@"
1 change: 1 addition & 0 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
COMPOSE_PROJECT_NAME="axy_errors_test"
13 changes: 13 additions & 0 deletions docker/build/php/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM php:8.2.3-cli

RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

RUN apt-get update && apt-get install -y --no-install-recommends \
libzip-dev

RUN docker-php-ext-install \
zip

RUN pecl install xdebug-3.2.0 && docker-php-ext-enable xdebug

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
17 changes: 17 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3.8'

services:
php:
build:
context: ./build/php
restart: 'no'
profiles: ['console']
volumes:
- '..:/app:ro'
- '../vendor:/app/vendor'
- '../composer.lock:/app/composer.lock'
- '../local:/app/local'
user: "${USER_ID:-0}:${GROUP_ID:-0}"
working_dir: '/app'
environment:
XDEBUG_MODE: 'coverage'
27 changes: 27 additions & 0 deletions docker/scripts/boot_host.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Source for including from a host script
# Builds docker compose project and set the current directory to the compose root for docker-compose run

COMPOSE_PROJECT_NAME="axy_errors_test"
export COMPOSE_PROJECT_NAME

cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1;
CURRENT_DIR=$(pwd)
ROOT_DIR="$CURRENT_DIR/../.."

# Use this file owner as the user under which docker is running
USER_ID=$(stat -c '%u' "$CURRENT_DIR")
GROUP_ID=$(stat -c '%g' "$CURRENT_DIR")
export USER_ID
export GROUP_ID

# Create empty composer.lock if it isn't exists yet
# because docker will be mount it as not read-only and it will be created as directory
if [[ ! -e "$ROOT_DIR/composer.lock" ]]
then
echo "{}" > "$ROOT_DIR/composer.lock";
fi
mkdir -p "$ROOT_DIR/vendor" || exit 1
mkdir -p "$ROOT_DIR/local" || exit 1

cd "$CURRENT_DIR/.." && docker-compose build || exit 1
3 changes: 3 additions & 0 deletions docker/scripts/composer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Run composer command (runs inside container)

cd /app && composer "$@"
3 changes: 3 additions & 0 deletions docker/scripts/coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Run unit tests with coverage (runs inside container)

cd /app && composer install --no-cache && ./vendor/bin/phpunit --coverage-html local/coverage "$@"
3 changes: 3 additions & 0 deletions docker/scripts/cs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Run code sniffer (runs inside container)

cd /app && ./vendor/bin/phpcs "$@"
3 changes: 3 additions & 0 deletions docker/scripts/unit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Run unit tests (runs inside container)

cd /app && composer install --no-cache && ./vendor/bin/phpunit "$@"
18 changes: 18 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Helper for define exception classes
*
* @package axy\errors
* @author Oleg Grigoriev <go.vasac@gmail.com>
* @license https://raw.github.com/axypro/errors/master/LICENSE MIT
* @link https://github.com/axypro/errors repository
* @link https://github.com/axypro/errors/blob/master/README.md documentation
* @link https://packagist.org/packages/axy/errors composer
* @uses PHP8.1+
*/

declare(strict_types=1);

namespace axy\errors;

require_once __DIR__ . '/vendor/autoload.php';
12 changes: 4 additions & 8 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?xml version="1.0"?>
<ruleset name="Axypro Standard">
<file>./src</file>
<file>./tests</file>

<rule ref="PSR2"/>
<rule ref="PSR2.Namespaces.UseDeclaration">
<exclude-pattern>*</exclude-pattern>
</rule>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="phpcs.xsd">
<file>src</file>
<file>tests</file>
<rule ref="PSR12"/>
</ruleset>
10 changes: 0 additions & 10 deletions phpmd.sh

This file was deleted.

0 comments on commit bb685c3

Please sign in to comment.