Skip to content

Commit 0ed20af

Browse files
committed
Sync Makefile improvements from wyrihaximus/test-utilities
1 parent 7411972 commit 0ed20af

File tree

2 files changed

+97
-66
lines changed

2 files changed

+97
-66
lines changed

.github/workflows/ci.yml

Lines changed: 78 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,81 @@
11
name: Continuous Integration
22
on:
3-
push:
4-
pull_request:
3+
push:
4+
pull_request:
55
jobs:
6-
composer-install:
7-
strategy:
8-
fail-fast: false
9-
matrix:
10-
php: [7.4]
11-
composer: [lowest, current, highest]
12-
runs-on: ubuntu-latest
13-
container:
14-
image: wyrihaximusnet/php:${{ matrix.php }}-zts-alpine3.11-dev-root
15-
steps:
16-
- uses: actions/checkout@v1
17-
- name: Cache composer packages
18-
uses: actions/cache@v1
19-
with:
20-
path: ./vendor/
21-
key: ${{ matrix.composer }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
22-
- name: Install Dependencies
23-
run: composer update --prefer-lowest --no-progress --ansi --no-interaction --prefer-dist -o
24-
if: matrix.composer == 'lowest'
25-
- name: Install Dependencies
26-
run: composer install --ansi --no-progress --no-interaction --prefer-dist -o
27-
if: matrix.composer == 'current'
28-
- name: Install Dependencies
29-
run: composer update --ansi --no-progress --no-interaction --prefer-dist -o
30-
if: matrix.composer == 'highest'
31-
qa:
32-
strategy:
33-
fail-fast: false
34-
matrix:
35-
php: [7.4]
36-
composer: [lowest, current, highest]
37-
qa: [lint, cs, stan, psalm, unit-ci, infection, composer-require-checker, composer-unused, backward-compatibility-check]
38-
needs: composer-install
39-
runs-on: ubuntu-latest
40-
container:
41-
image: wyrihaximusnet/php:${{ matrix.php }}-zts-alpine3.11-dev-root
42-
steps:
43-
- uses: actions/checkout@v1
44-
- name: Cache composer packages
45-
uses: actions/cache@v1
46-
with:
47-
path: ./vendor/
48-
key: ${{ matrix.composer }}-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
49-
- name: Install Dependencies
50-
run: (test -f vendor && true ) || composer update --prefer-lowest --no-progress --ansi --no-interaction --prefer-dist -o
51-
if: matrix.composer == 'lowest'
52-
- name: Install Dependencies
53-
run: (test -f vendor && true ) || composer install --ansi --no-progress --no-interaction --prefer-dist -o
54-
if: matrix.composer == 'current'
55-
- name: Install Dependencies
56-
run: (test -f vendor && true ) || composer update --ansi --no-progress --no-interaction --prefer-dist -o
57-
if: matrix.composer == 'highest'
58-
- run: make ${{ matrix.qa }}
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 }}

Makefile

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,45 @@ else
2222
"wyrihaximusnet/php:7.4-zts-alpine3.12-dev"
2323
endif
2424

25-
all: lint cs-fix cs stan psalm unit infection composer-require-checker composer-unused
25+
all: syntax-php cs-fix cs stan psalm unit infection composer-require-checker composer-unused backward-compatibility-check
2626

27-
lint:
27+
syntax-php: ## Lint PHP syntax
2828
$(DOCKER_RUN) vendor/bin/parallel-lint --exclude vendor .
2929

30-
cs:
30+
cs: ## Check the code for code style issues
3131
$(DOCKER_RUN) vendor/bin/phpcs --parallel=$(shell nproc)
3232

33-
cs-fix:
33+
cs-fix: ## Fix any automatically fixable code style issues
3434
$(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(shell nproc)
3535

36-
stan:
36+
stan: ## Run static analysis (PHPStan)
3737
$(DOCKER_RUN) vendor/bin/phpstan analyse src tests --level max --ansi -c phpstan.neon
3838

39-
psalm:
39+
psalm: ## Run static analysis (Psalm)
4040
$(DOCKER_RUN) vendor/bin/psalm --threads=$(shell nproc) --shepherd --stats
4141

42-
unit:
42+
unit: ## Run tests
4343
$(DOCKER_RUN) vendor/bin/phpunit --colors=always -c phpunit.xml.dist --coverage-text --coverage-html covHtml --coverage-clover ./build/logs/clover.xml
4444

4545
unit-ci: unit
4646
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
4747

48-
infection:
48+
infection: ## Run mutation testing
4949
$(DOCKER_RUN) vendor/bin/infection --ansi --min-msi=100 --min-covered-msi=100 --threads=$(shell nproc)
5050

51-
composer-require-checker:
51+
composer-require-checker: ## Ensure we require every package used in this package directly
5252
$(DOCKER_RUN) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=composer-require-checker.json
5353

54-
composer-unused:
54+
composer-unused: ## Ensure we don't require any package we don't use in this package directly
5555
$(DOCKER_RUN) composer unused --ansi
5656

57-
backward-compatibility-check:
57+
backward-compatibility-check: ## Check code for backwards incompatible changes
5858
$(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}'

0 commit comments

Comments
 (0)