Skip to content

Commit

Permalink
Add complete CI (predis#1036)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
szepeviktor and tillkruss committed Jan 21, 2023
1 parent 6e45ca5 commit ac259bd
Show file tree
Hide file tree
Showing 43 changed files with 372 additions and 237 deletions.
6 changes: 6 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[codespell]
skip=./.git
check-hidden=
check-filenames=
builtin=clear,rare,informal,usage,code,names
ignore-words-list=master,masters,slave,slaves,whitelist,cas,exat,smove
11 changes: 9 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# http:https://editorconfig.org

root = true

[*]
Expand All @@ -9,9 +7,18 @@ indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
block_comment_start = /*
block_comment = *
block_comment_end = */

[*.php]
max_line_length = 150

[*.{md,yml,yaml,neon}]
indent_size = 2

[tests/**.php]
max_line_length = unset

[{src/ClientInterface.php,src/ClientContextInterface.php}]
max_line_length = unset
13 changes: 10 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
* text=auto

/tests export-ignore
/.github export-ignore
/.github/ export-ignore
/examples/ export-ignore
/tests/ export-ignore
/.codespellrc export-ignore linguist-language=INI
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php_cs.dist export-ignore
/.php-cs-fixer.dist.php export-ignore
/CHANGELOG.md export-ignore linguist-documentation
/CONTRIBUTING.md export-ignore linguist-documentation
/FAQ.md export-ignore linguist-documentation
/VERSION export-ignore
/phpunit.xml.dist export-ignore
/phpstan.dist.neon export-ignore
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ Steps to reproduce the behavior:
A clear and concise description of what you expected to happen.

**Versions (please complete the following information):**
- Predis: [e.g. 1.1.2]
- PHP [e.g. 8.0.0]
- Redis Server [e.g. 6.0.0]
- OS [e.g. Ubuntu 20.10]
- Predis: [e.g. 1.1.2]
- PHP [e.g. 8.0.0]
- Redis Server [e.g. 6.0.0]
- OS [e.g. Ubuntu 20.10]

**Code sample**
If applicable, a small snippet of code that reproduces the issue.
Expand Down
61 changes: 0 additions & 61 deletions .github/workflows/coding-standards.yml

This file was deleted.

164 changes: 164 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow

name: Linters

on:
push:
branches:
- main
- v2.**
pull_request: null

permissions: {}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

byte_level:
name: Byte-level
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Check file permissions
run: test "$(find . -type f -not -path './.git/*' -executable)" = "./bin/create-command-test"

- name: "Find non-printable ASCII characters"
run: |
! LC_ALL=C.UTF-8 find . -type f -name '*.php' -print0 \
| xargs --null -- grep --perl-regexp --with-filename --line-number '[^ -~ü]'
syntax_errors:
name: Syntax errors
runs-on: ubuntu-latest

steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
coverage: none
tools: parallel-lint

- name: Checkout repository
uses: actions/checkout@v3

- name: Check source code for syntax errors
run: composer exec -- parallel-lint bin/ examples/ src/ tests/

static_analysis:
name: Static Analysis
needs:
- byte_level
- syntax_errors
runs-on: ubuntu-latest

steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
coverage: none

- name: Checkout repository
uses: actions/checkout@v3

- name: Validate Composer configuration
run: composer validate --no-interaction --strict

- name: Install dependencies
uses: ramsey/composer-install@v2
with:
dependency-versions: highest

- name: Check PSR-4 mapping
run: composer dump-autoload --no-interaction --optimize --strict-psr

- name: Perform static analysis
run: composer run phpstan

coding_standards:
name: Coding Standards
needs:
- byte_level
- syntax_errors
runs-on: ubuntu-latest

steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.1"
coverage: none

- name: Checkout repository
uses: actions/checkout@v3

- name: Check EditorConfig configuration
run: test -f .editorconfig

- name: Check adherence to EditorConfig
uses: greut/eclint-action@v0

- name: Install dependencies
uses: ramsey/composer-install@v2
with:
dependency-versions: highest

- name: Check coding style
run: composer exec -- php-cs-fixer fix --diff --dry-run --allow-risky=yes --using-cache=no

- name: Search for TODO-s and FIXME-s
run: |
! git grep --extended-regexp --ignore-case '\b(TODO|FIXME)\b' -- ':/' ':!tests/*' ':!*/linters\.yml'
exported_files:
name: Exported files
needs:
- byte_level
- syntax_errors
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Check exported files
run: |
EXPECTED="LICENSE,README.md,autoload.php,composer.json"
CURRENT="$(
git archive HEAD \
| tar --list --exclude="src" --exclude="src/*" --exclude="bin" --exclude="bin/*" \
| paste --serial --delimiters=","
)"
echo "CURRENT =${CURRENT}"
echo "EXPECTED=${EXPECTED}"
test "${CURRENT}" = "${EXPECTED}"
spelling:
name: Spelling
needs:
- byte_level
- syntax_errors
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-codespell

- name: Install codespell
run: pip install --user 'codespell>=2.2'

- name: Search for misspellings
run: $(python -m site --user-base)/bin/codespell
6 changes: 5 additions & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

update_release_draft:
Expand All @@ -16,6 +20,6 @@ jobs:

- uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter-config.yml
config-name: release-drafter-config.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54 changes: 31 additions & 23 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ on:
- v2.**
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

predis:
name: PHP ${{ matrix.php }} (Redis ${{ matrix.redis }})
name: PHP ${{ matrix.php }} Redis ${{ matrix.redis }}
runs-on: ubuntu-latest

strategy:
Expand All @@ -24,11 +28,11 @@ jobs:
- '8.1'
- '8.2'
redis:
- 3
- 4
- 5
- 6
- 7
- '3'
- '4'
- '5'
- '6'
- '7'

services:
redis:
Expand All @@ -39,29 +43,33 @@ jobs:

steps:

- name: Checkout
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup PHP with Composer and extensions
with:
php-version: ${{ matrix.php }}
uses: shivammathur/setup-php@v2

- name: Get Composer cache directory
id: composer-cache
run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.directory }}
key: tests-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: tests-php-${{ matrix.php }}-composer
php-version: ${{ matrix.php }}
coverage: ${{ (matrix.php == '8.1' && matrix.redis == '7') && 'xdebug' || 'none' }}

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

- name: Run PHPUnit tests
run: vendor/bin/phpunit
if: ${{ matrix.php != '8.1' || matrix.redis != '7' }}
run: vendor/bin/phpunit --verbose

- name: Run PHPUnit tests with coverage
if: ${{ matrix.php == '8.1' && matrix.redis == '7' }}
run: vendor/bin/phpunit --verbose --coverage-clover build/logs/clover.xml --coverage-filter src

- name: Send coverage to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ env.COVERALLS_REPO_TOKEN && matrix.php == '8.1' && matrix.redis == '7' }}
run: |
wget "https://github.com/php-coveralls/php-coveralls/releases/download/v2.5.3/php-coveralls.phar"
php ./php-coveralls.phar -v
Loading

0 comments on commit ac259bd

Please sign in to comment.