Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 5384657

Browse files
authored
Merge pull request #3 from reactphp-parallel/add-qa
Add QA
2 parents 5d711fd + 06cb30f commit 5384657

17 files changed

+9442
-0
lines changed

.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

.github/workflows/ci.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Continuous Integration
2+
on:
3+
push:
4+
pull_request:
5+
jobs:
6+
generate-checks-strategy:
7+
name: Generate Checks
8+
runs-on: ubuntu-latest
9+
outputs:
10+
check: ${{ steps.generate-checks-strategy.outputs.check }}
11+
steps:
12+
- uses: actions/checkout@v1
13+
- id: generate-checks-strategy
14+
name: Generate check
15+
run: |
16+
printf "Checks found: %s\r\n" $(make task-list-ci)
17+
printf "::set-output name=check::%s" $(make task-list-ci)
18+
lint:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Lint Code Base
22+
uses: docker://github/super-linter:v2.2.0
23+
composer-install:
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
php: [7.4]
28+
composer: [lowest, current, highest]
29+
needs: lint
30+
runs-on: ubuntu-latest
31+
container:
32+
image: wyrihaximusnet/php:${{ matrix.php }}-zts-alpine3.12-dev-root
33+
steps:
34+
- uses: actions/checkout@v1
35+
- name: Cache composer packages
36+
uses: actions/cache@v1
37+
with:
38+
path: ./vendor/
39+
key: ${{ matrix.composer }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
40+
- name: Install Dependencies
41+
run: composer update --prefer-lowest --no-progress --ansi --no-interaction --prefer-dist -o
42+
if: matrix.composer == 'lowest'
43+
- name: Install Dependencies
44+
run: composer install --ansi --no-progress --no-interaction --prefer-dist -o
45+
if: matrix.composer == 'current'
46+
- name: Install Dependencies
47+
run: composer update --ansi --no-progress --no-interaction --prefer-dist -o
48+
if: matrix.composer == 'highest'
49+
qa:
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
php: [7.4]
54+
composer: [lowest, current, highest]
55+
check: ${{ fromJson(needs.generate-checks-strategy.outputs.check) }}
56+
needs:
57+
- composer-install
58+
- generate-checks-strategy
59+
runs-on: ubuntu-latest
60+
container:
61+
image: wyrihaximusnet/php:${{ matrix.php }}-zts-alpine3.12-dev-root
62+
steps:
63+
- uses: actions/checkout@v1
64+
- name: Cache composer packages
65+
uses: actions/cache@v1
66+
with:
67+
path: ./vendor/
68+
key: ${{ matrix.composer }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
69+
- name: Install Dependencies
70+
run: (test -f vendor && true ) || composer update --prefer-lowest --no-progress --ansi --no-interaction --prefer-dist -o
71+
if: matrix.composer == 'lowest'
72+
- name: Install Dependencies
73+
run: (test -f vendor && true ) || composer install --ansi --no-progress --no-interaction --prefer-dist -o
74+
if: matrix.composer == 'current'
75+
- name: Install Dependencies
76+
run: (test -f vendor && true ) || composer update --ansi --no-progress --no-interaction --prefer-dist -o
77+
if: matrix.composer == 'highest'
78+
- name: Fetch Tags
79+
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
80+
if: matrix.check == 'backward-compatibility-check'
81+
- run: make ${{ matrix.check }}
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 }}"

.phpcs.cache

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Cees-Jan Kiewiet
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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: syntax-php cs-fix cs stan psalm unit infection composer-require-checker composer-unused backward-compatibility-check
26+
27+
syntax-php: ## Lint PHP syntax
28+
$(DOCKER_RUN) vendor/bin/parallel-lint --exclude vendor .
29+
30+
cs: ## Check the code for code style issues
31+
$(DOCKER_RUN) vendor/bin/phpcs --parallel=$(shell nproc)
32+
33+
cs-fix: ## Fix any automatically fixable code style issues
34+
$(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(shell nproc)
35+
36+
stan: ## Run static analysis (PHPStan)
37+
$(DOCKER_RUN) vendor/bin/phpstan analyse src tests --level max --ansi -c phpstan.neon
38+
39+
psalm: ## Run static analysis (Psalm)
40+
$(DOCKER_RUN) vendor/bin/psalm --threads=$(shell nproc) --shepherd --stats
41+
42+
unit: ## Run tests
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 wget https://scrutinizer-ci.com/ocular.phar && sleep 3 && php ocular.phar code-coverage:upload --format=php-clover ./build/logs/clover.xml; fi
47+
48+
infection: ## Run mutation testing
49+
$(DOCKER_RUN) vendor/bin/infection --ansi --min-msi=100 --min-covered-msi=100 --threads=$(shell nproc)
50+
51+
composer-require-checker: ## Ensure we require every package used in this package directly
52+
$(DOCKER_RUN) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=composer-require-checker.json
53+
54+
composer-unused: ## Ensure we don't require any package we don't use in this package directly
55+
$(DOCKER_RUN) composer unused --ansi
56+
57+
backward-compatibility-check: ## Check code for backwards incompatible changes
58+
$(DOCKER_RUN) vendor/bin/roave-backward-compatibility-check || true
59+
60+
task-list-ci:
61+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | jq --raw-input --slurp -c 'split("\n")| .[0:-1]'
62+
63+
help:
64+
@printf "\033[33mUsage:\033[0m\n make [target]\n\n\033[33mTargets:\033[0m\n"
65+
@printf " \033[32m%-32s\033[0m %s\n" "all" "Runs everything"
66+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-32s\033[0m %s\n", $$1, $$2}'

composer-require-checker.json

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

0 commit comments

Comments
 (0)