Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpetri committed Mar 21, 2023
0 parents commit 0f35f49
Show file tree
Hide file tree
Showing 22 changed files with 7,284 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: daily
time: "04:00"
open-pull-requests-limit: 10
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

name: "Continuous Integration"

on:
pull_request:
push:

jobs:
matrix:
name: Generate job matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Gather CI configuration
id: matrix
uses: laminas/laminas-ci-matrix-action@v1

qa:
name: QA Checks
needs: [matrix]
runs-on: ${{ matrix.operatingSystem }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.matrix.outputs.matrix) }}
steps:
- name: ${{ matrix.name }}
uses: laminas/laminas-continuous-integration-action@v1
with:
job: ${{ matrix.job }}
23 changes: 23 additions & 0 deletions .github/workflows/merge-dependabot-upgrades.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://github.com/ridedott/merge-me-action/
# This workflow automates merges from patches sent by Dependabot, and
# only by dependabot, once the other CI workflows pass
name: Auto-merge Dependabot PRs

on:
workflow_run:
types:
- completed
workflows:
- "Continuous Integration"

jobs:
merge-me:
name: Auto-merge Dependabot PRs
runs-on: ubuntu-latest
steps:
- name: Auto-Merge
if: ${{ github.event.workflow_run.conclusion == 'success' }}
uses: ridedott/merge-me-action@v2.9.54
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MERGE_METHOD: MERGE
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vendor
.phpunit.result.cache
.php-cs-fixer.cache
.idea
14 changes: 14 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in([
__DIR__ . '/src',
__DIR__ . '/tests'
]);

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
'no_unused_imports' => true,
])
->setFinder($finder);
87 changes: 87 additions & 0 deletions CONTRIBUTE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Contributing

Contributions are welcome. I accept merge requests on [GitHub][].
This project follows semantic versioning and the [semantic branching model][].

## Communication Channels

You can find help and discussion in the following places:

- [GitHub Issues][issues]

## Reporting Bugs

Bugs get tracked in the project's [issue tracker][issues].

When submitting a bug report, please include enough information to reproduce the
bug. A good bug report includes the following sections:

- Given input
- Expected output
- Actual output
- Steps to reproduce, including sample code
- Any other information that will help debug and reproduce the issue, including
stack traces, system/environment information, screenshots or at best a
merge request with a test scenario which proofs the error.

## Fixing Bugs

I welcome merge requests to fix bugs!

If you see a bug report that you'd like to fix, please feel free to do so.
See the [bug fixes][] section of the [semantic branching model][] documentation.

## Adding New Features

If you have an idea for a new feature, it's a good idea to check out the
[issues][] or active [merge requests][] first to see if the feature has already
requested and being worked on. If not, feel free to submit an issue first, asking
whether the feature is beneficial to the project. This will save you from doing a
lot of development work only to have your feature rejected. I don't enjoy rejecting
your hard work, but some features just don't fit with the goals of the project.

When you do begin working on your feature, here are some guidelines to consider:

- Check the [branch semantics][] section of the [semantic branching model][] documentation.
- Your merge request description should clearly detail the changes you have made.
I will use this description to update the CHANGELOG. If there is no
description, or it does not adequately describe your feature, I will ask you
to update the description.
- This package follows the **[PSR-12 coding standard][psr-12]**. Please
ensure your code does, too.
- Please **write tests** for any new features you add.
- Please **ensure that tests pass** before submitting your merge request.
This package has automatically running tests for merge requests.
However, running the tests locally will help save time.
- Use **feature/{issue-id}.** branches. Please do not ask to merge from your master
branch.
- **Submit one feature per merge request.** If you have multiple features you
wish to submit, please break them up into separate merge requests.
- **Write good commit messages.** Make sure each individual commit in your merge
request is meaningful. If you had to make multiple intermediate commits while
developing, please squash them before submitting.


## Running Tests and Linters

This project contains a composer wrapper script which can be executed with `./composerw` which requires docker.

The following must pass before I will accept a merge request. If this does not
pass, it will result in a complete build failure. Before you can run this, be
sure to `./composerw install`.

To run all the tests and coding standards checks, execute the following from the
command line, while in the project root directory:

```
./composerw lint
./composerw test
```

[GitHub]: https://github.com/michaelpetri/symfony-file-watcher
[issues]: https://github.com/michaelpetri/symfony-file-watcher/issues
[bug fixes]: https://dev-cafe.github.io/branching-model#bugfixes
[branch semantics]: https://dev-cafe.github.io/branching-model/#branch-semantics
[merge reqeusts]: https://github.com/michaelpetri/symfony-file-watcher/compare
[semantic branching model]: https://dev-cafe.github.io/branching-model
[psr-12]: https://www.php-fig.org/psr/psr-12/
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ARG PHP_VERSION
FROM php:${PHP_VERSION}-cli-alpine3.16

# Better extension installer
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions

# Install composer
COPY --from=composer:2.4.2 /usr/bin/composer /usr/bin/composer

# Install development tools
RUN apk add --no-cache \
bash \
make \
unzip \
git \
&& install-php-extensions \
xdebug
22 changes: 22 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2023 Michael Petri

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
a
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Symfony File Watcher

[![Type Coverage](https://shepherd.dev/github/michaelpetri/symfony-file-watcher/coverage.svg)](https://shepherd.dev/github/michaelpetri/symfony-file-watcher)
[![Latest Stable Version](https://poser.pugx.org/michaelpetri/symfony-file-watcher/v)](https://packagist.org/packages/michaelpetri/symfony-file-watcher)
[![License](https://poser.pugx.org/michaelpetri/symfony-file-watcher/license)](https://packagist.org/packages/michaelpetri/symfony-file-watcher)

This package contains a file watcher based on [symfony/messenger](https://github.com/symfony/messenger) and [michaelpetri/php-git](https://github.com/michaelpetri/php-git).

Since it is based on git it can emmit events for files even after it has been paused for a decent time. All changes will
trigger a `FileCreated`, `FileChanged` or `FileDeleted` event which then can be handled by an event handler.

> **Note:**
> Keep in mind that git is not good at handling binary files and using this package can lead to bloated disk usage!
## Installation:
```
composer require michaelpetri/symfony-file-watcher
```

## Usage:

```yaml
# messenger.yaml
transports:
my-file-watcher:
dsn: 'file-watcher:///absolute/path/to/files'
```

```shell
bin/console messenger:setup
bin/console messenger:consume my-file-watcher
```

## Sponsor:

[![Lyska.cloud](https://avatars.githubusercontent.com/u/82085619?s=400&u=bf1fb2d6dec05e5911a190964568903b7a795592&v=4)](https://lyska.cloud)

We are on a mission to streamline B2B purchasing processes. By simplifying and speed up sales, using cutting-edge technology and process automation.
56 changes: 56 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "michaelpetri/symfony-file-watcher",
"description": "Symfony Message Receiver to receive filesystem events.",
"authors": [
{
"name": "Michael Petri",
"email": "mpetri@lyska.io"
}
],
"license": "MIT",
"require": {
"php": "~8.1.0 || ~8.2.0",
"symfony/messenger": "^6.2.7",
"symfony/process": "^6.2.7",
"michaelpetri/php-generic-list": "^0.1.1",
"symfony/dependency-injection": "^6.2.7",
"symfony/framework-bundle": "^6.2.7",
"michaelpetri/php-git": "^0.2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.15.1",
"phpunit/phpunit": "^9.6.5",
"roave/security-advisories": "dev-latest",
"vimeo/psalm": "^4.30"
},
"autoload": {
"psr-4": {
"MichaelPetri\\SymfonyFileWatcher\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\MichaelPetri\\SymfonyFileWatcher\\": "tests/"
}
},
"scripts": {
"lint": [
"@validate",
"@psalm",
"@php-cs-fix",
"@security"
],
"test": [
"@phpunit"
],
"psalm": "vendor/bin/psalm --no-progress",
"psalm-cache-clear": "vendor/bin/psalm --clear-cache",
"psalm-baseline": "vendor/bin/psalm --update-baseline",
"psalm-reset-baseline": "vendor/bin/psalm --set-baseline=psalm-baseline.xml",
"php-cs-fix": "PHP_CS_FIXER_FUTURE_MODE=1 vendor/bin/php-cs-fixer fix --allow-risky=yes",
"security": "composer update --dry-run roave/security-advisories",
"phpunit": "vendor/bin/phpunit --testdox --order-by=random",
"phpunit-coverage-report": "vendor/bin/phpunit --coverage-html=.phpunit-coverage-report",
"bash": "bash"
}
}

0 comments on commit 0f35f49

Please sign in to comment.