Skip to content

Commit ac259bd

Browse files
Add complete CI (predis#1036)
* Add complete CI * Fix CI * Fix spelling * Fix indentation * Fix CI * Fix CI * Revert disabling unit tests * Add coverage driver to CI * Start coverage debugging * Fix debugging ignored, and an empty message aborts the commit. * Stop debugging * Move TODO-s from source to GitHub issues * Ignore too long lines in certain files * Revert requiring php-parallel-lint/php-parallel-lint * formatting * try shorter formatting * formatting * fix syntax * try two paths? * Update .editorconfig Co-authored-by: Viktor Szépe <[email protected]> * indentation * make it a group Co-authored-by: Till Krüss <[email protected]>
1 parent 6e45ca5 commit ac259bd

Some content is hidden

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

43 files changed

+372
-237
lines changed

.codespellrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[codespell]
2+
skip=./.git
3+
check-hidden=
4+
check-filenames=
5+
builtin=clear,rare,informal,usage,code,names
6+
ignore-words-list=master,masters,slave,slaves,whitelist,cas,exat,smove

.editorconfig

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# http://editorconfig.org
2-
31
root = true
42

53
[*]
@@ -9,9 +7,18 @@ indent_size = 4
97
end_of_line = lf
108
insert_final_newline = true
119
trim_trailing_whitespace = true
10+
block_comment_start = /*
11+
block_comment = *
12+
block_comment_end = */
1213

1314
[*.php]
1415
max_line_length = 150
1516

1617
[*.{md,yml,yaml,neon}]
1718
indent_size = 2
19+
20+
[tests/**.php]
21+
max_line_length = unset
22+
23+
[{src/ClientInterface.php,src/ClientContextInterface.php}]
24+
max_line_length = unset

.gitattributes

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
* text=auto
22

3-
/tests export-ignore
4-
/.github export-ignore
3+
/.github/ export-ignore
4+
/examples/ export-ignore
5+
/tests/ export-ignore
6+
/.codespellrc export-ignore linguist-language=INI
57
/.editorconfig export-ignore
68
/.gitattributes export-ignore
79
/.gitignore export-ignore
8-
/.php_cs.dist export-ignore
10+
/.php-cs-fixer.dist.php export-ignore
11+
/CHANGELOG.md export-ignore linguist-documentation
12+
/CONTRIBUTING.md export-ignore linguist-documentation
13+
/FAQ.md export-ignore linguist-documentation
14+
/VERSION export-ignore
915
/phpunit.xml.dist export-ignore
16+
/phpstan.dist.neon export-ignore

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ Steps to reproduce the behavior:
1919
A clear and concise description of what you expected to happen.
2020

2121
**Versions (please complete the following information):**
22-
- Predis: [e.g. 1.1.2]
23-
- PHP [e.g. 8.0.0]
24-
- Redis Server [e.g. 6.0.0]
25-
- OS [e.g. Ubuntu 20.10]
22+
- Predis: [e.g. 1.1.2]
23+
- PHP [e.g. 8.0.0]
24+
- Redis Server [e.g. 6.0.0]
25+
- OS [e.g. Ubuntu 20.10]
2626

2727
**Code sample**
2828
If applicable, a small snippet of code that reproduces the issue.

.github/workflows/coding-standards.yml

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

.github/workflows/linters.yml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
2+
3+
name: Linters
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
- v2.**
10+
pull_request: null
11+
12+
permissions: {}
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
20+
byte_level:
21+
name: Byte-level
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v3
27+
28+
- name: Check file permissions
29+
run: test "$(find . -type f -not -path './.git/*' -executable)" = "./bin/create-command-test"
30+
31+
- name: "Find non-printable ASCII characters"
32+
run: |
33+
! LC_ALL=C.UTF-8 find . -type f -name '*.php' -print0 \
34+
| xargs --null -- grep --perl-regexp --with-filename --line-number '[^ -~ü]'
35+
36+
syntax_errors:
37+
name: Syntax errors
38+
runs-on: ubuntu-latest
39+
40+
steps:
41+
- name: Set up PHP
42+
uses: shivammathur/setup-php@v2
43+
with:
44+
php-version: "8.1"
45+
coverage: none
46+
tools: parallel-lint
47+
48+
- name: Checkout repository
49+
uses: actions/checkout@v3
50+
51+
- name: Check source code for syntax errors
52+
run: composer exec -- parallel-lint bin/ examples/ src/ tests/
53+
54+
static_analysis:
55+
name: Static Analysis
56+
needs:
57+
- byte_level
58+
- syntax_errors
59+
runs-on: ubuntu-latest
60+
61+
steps:
62+
- name: Set up PHP
63+
uses: shivammathur/setup-php@v2
64+
with:
65+
php-version: "8.2"
66+
coverage: none
67+
68+
- name: Checkout repository
69+
uses: actions/checkout@v3
70+
71+
- name: Validate Composer configuration
72+
run: composer validate --no-interaction --strict
73+
74+
- name: Install dependencies
75+
uses: ramsey/composer-install@v2
76+
with:
77+
dependency-versions: highest
78+
79+
- name: Check PSR-4 mapping
80+
run: composer dump-autoload --no-interaction --optimize --strict-psr
81+
82+
- name: Perform static analysis
83+
run: composer run phpstan
84+
85+
coding_standards:
86+
name: Coding Standards
87+
needs:
88+
- byte_level
89+
- syntax_errors
90+
runs-on: ubuntu-latest
91+
92+
steps:
93+
- name: Set up PHP
94+
uses: shivammathur/setup-php@v2
95+
with:
96+
php-version: "8.1"
97+
coverage: none
98+
99+
- name: Checkout repository
100+
uses: actions/checkout@v3
101+
102+
- name: Check EditorConfig configuration
103+
run: test -f .editorconfig
104+
105+
- name: Check adherence to EditorConfig
106+
uses: greut/eclint-action@v0
107+
108+
- name: Install dependencies
109+
uses: ramsey/composer-install@v2
110+
with:
111+
dependency-versions: highest
112+
113+
- name: Check coding style
114+
run: composer exec -- php-cs-fixer fix --diff --dry-run --allow-risky=yes --using-cache=no
115+
116+
- name: Search for TODO-s and FIXME-s
117+
run: |
118+
! git grep --extended-regexp --ignore-case '\b(TODO|FIXME)\b' -- ':/' ':!tests/*' ':!*/linters\.yml'
119+
120+
exported_files:
121+
name: Exported files
122+
needs:
123+
- byte_level
124+
- syntax_errors
125+
runs-on: ubuntu-latest
126+
127+
steps:
128+
- name: Checkout repository
129+
uses: actions/checkout@v3
130+
131+
- name: Check exported files
132+
run: |
133+
EXPECTED="LICENSE,README.md,autoload.php,composer.json"
134+
CURRENT="$(
135+
git archive HEAD \
136+
| tar --list --exclude="src" --exclude="src/*" --exclude="bin" --exclude="bin/*" \
137+
| paste --serial --delimiters=","
138+
)"
139+
echo "CURRENT =${CURRENT}"
140+
echo "EXPECTED=${EXPECTED}"
141+
test "${CURRENT}" = "${EXPECTED}"
142+
143+
spelling:
144+
name: Spelling
145+
needs:
146+
- byte_level
147+
- syntax_errors
148+
runs-on: ubuntu-latest
149+
150+
steps:
151+
- name: Checkout repository
152+
uses: actions/checkout@v3
153+
154+
- name: Cache pip
155+
uses: actions/cache@v3
156+
with:
157+
path: ~/.cache/pip
158+
key: ${{ runner.os }}-pip-codespell
159+
160+
- name: Install codespell
161+
run: pip install --user 'codespell>=2.2'
162+
163+
- name: Search for misspellings
164+
run: $(python -m site --user-base)/bin/codespell

.github/workflows/release-drafter.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
branches:
66
- main
77

8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
812
jobs:
913

1014
update_release_draft:
@@ -16,6 +20,6 @@ jobs:
1620

1721
- uses: release-drafter/release-drafter@v5
1822
with:
19-
config-name: release-drafter-config.yml
23+
config-name: release-drafter-config.yml
2024
env:
2125
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tests.yml

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ on:
77
- v2.**
88
pull_request:
99

10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
1014
jobs:
1115

1216
predis:
13-
name: PHP ${{ matrix.php }} (Redis ${{ matrix.redis }})
17+
name: PHP ${{ matrix.php }} Redis ${{ matrix.redis }}
1418
runs-on: ubuntu-latest
1519

1620
strategy:
@@ -24,11 +28,11 @@ jobs:
2428
- '8.1'
2529
- '8.2'
2630
redis:
27-
- 3
28-
- 4
29-
- 5
30-
- 6
31-
- 7
31+
- '3'
32+
- '4'
33+
- '5'
34+
- '6'
35+
- '7'
3236

3337
services:
3438
redis:
@@ -39,29 +43,33 @@ jobs:
3943

4044
steps:
4145

42-
- name: Checkout
46+
- name: Checkout repository
4347
uses: actions/checkout@v3
4448

4549
- name: Setup PHP with Composer and extensions
46-
with:
47-
php-version: ${{ matrix.php }}
4850
uses: shivammathur/setup-php@v2
49-
50-
- name: Get Composer cache directory
51-
id: composer-cache
52-
run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT
53-
54-
- name: Cache Composer dependencies
55-
uses: actions/cache@v3
5651
with:
57-
path: ${{ steps.composer-cache.outputs.directory }}
58-
key: tests-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
59-
restore-keys: tests-php-${{ matrix.php }}-composer
52+
php-version: ${{ matrix.php }}
53+
coverage: ${{ (matrix.php == '8.1' && matrix.redis == '7') && 'xdebug' || 'none' }}
6054

6155
- name: Install Composer dependencies
62-
env:
63-
PHP_VERSION: ${{ matrix.php }}
64-
run: composer install --ansi --no-progress --prefer-dist $(if [ "$PHP_VERSION" == "8.0" ]; then echo "--ignore-platform-reqs"; fi;)
56+
uses: ramsey/composer-install@v2
57+
with:
58+
dependency-versions: highest
59+
composer-options: ${{ matrix.php == '8.0' && '--ignore-platform-reqs' || '' }}
6560

6661
- name: Run PHPUnit tests
67-
run: vendor/bin/phpunit
62+
if: ${{ matrix.php != '8.1' || matrix.redis != '7' }}
63+
run: vendor/bin/phpunit --verbose
64+
65+
- name: Run PHPUnit tests with coverage
66+
if: ${{ matrix.php == '8.1' && matrix.redis == '7' }}
67+
run: vendor/bin/phpunit --verbose --coverage-clover build/logs/clover.xml --coverage-filter src
68+
69+
- name: Send coverage to Coveralls
70+
env:
71+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
if: ${{ env.COVERALLS_REPO_TOKEN && matrix.php == '8.1' && matrix.redis == '7' }}
73+
run: |
74+
wget "https://github.com/php-coveralls/php-coveralls/releases/download/v2.5.3/php-coveralls.phar"
75+
php ./php-coveralls.phar -v

0 commit comments

Comments
 (0)