Skip to content

Commit

Permalink
Make private library public
Browse files Browse the repository at this point in the history
  • Loading branch information
MortalFlesh committed Mar 20, 2022
1 parent 4725805 commit 28887dc
Show file tree
Hide file tree
Showing 20 changed files with 859 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .github/config/yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
extends: default

# documentation: https://yamllint.readthedocs.io/en/stable/rules.html

rules:
# 300 chars should be enough, but don't fail if a line is longer
line-length:
max: 300
level: warning

# don't bother me with this rule
braces: disable
brackets: disable
colons: disable
document-start: disable
hyphens: disable
40 changes: 40 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Checks

on:
#push:
pull_request:
#schedule:
# - cron: '0 3 * * *'

jobs:
markdown-link-check: # https://github.com/gaurav-nelson/github-action-markdown-link-check
name: "Markdown link check"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-verbose-mode: 'yes'

shellcheck: # https://github.com/marketplace/actions/shellcheck
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
env:
SHELLCHECK_OPTS: -e SC1090

yamllint: # https://github.com/marketplace/actions/yamllint-github-action
name: 'Yamllint'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: 'Yamllint'
uses: karancode/yamllint-github-action@master
with:
yamllint_file_or_dir: '.'
yamllint_config_filepath: '.github/config/yamllint.yaml'
yamllint_strict: false
yamllint_comment: false
35 changes: 35 additions & 0 deletions .github/workflows/php-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: PHP - Checks

on:
#push:
pull_request:
#schedule:
# - cron: '0 3 * * *'

jobs:
checks:
runs-on: ubuntu-latest
name: PHP 7.4 - checks
steps:
# Setup
- uses: actions/checkout@v2

- name: '[PHP] Setup'
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: mbstring, intl

# Prepare application
- name: '[INIT] Check composer.json'
run: composer validate --no-check-all --no-check-publish --no-check-lock

- name: '[INIT] Install dependencies'
run: composer update --prefer-dist --no-progress

# Check application
- name: '[CHECK] codestyle'
run: composer cs

- name: '[CHECK] phpstan'
run: composer phpstan
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vendor/
composer.lock

tools/*/vendor
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

<!-- There should always be "Unreleased" section at the beginning. -->

## Unreleased

## 5.0.0 - 2022-03-20
- Make private library public
61 changes: 60 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,61 @@
# deb-build
Debian package build
====================

Build deb package of PHP application using [Robo](http://robo.li/) task runner.


# How to install and use

First install this package as composer dependency:

```sh
composer require vysokeskoly/deb-build:dev-master
```

- *NOTE* it must NOT be installed as `--dev` dependency, as it is needed for `postinst` which is triggered on during installation on target server.

Then you can copy example `RoboFile.php`:

```sh
cd {YOUR_PROJECT}
cp vendor/vysokeskoly/deb-build/example/RoboFile.php ./RoboFile.php
```

Now just edit `RoboFile.php` and resolve all `TODOs` and check/edit other configuration.

## Autoloading

- You can require `Tasks` and `Traits` in your own `RoboFile.php`.
- Or you can use the predefined autoloader:
```php
require __DIR__ . '/vendor/vysokeskoly/deb-build/src/autoload.php';
```
- It is not recommended (though it may be possible in some cases) to use `vendor/autoload.php` of your application,
because it may (and most probably will) conflict with `robo.phar` inner dependencies (_like `Symfony`_).

# Build a deb package

## Build by Robo on Jenkins

```sh
wget https://github.com/vysokeskoly/robo-mirror/raw/master/robo.phar
php robo.phar build:deb
```


## Build locally (_vagrant_) - test purposes only

```sh
sudo apt-get install ruby-dev gcc make
sudo gem install fpm
```

then build Robo as on jenkins (`BUILD_NUMBER` could be any number):

```sh
sudo /bin/bash
wget https://github.com/vysokeskoly/robo-mirror/raw/master/robo.phar

export BUILD_NUMBER=666
php robo.phar build:deb
```
50 changes: 50 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "vysokeskoly/deb-build",
"description": "Utilities for building deb packages of PHP apps",
"autoload": {
"psr-4": {
"VysokeSkoly\\Build\\": "src/Build/"
}
},
"require": {
"php": "^7.4",
"ext-dom": "*",
"ext-json": "*",
"ext-mbstring": "*",
"consolidation/robo": "^3"
},
"require-dev": {
"phpstan/phpstan": "^1.4",
"phpstan/extension-installer": "^1.1"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"scripts": {
"post-install-cmd": [
"@installTools"
],
"post-update-cmd": [
"@updateTools"
],
"installTools": [
"cd tools/coding-standards && composer install && composer link"
],
"updateTools": [
"cd tools/coding-standards && composer update && composer link"
],
"all": [
"@analyze"
],
"analyze": [
"@cs",
"@phpstan"
],
"cs": "vendor/bin/ecs check --ansi -- src/ ecs.php",
"phpstan": "vendor/bin/phpstan analyze ./src -c phpstan.neon --ansi --level 8",
"fix": "vendor/bin/ecs check src/ ecs.php --ansi --fix"
}
}
18 changes: 18 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;

return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();

$parameters->set(
Option::SKIP,
[
'PHP_CodeSniffer\Standards\Generic\Sniffs\Commenting\DocCommentSniff' => null,
]
);

$containerConfigurator->import(__DIR__ . '/tools/coding-standards/vendor/lmc/coding-standard/ecs.php');
$containerConfigurator->import(__DIR__ . '/tools/coding-standards/vendor/lmc/coding-standard/ecs-7.4.php');
};
Loading

0 comments on commit 28887dc

Please sign in to comment.