Skip to content

Commit

Permalink
upgrade to code-safe-2.2 (#48)
Browse files Browse the repository at this point in the history
* add comment of why mutation testing is disabled
* update composer
  • Loading branch information
ildyria authored Oct 21, 2022
1 parent 7b1eb6c commit ada5def
Show file tree
Hide file tree
Showing 14 changed files with 986 additions and 152 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ trim_trailing_whitespace = false
[*.js]
indent_style = tab
indent_size = 4

[*.yml]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
154 changes: 138 additions & 16 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,122 @@
name: Tests
name: "Integrate"

# Run this workflow every time a new commit pushed to your repository
on:
push:
paths-ignore:
- '**/*.md'
- 'public/dist/*.js'
- 'public/dist/**/*.js'
pull_request:
paths-ignore:
- '**/*.md'
- 'public/dist/*.js'
- 'public/dist/**/*.js'
# Allow manually triggering the workflow.
workflow_dispatch:

jobs:
tests:
runs-on: ${{ matrix.operating-system }}
kill_previous:
name: "0️⃣ Kill previous runs"
runs-on: "ubuntu-latest"
# We want to run on external PRs, but not on our own internal PRs as they'll be run by the push to the branch.
if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository)
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

php_syntax_errors:
name: "1️⃣ PHP: Syntax errors"
runs-on: "ubuntu-latest"
needs:
- "kill_previous"
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "latest"

- name: "Checkout code"
uses: "actions/checkout@v3"

- name: "Install dependencies"
uses: "ramsey/composer-install@v2"

- name: Validate files
run: composer validate-files

code_style_errors:
name: "1️⃣ PHP: Code Style errors"
runs-on: "ubuntu-latest"
needs:
- "kill_previous"
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "latest"

- name: "Checkout code"
uses: "actions/checkout@v3"

- name: "Install dependencies"
uses: "ramsey/composer-install@v2"

- name: Check Style
run: composer check-code-style

phpstan:
name: "2️⃣ PHP: PHPStan"
runs-on: "ubuntu-latest"
needs:
- "php_syntax_errors"
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/[email protected]
with:
php-version: "latest"
coverage: none
tools: phpstan

- name: Install Composer dependencies
uses: "ramsey/composer-install@v2"

- name: Run PHPStan
run: vendor/bin/phpstan analyze

tests:
name: "2️⃣ PHP ${{ matrix.php-version }}: ${{ matrix.beta }} ${{ matrix.dependencies }}"
needs:
- "php_syntax_errors"
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-20.04]
php-versions: ['8.0', '8.1']
beta: ['beta', '']
dependencies: ['locked', 'lowest', 'highest']
php-version:
- "8.0"
- "8.1"
dependencies:
- "locked"
- "lowest"
- "highest"
beta:
- "beta"
- ""
exclude:
- beta: 'beta'
dependencies: 'locked'
- beta: 'beta'
dependencies: 'lowest'

name: PHP ${{ matrix.php-versions }} -- ${{ matrix.beta }} ${{ matrix.dependencies }}
- beta: "beta"
dependencies: "locked"
- beta: "beta"
dependencies: "lowest"

env:
extensions: curl, dom, imagick, json, libxml, mbstring
key: cache-v1 # can be any string, change to clear the extension cache.

steps:
# Checks out a copy of your repository on the ubuntu machine
- name: Checkout code
uses: actions/checkout@v3

Expand All @@ -48,7 +129,7 @@ jobs:
- name: Setup PHP Action
uses: shivammathur/[email protected]
with:
php-version: ${{ matrix.php-versions }}
php-version: ${{ matrix.php-version }}
extensions: ${{ env.extensions }}
coverage: xdebug
tools: pecl, composer
Expand Down Expand Up @@ -79,3 +160,44 @@ jobs:

- name: Run tests
run: composer run-tests

- name: Codecov
uses: codecov/codecov-action@v1

# support for mutation testing.
#
# This section is disabled because Mutation testing is a rather slow process
# and furthermore adds lots of noise into the pull request review panel by Github.
# While it is an intersting set of tests to have, this does not constitute major
# improvements to the full code base.
#
# TODO: This section can be uncommented once ALL the code paths are evaluted.
# This unfortunately includes changes such as in_array(...,..., true) into in_array(...,..., false)
# and other behaviours which are very edge cases
#
# infection:
# name: "3️⃣ PHP: Mutation testing"
# runs-on: "ubuntu-latest"
# needs:
# - "tests"
# steps:
# - name: Checkout code
# uses: actions/checkout@v3

# - name: Set Up Imagick, FFmpeg & Exiftools
# run: |
# sudo apt-get update
# sudo apt-get --fix-broken install
# sudo apt-get -y install ffmpeg libimage-exiftool-perl libmagickwand-dev

# - name: Setup PHP
# uses: shivammathur/[email protected]
# with:
# php-version: "latest"
# coverage: xdebug

# - name: Install Composer dependencies
# uses: "ramsey/composer-install@v2"

# - name: Run Infection
# run: vendor/bin/infection
41 changes: 0 additions & 41 deletions .github/workflows/phpstan.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ composer.phar
.DS_Store
.idea
.phpunit.result.cache
infection.html
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@
"ext-fileinfo": "*",
"neitanod/forceutf8": "^2.0.4",
"php-ffmpeg/php-ffmpeg": "^1.0",
"thecodingmachine/safe": "^1.3"
"thecodingmachine/safe": "^2.2"
},
"require-dev": {
"lychee-org/phpstan-lychee": "dev-master",
"friendsofphp/php-cs-fixer": "^3.3",
"infection/infection": "^0.26.13",
"lychee-org/phpstan-lychee": "dev-master",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpmd/phpmd": "^2.9",
"phpunit/phpunit": "^9.5.10",
Expand Down Expand Up @@ -76,7 +77,10 @@
},
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
"optimize-autoloader": true,
"allow-plugins": {
"infection/extension-installer": true
}
},
"prefer-stable": true
}
Loading

0 comments on commit ada5def

Please sign in to comment.