Skip to content

Commit 85d0a8f

Browse files
authored
Merge pull request #125 from WyriHaximus/drop-php-7-support
Drop php 7 support
2 parents dce53f6 + 8856908 commit 85d0a8f

17 files changed

+1923
-1053
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github: WyriHaximus
1+
github: WyriHaximus

.github/workflows/ci.yml

Lines changed: 136 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,167 @@
11
name: Continuous Integration
22
on:
33
push:
4+
branches:
5+
- 'main'
6+
- 'master'
7+
- 'refs/heads/v[0-9]+.[0-9]+.[0-9]+'
48
pull_request:
59
jobs:
6-
generate-checks-strategy:
7-
name: Generate Checks
10+
package-name:
11+
name: Package Name
812
runs-on: ubuntu-latest
13+
needs:
14+
- lint-json
15+
outputs:
16+
package-name: ${{ steps.package-name.outputs.package-name }}
17+
steps:
18+
- uses: actions/checkout@v3
19+
- id: package-name
20+
run: |
21+
printf "::set-output name=package-name::[\"%s\"]" $(docker run --rm -v "`pwd`:`pwd`" jess/jq jq -r -c '.name' "${GITHUB_WORKSPACE}/composer.json")
22+
supported-versions-matrix:
23+
name: Supported Versions Matrix
24+
runs-on: ubuntu-latest
25+
needs:
26+
- lint-yaml
27+
- lint-json
928
outputs:
10-
check: ${{ steps.generate-checks-strategy.outputs.check }}
29+
version: ${{ steps.supported-versions-matrix.outputs.version }}
1130
steps:
12-
- uses: actions/checkout@v1
13-
- id: generate-checks-strategy
31+
- uses: actions/checkout@v3
32+
- id: supported-versions-matrix
33+
uses: WyriHaximus/github-action-composer-php-versions-in-range@v1
34+
with:
35+
upcomingReleases: true
36+
supported-checks-matrix:
37+
name: Supported Checks Matrix
38+
runs-on: ubuntu-latest
39+
needs:
40+
- lint-yaml
41+
outputs:
42+
check: ${{ steps.supported-checks-matrix.outputs.check }}
43+
steps:
44+
- uses: actions/checkout@v3
45+
- id: supported-checks-matrix
1446
name: Generate check
1547
run: |
1648
printf "Checks found: %s\r\n" $(make task-list-ci)
1749
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:
50+
can-require:
51+
name: Test we can require "${{ matrix.package-name }}" on PHP ${{ matrix.php }}
2452
strategy:
2553
fail-fast: false
2654
matrix:
27-
php: [7.4, "8.0", 8.1]
28-
composer: [lowest, current, highest]
29-
needs: lint
55+
php: ${{ fromJson(needs.supported-versions-matrix.outputs.version) }}
56+
package-name: ${{ fromJson(needs.package-name.outputs.package-name) }}
57+
needs:
58+
- lint-yaml
59+
- lint-json
60+
- package-name
61+
- supported-versions-matrix
3062
runs-on: ubuntu-latest
3163
container:
32-
image: wyrihaximusnet/php:${{ matrix.php }}-nts-alpine-slim-dev-root
64+
image: ghcr.io/wyrihaximusnet/php:${{ matrix.php }}-nts-buster-dev-root
3365
steps:
34-
- uses: actions/checkout@v1
35-
- name: Cache composer packages
36-
uses: actions/cache@v1
66+
- uses: actions/checkout@v3
3767
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'
68+
path: checked_out_package
69+
- name: Set Up composer.json
70+
run: |
71+
echo "{\"repositories\": [{\"name\": \"${{ matrix.package-name }}\",\"type\": \"path\",\"url\": \"./checked_out_package\"}]}" > composer.json
72+
- name: Require package
73+
run: |
74+
composer require "${{ matrix.package-name }}:dev-${GITHUB_SHA}" --no-progress --ansi --no-interaction --prefer-dist -o -vvv || composer require "${{ matrix.package-name }}:dev-${GITHUB_REF_NAME}" --no-progress --ansi --no-interaction --prefer-dist -o -vvv
4975
qa:
76+
name: Run ${{ matrix.check }} on PHP ${{ matrix.php }} with ${{ matrix.composer }} dependency preference
5077
strategy:
5178
fail-fast: false
5279
matrix:
53-
php: [7.4, "8.0", 8.1]
54-
composer: [lowest, current, highest]
55-
check: ${{ fromJson(needs.generate-checks-strategy.outputs.check) }}
80+
php: ${{ fromJson(needs.supported-versions-matrix.outputs.version) }}
81+
composer: [lowest, locked, highest]
82+
check: ${{ fromJson(needs.supported-checks-matrix.outputs.check) }}
5683
needs:
57-
- composer-install
58-
- generate-checks-strategy
84+
- lint-yaml
85+
- lint-json
86+
- supported-checks-matrix
87+
- supported-versions-matrix
5988
runs-on: ubuntu-latest
6089
container:
61-
image: wyrihaximusnet/php:${{ matrix.php }}-nts-alpine-slim-dev-root
90+
image: ghcr.io/wyrihaximusnet/php:${{ matrix.php }}-nts-buster-dev-root
6291
steps:
63-
- uses: actions/checkout@v1
64-
- name: Cache composer packages
65-
uses: actions/cache@v1
92+
- uses: actions/checkout@v3
93+
- uses: ramsey/composer-install@v2
6694
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'
95+
dependency-versions: ${{ matrix.composer }}
7896
- name: Fetch Tags
79-
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
97+
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
8098
if: matrix.check == 'backward-compatibility-check'
8199
- run: make ${{ matrix.check }}
100+
env:
101+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
102+
COVERALLS_RUN_LOCALLY: ${{ secrets.COVERALLS_RUN_LOCALLY }}
103+
tests-directly-on-os:
104+
name: Run tests on PHP ${{ matrix.php }} with ${{ matrix.composer }} dependency preference (${{ matrix.os }})
105+
strategy:
106+
fail-fast: false
107+
matrix:
108+
os: [ubuntu-latest, windows-latest, macos-latest]
109+
php: ${{ fromJson(needs.supported-versions-matrix.outputs.version) }}
110+
composer: [lowest, locked, highest]
111+
needs:
112+
- lint-yaml
113+
- lint-json
114+
- supported-checks-matrix
115+
- supported-versions-matrix
116+
runs-on: ${{ matrix.os }}
117+
steps:
118+
- uses: actions/checkout@v3
119+
- uses: shivammathur/setup-php@v2
120+
with:
121+
php-version: ${{ matrix.php }}
122+
coverage: pcov
123+
extensions: intl, sodium
124+
- uses: ramsey/composer-install@v2
125+
with:
126+
dependency-versions: ${{ matrix.composer }}
127+
- run: |
128+
make unit-testing-raw
129+
env:
130+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
131+
COVERALLS_RUN_LOCALLY: ${{ secrets.COVERALLS_RUN_LOCALLY }}
132+
lint-yaml:
133+
name: Lint YAML
134+
runs-on: ubuntu-latest
135+
steps:
136+
- uses: actions/checkout@v3
137+
- name: yaml-lint
138+
uses: ibiqlik/action-yamllint@v3
139+
with:
140+
config_data: |
141+
extends: default
142+
ignore: |
143+
/.git/
144+
rules:
145+
line-length: disable
146+
document-start: disable
147+
truthy: disable
148+
lint-json:
149+
name: Lint JSON
150+
runs-on: ubuntu-latest
151+
steps:
152+
- uses: actions/checkout@v3
153+
- name: json-syntax-check
154+
uses: limitusus/json-syntax-check@v1
155+
with:
156+
pattern: "\\.json$"
157+
check-mark:
158+
name: ✔️
159+
needs:
160+
- lint-yaml
161+
- lint-json
162+
- can-require
163+
- qa
164+
- tests-directly-on-os
165+
runs-on: ubuntu-latest
166+
steps:
167+
- run: echo "✔️"

.github/workflows/craft-release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- generate-changelog
3030
runs-on: ubuntu-latest
3131
steps:
32-
- uses: actions/checkout@v1
32+
- uses: actions/checkout@v3
3333
env:
3434
CHANGELOG: ${{ needs.generate-changelog.outputs.changelog }}
3535
- run: |

.github/workflows/set-milestone-on-pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
outputs:
2222
check: ${{ steps.generate-checks-strategy.outputs.check }}
2323
steps:
24-
- uses: actions/checkout@v1
24+
- uses: actions/checkout@v3
2525
- name: 'Get Previous tag'
2626
id: previoustag
2727
uses: "WyriHaximus/github-action-get-previous-tag@v1"

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
covHtml/
1+
var/*
2+
!var/.gitkeep
23
vendor/
3-
humbuglog.txt
4-
humbuglog.json
4+
etc/qa/.phpunit.result.cache

.scrutinizer.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

Makefile

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,86 @@ SHELL=bash
33

44
.PHONY: *
55

6-
DOCKER_CGROUP:=$(shell cat /proc/1/cgroup | grep docker | wc -l)
6+
COMPOSER_CACHE_DIR=$(shell composer config --global cache-dir -q || echo ${HOME}/.composer-php/cache)
7+
COMPOSER_SHOW_EXTENSION_LIST=$(shell composer show -t | grep -o "\-\-\(ext-\).\+" | sort | uniq | cut -d- -f4- | tr -d '\n' | grep . | sed '/^$$/d' | xargs | sed -e 's/ /, /g' | tr -cd '[:alnum:],' | sed 's/.$$//')
8+
SLIM_DOCKER_IMAGE=$(shell php -r 'echo count(array_intersect(["gd", "vips"], explode(",", "${COMPOSER_SHOW_EXTENSION_LIST}"))) > 0 ? "" : "-slim";')
79

8-
ifneq ("$(wildcard /.dockerenv)","")
10+
ifneq ("$(wildcard /.you-are-in-a-wyrihaximus.net-php-docker-image)","")
911
IN_DOCKER=TRUE
10-
else ifneq ("$(DOCKER_CGROUP)","0")
11-
IN_DOCKER=TRUE
1212
else
13-
IN_DOCKER=FALSe
13+
IN_DOCKER=FALSE
1414
endif
1515

1616
ifeq ("$(IN_DOCKER)","TRUE")
17-
DOCKER_RUN=
17+
DOCKER_RUN:=
1818
else
19-
DOCKER_RUN=docker run --rm -it \
19+
PHP_VERSION:=$(shell docker run --rm -v "`pwd`:`pwd`" jess/jq jq -r -c '.config.platform.php' "`pwd`/composer.json" | php -r "echo str_replace('|', '.', explode('.', implode('|', explode('.', stream_get_contents(STDIN), 2)), 2)[0]);")
20+
DOCKER_RUN:=docker run --rm -it \
2021
-v "`pwd`:`pwd`" \
22+
-v "${COMPOSER_CACHE_DIR}:/home/app/.composer/cache" \
2123
-w "`pwd`" \
22-
"wyrihaximusnet/php:7.4-zts-alpine3.12-dev"
24+
"ghcr.io/wyrihaximusnet/php:${PHP_VERSION}-nts-buster${SLIM_DOCKER_IMAGE}-dev"
2325
endif
2426

25-
all: syntax-php cs-fix cs stan psalm unit infection composer-require-checker composer-unused backward-compatibility-check
27+
ifneq (,$(findstring icrosoft,$(shell cat /proc/version)))
28+
THREADS=1
29+
else
30+
THREADS=$(shell nproc)
31+
endif
32+
33+
all: ## Runs everything ###
34+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | grep -v "###" | awk 'BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | xargs --open-tty $(MAKE)
2635

2736
syntax-php: ## Lint PHP syntax
2837
$(DOCKER_RUN) vendor/bin/parallel-lint --exclude vendor .
2938

30-
cs: ## Check the code for code style issues
31-
$(DOCKER_RUN) vendor/bin/phpcs --parallel=$(shell nproc)
32-
3339
cs-fix: ## Fix any automatically fixable code style issues
34-
$(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(shell nproc)
40+
$(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(THREADS) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml || $(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(THREADS) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml || $(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(THREADS) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml -vvvv
41+
42+
cs: ## Check the code for code style issues
43+
$(DOCKER_RUN) vendor/bin/phpcs --parallel=$(THREADS) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml
3544

3645
stan: ## Run static analysis (PHPStan)
37-
$(DOCKER_RUN) vendor/bin/phpstan analyse src tests --level max --ansi -c phpstan.neon
46+
$(DOCKER_RUN) vendor/bin/phpstan analyse src tests --level max --ansi -c ./etc/qa/phpstan.neon
3847

3948
psalm: ## Run static analysis (Psalm)
40-
$(DOCKER_RUN) vendor/bin/psalm --threads=$(shell nproc) --shepherd --stats
49+
$(DOCKER_RUN) vendor/bin/psalm --threads=$(THREADS) --shepherd --stats --config=./etc/qa/psalm.xml
50+
51+
unit-testing: ## Run tests
52+
$(DOCKER_RUN) vendor/bin/phpunit --colors=always -c ./etc/qa/phpunit.xml --coverage-text --coverage-html ./var/tests-unit-coverage-html --coverage-clover ./var/tests-unit-clover-coverage.xml
53+
$(DOCKER_RUN) test -n "$(COVERALLS_REPO_TOKEN)" && test -n "$(COVERALLS_RUN_LOCALLY)" && test -f ./var/tests-unit-clover-coverage.xml && vendor/bin/php-coveralls -v --coverage_clover ./build/logs/clover.xml --json_path ./var/tests-unit-clover-coverage-upload.json || true
4154

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
55+
unit-testing-raw: ## Run tests ###
56+
php vendor/phpunit/phpunit/phpunit --colors=always -c ./etc/qa/phpunit.xml --coverage-text --coverage-html ./var/tests-unit-coverage-html --coverage-clover ./var/tests-unit-clover-coverage.xml
57+
test -n "$(COVERALLS_REPO_TOKEN)" && test -n "$(COVERALLS_RUN_LOCALLY)" && test -f ./var/tests-unit-clover-coverage.xml && ./vendor/bin/php-coveralls -v --coverage_clover ./build/logs/clover.xml --json_path ./var/tests-unit-clover-coverage-upload.json || true
4458

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
59+
mutation-testing: ## Run mutation testing
60+
$(DOCKER_RUN) vendor/bin/roave-infection-static-analysis-plugin --ansi --log-verbosity=all --threads=$(THREADS) --psalm-config etc/qa/psalm.xml || (cat ./var/infection.log && false)
4761

48-
infection: ## Run mutation testing
49-
$(DOCKER_RUN) vendor/bin/infection --ansi --min-msi=100 --min-covered-msi=100 --threads=$(shell nproc)
62+
mutation-testing-raw: ## Run mutation testing ###
63+
php vendor/roave/infection-static-analysis-plugin/bin/roave-infection-static-analysis-plugin --ansi --log-verbosity=all --threads=$(THREADS) --psalm-config etc/qa/psalm.xml || (cat ./var/infection.log && false)
5064

5165
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
66+
$(DOCKER_RUN) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=./etc/qa/composer-require-checker.json
5367

5468
composer-unused: ## Ensure we don't require any package we don't use in this package directly
55-
$(DOCKER_RUN) composer unused --ansi
69+
$(DOCKER_RUN) vendor/bin/composer-unused --ansi
70+
71+
composer-install: ## Install dependencies
72+
$(DOCKER_RUN) composer install --no-progress --ansi --no-interaction --prefer-dist -o
5673

5774
backward-compatibility-check: ## Check code for backwards incompatible changes
58-
$(DOCKER_RUN) vendor/bin/roave-backward-compatibility-check || true
75+
$(MAKE) backward-compatibility-check-raw || true
76+
77+
backward-compatibility-check-raw: ## Check code for backwards incompatible changes, doesn't ignore the failure ###
78+
$(DOCKER_RUN) vendor/bin/roave-backward-compatibility-check
79+
80+
shell: ## Provides Shell access in the expected environment ###
81+
$(DOCKER_RUN) bash
5982

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]'
83+
task-list-ci: ## CI: Generate a JSON array of jobs to run, matches the commands run when running `make (|all)` ###
84+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | grep -v "###" | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | jq --raw-input --slurp -c 'split("\n")| .[0:-1]'
6285

63-
help:
86+
help: ## Show this help ###
6487
@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}'
88+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-32s\033[0m %s\n", $$1, $$2}' | tr -d '#'

0 commit comments

Comments
 (0)