Skip to content

Commit fde1000

Browse files
authored
Merge pull request #2 from reactphp-parallel/initial-code
Add Initial code
2 parents ddfe6d4 + 089dc26 commit fde1000

42 files changed

Lines changed: 9252 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 4
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
10+
[*.json]
11+
indent_size = 2
12+
13+
[Makefile]
14+
indent_style = tab

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Ignoring files for distribution archieves
2+
examples/ export-ignore
3+
tests/ export-ignore
4+
.dunitconfig export-ignore
5+
.travis.yml export-ignore
6+
.gitignore export-ignore
7+
.gitattributes export-ignore
8+
.scrutinizer.yml export-ignore
9+
.styleci.yml export-ignore
10+
appveyor.yml export-ignore
11+
phpunit.xml.dist export-ignore

.github/workflows/ci.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Continuous Integration
2+
on:
3+
push:
4+
pull_request:
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Lint Code Base
10+
uses: docker://github/super-linter:v2.2.0
11+
composer-install:
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
php: [7.4]
16+
composer: [lowest, current, highest]
17+
needs: lint
18+
runs-on: ubuntu-latest
19+
container:
20+
image: wyrihaximusnet/php:${{ matrix.php }}-zts-alpine3.11-dev-root
21+
steps:
22+
- uses: actions/checkout@v1
23+
- name: Cache composer packages
24+
uses: actions/cache@v1
25+
with:
26+
path: ./vendor/
27+
key: ${{ matrix.composer }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
28+
- name: Install Dependencies
29+
run: composer update --prefer-lowest --no-progress --ansi --no-interaction --prefer-dist -o
30+
if: matrix.composer == 'lowest'
31+
- name: Install Dependencies
32+
run: composer install --ansi --no-progress --no-interaction --prefer-dist -o
33+
if: matrix.composer == 'current'
34+
- name: Install Dependencies
35+
run: composer update --ansi --no-progress --no-interaction --prefer-dist -o
36+
if: matrix.composer == 'highest'
37+
qa:
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
php: [7.4]
42+
composer: [lowest, current, highest]
43+
qa: [lint, cs, stan, psalm, unit-ci, infection, composer-require-checker, composer-unused, backward-compatibility-check]
44+
needs: composer-install
45+
runs-on: ubuntu-latest
46+
container:
47+
image: wyrihaximusnet/php:${{ matrix.php }}-zts-alpine3.11-dev-root
48+
steps:
49+
- uses: actions/checkout@v1
50+
- name: Cache composer packages
51+
uses: actions/cache@v1
52+
with:
53+
path: ./vendor/
54+
key: ${{ matrix.composer }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
55+
- name: Install Dependencies
56+
run: (test -f vendor && true ) || composer update --prefer-lowest --no-progress --ansi --no-interaction --prefer-dist -o
57+
if: matrix.composer == 'lowest'
58+
- name: Install Dependencies
59+
run: (test -f vendor && true ) || composer install --ansi --no-progress --no-interaction --prefer-dist -o
60+
if: matrix.composer == 'current'
61+
- name: Install Dependencies
62+
run: (test -f vendor && true ) || composer update --ansi --no-progress --no-interaction --prefer-dist -o
63+
if: matrix.composer == 'highest'
64+
- name: Fetch Tags
65+
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
66+
if: matrix.qa == 'backward-compatibility-check'
67+
- run: make ${{ matrix.qa }}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Create Release
2+
env:
3+
MILESTONE: ${{ github.event.milestone.title }}
4+
on:
5+
milestone:
6+
types:
7+
- closed
8+
jobs:
9+
generate-changelog:
10+
name: Generate Changelog
11+
runs-on: ubuntu-latest
12+
outputs:
13+
changelog: ${{ steps.changelog.outputs.changelog }}
14+
steps:
15+
- name: Generate changelog
16+
uses: WyriHaximus/github-action-jwage-changelog-generator@v1
17+
id: changelog
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
with:
21+
milestone: ${{ env.MILESTONE }}
22+
- name: Show changelog
23+
run: echo "${CHANGELOG}"
24+
env:
25+
CHANGELOG: ${{ steps.changelog.outputs.changelog }}
26+
create-release:
27+
name: Create Release
28+
needs:
29+
- generate-changelog
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v1
33+
env:
34+
CHANGELOG: ${{ needs.generate-changelog.outputs.changelog }}
35+
- run: |
36+
echo -e "${MILESTONE_DESCRIPTION}\r\n\r\n${CHANGELOG}" > release-${{ env.MILESTONE }}-release-message.md
37+
cat release-${{ env.MILESTONE }}-release-message.md
38+
release_message=$(cat release-${{ env.MILESTONE }}-release-message.md)
39+
release_message="${release_message//'%'/'%25'}"
40+
release_message="${release_message//$'\n'/'%0A'}"
41+
release_message="${release_message//$'\r'/'%0D'}"
42+
echo "::set-output name=release_message::$release_message"
43+
id: releasemessage
44+
env:
45+
MILESTONE_DESCRIPTION: ${{ github.event.milestone.description }}
46+
CHANGELOG: ${{ needs.generate-changelog.outputs.changelog }}
47+
- name: Create Reference Release with Changelog
48+
uses: fleskesvor/create-release@feature/support-target-commitish
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
with:
52+
tag_name: ${{ env.MILESTONE }}
53+
release_name: ${{ env.MILESTONE }}
54+
body: ${{ steps.releasemessage.outputs.release_message }}
55+
draft: false
56+
prerelease: false
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Label sponsors ❤️
2+
on:
3+
pull_request:
4+
types:
5+
- opened
6+
issues:
7+
types:
8+
- opened
9+
jobs:
10+
sponsor-label:
11+
name: Label sponsors ❤️
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: JasonEtco/is-sponsor-label-action@v1
15+
with:
16+
label: Sponsor Request ❤️
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Set Milestone
2+
on:
3+
pull_request:
4+
types:
5+
- assigned
6+
- opened
7+
- synchronize
8+
- reopened
9+
- edited
10+
- ready_for_review
11+
- review_requested
12+
jobs:
13+
set-milestone:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v1
17+
if: github.event.pull_request.milestone == null
18+
- name: 'Get Previous tag'
19+
if: github.event.pull_request.milestone == null
20+
id: previoustag
21+
uses: "WyriHaximus/github-action-get-previous-tag@master"
22+
env:
23+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
24+
- name: 'Get next minor version'
25+
if: github.event.pull_request.milestone == null
26+
id: semvers
27+
uses: "WyriHaximus/github-action-next-semvers@master"
28+
with:
29+
version: ${{ steps.previoustag.outputs.tag }}
30+
- name: 'Get Milestones'
31+
if: github.event.pull_request.milestone == null
32+
uses: "WyriHaximus/github-action-get-milestones@master"
33+
id: milestones
34+
env:
35+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
36+
- run: printf "::set-output name=number::%s" $(printenv MILESTONES | jq --arg MILESTONE $(printenv MILESTONE) '.[] | select(.title == $MILESTONE) | .number')
37+
if: github.event.pull_request.milestone == null
38+
id: querymilestone
39+
env:
40+
MILESTONES: ${{ steps.milestones.outputs.milestones }}
41+
MILESTONE: ${{ steps.semvers.outputs.minor }}
42+
- name: 'Create Milestone'
43+
if: github.event.pull_request.milestone == null && steps.querymilestone.outputs.number == ''
44+
id: createmilestone
45+
uses: "WyriHaximus/github-action-create-milestone@master"
46+
with:
47+
title: ${{ steps.semvers.outputs.minor }}
48+
env:
49+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
50+
- name: 'Select found or created Milestone'
51+
if: github.event.pull_request.milestone == null
52+
id: selectmilestone
53+
run: |
54+
if [ $(echo ${QUERY_NUMBER} | wc -c) -eq 1 ] ; then
55+
printf "::set-output name=number::%s" "${CREATED_NUMBER}"
56+
exit 0
57+
fi
58+
59+
printf "::set-output name=number::%s" "${QUERY_NUMBER}"
60+
env:
61+
CREATED_NUMBER: ${{ steps.createmilestone.outputs.number }}
62+
QUERY_NUMBER: ${{ steps.querymilestone.outputs.number }}
63+
- name: 'Set Milestone'
64+
if: github.event.pull_request.milestone == null
65+
uses: "WyriHaximus/github-action-set-milestone@master"
66+
with:
67+
issue_number: ${{ github.event.pull_request.number }}
68+
milestone_number: ${{ steps.selectmilestone.outputs.number }}
69+
env:
70+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
examples/credentials.php
2+
vendor/

Makefile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# set all to phony
2+
SHELL=bash
3+
4+
.PHONY: *
5+
6+
DOCKER_CGROUP:=$(shell cat /proc/1/cgroup | grep docker | wc -l)
7+
8+
ifneq ("$(wildcard /.dockerenv)","")
9+
IN_DOCKER=TRUE
10+
else ifneq ("$(DOCKER_CGROUP)","0")
11+
IN_DOCKER=TRUE
12+
else
13+
IN_DOCKER=FALSe
14+
endif
15+
16+
ifeq ("$(IN_DOCKER)","TRUE")
17+
DOCKER_RUN=
18+
else
19+
DOCKER_RUN=docker run --rm -it \
20+
-v "`pwd`:`pwd`" \
21+
-w "`pwd`" \
22+
"wyrihaximusnet/php:7.4-zts-alpine3.12-dev"
23+
endif
24+
25+
all: lint cs-fix cs stan unit infection composer-require-checker composer-unused
26+
27+
lint:
28+
$(DOCKER_RUN) vendor/bin/parallel-lint --exclude vendor .
29+
30+
cs:
31+
$(DOCKER_RUN) vendor/bin/phpcs --parallel=$(shell nproc)
32+
33+
cs-fix:
34+
$(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(shell nproc)
35+
36+
stan:
37+
$(DOCKER_RUN) vendor/bin/phpstan analyse src tests --level max --ansi -c phpstan.neon
38+
39+
psalm:
40+
$(DOCKER_RUN) vendor/bin/psalm --threads=$(shell nproc) --shepherd --stats
41+
42+
unit:
43+
$(DOCKER_RUN) vendor/bin/phpunit --colors=always -c phpunit.xml.dist --coverage-text --coverage-html covHtml --coverage-clover ./build/logs/clover.xml
44+
45+
unit-ci: unit
46+
if [ -f ./build/logs/clover.xml ]; then sleep 3; fi
47+
48+
infection:
49+
$(DOCKER_RUN) vendor/bin/infection --ansi --min-msi=100 --min-covered-msi=100 --threads=$(shell nproc)
50+
51+
composer-require-checker:
52+
$(DOCKER_RUN) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=composer-require-checker.json
53+
54+
composer-unused:
55+
$(DOCKER_RUN) composer unused --ansi

composer-require-checker.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"symbol-whitelist" : [
3+
"null", "true", "false",
4+
"static", "self", "parent",
5+
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object"
6+
],
7+
"php-core-extensions" : [
8+
"Core",
9+
"date",
10+
"pcre",
11+
"Phar",
12+
"Reflection",
13+
"SPL",
14+
"standard"
15+
],
16+
"scan-files" : []
17+
}

composer.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"name": "react-parallel/worker-pool",
3+
"description": "\ud83d\udc77\ud83d\udc77\u200d\u2640\ufe0f\ud83d\udc77\u200d\u2642\ufe0f Worker pool for only one specific designated task",
4+
"license": "MIT",
5+
"authors": [
6+
{
7+
"name": "Cees-Jan Kiewiet",
8+
"email": "ceesjank@gmail.com",
9+
"homepage": "http://wyrihaximus.net/"
10+
}
11+
],
12+
"require": {
13+
"php": "^7.4",
14+
"ext-parallel": "*",
15+
"react-parallel/contracts": "^1.0",
16+
"react-parallel/event-loop": "^1.0",
17+
"react-parallel/runtime": "^2.0",
18+
"react/event-loop": "^1.1",
19+
"react/promise": "^2.7",
20+
"wyrihaximus/constants": "^1.5",
21+
"wyrihaximus/json-throwable": "^4.0",
22+
"wyrihaximus/pool-info": "^1.0",
23+
"wyrihaximus/ticking-promise": "^1.6"
24+
},
25+
"require-dev": {
26+
"bruli/php-value-objects": "^2.0",
27+
"money/money": "^2.0",
28+
"moneyphp/money": "^3.2 || ^3.2.1",
29+
"ocramius/package-versions": "^1.4",
30+
"react-parallel/infinite-pool": "^2.0",
31+
"react-parallel/pool-tests": "^2.0",
32+
"wyrihaximus/async-test-utilities": "^2.2",
33+
"wyrihaximus/iterator-or-array-to-array": "^1.1"
34+
},
35+
"config": {
36+
"platform": {
37+
"php": "7.4.7"
38+
},
39+
"sort-packages": true
40+
},
41+
"autoload": {
42+
"psr-4": {
43+
"ReactParallel\\Pool\\Worker\\": "src/"
44+
}
45+
},
46+
"autoload-dev": {
47+
"psr-4": {
48+
"ReactParallel\\Tests\\Pool\\Worker\\": "tests/"
49+
}
50+
},
51+
"minimum-stability": "dev",
52+
"prefer-stable": true,
53+
"scripts": {
54+
"post-install-cmd": [
55+
"composer normalize"
56+
],
57+
"post-update-cmd": [
58+
"composer normalize"
59+
]
60+
}
61+
}

0 commit comments

Comments
 (0)