Skip to content

Feature/php8 and GitHub action #448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Docker
on:
# We try to build image on each PR.
pull_request: ~
# When tagged, we also push the image to the docker registry.
push:
tags:
- '*'

jobs:
build:
runs-on: ubuntu-latest
name: Docker image build
env:
publish: ${{ github.event_name == 'push' }}
repository: 'nunomaduro/phpinsights'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get Release version
run: echo "RELEASE_VERSION=$(echo ${GITHUB_REF:10})" >> $GITHUB_ENV
if: ${{ env.publish == 'true' }}
- name: Login to docker hub
run: echo "${{ secrets.DOCKER_PASSWORD}}" | docker login -u "${{ secrets.DOCKER_USERNAME}}" --password-stdin
if: ${{ env.publish == 'true' }}
- name: Build image
run: docker build -f docker/Dockerfile -t ${{ env.repository }}:latest .
- name: Tag image
run: |
docker tag ${{ env.repository }}:latest ${{ env.repository }}:${{ env.RELEASE_VERSION }}
if: ${{ env.publish == 'true' }}
- name: Push image to hub.docker.com registry
run: docker push ${{ env.repository }}
if: ${{ env.publish == 'true' }}
59 changes: 59 additions & 0 deletions .github/workflows/format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Code style analysis

on:
pull_request: ~
push:
branches:
- master

jobs:
ci:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [7.4]
dependency-version: [prefer-stable]

name: ${{ matrix.php }} - ${{ matrix.dependency-version }}

steps:

- name: Checkout
uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, mbstring, zip
coverage: none
tools: cs2pr

- name: Install Composer dependencies
run: composer update --${{ matrix.dependency-version }} --ansi --no-interaction --prefer-dist

- name: PHPStan
run: composer run phpstan:test -- --error-format=checkstyle | cs2pr

- name: ECS
run: composer run ecs:test

- name: Rector
run: composer run rector:test -- --dry-run

- name: PHPInsight on modified files
run: |
URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${{ github.event.pull_request.number }}/files"
FILES=$(curl -s -X GET -G $URL | jq -r '.[] | select( .status == "added" or .status == "modified") | .filename')
php bin/phpinsights analyse $FILES --ansi -v --no-interaction --format=github-action --min-quality=0 --min-complexity=0 --min-architecture=0 --min-style=0

- name: PHPInsight
run: composer run insights

137 changes: 137 additions & 0 deletions .github/workflows/frameworks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: Popular frameworks

on:
push:
branches:
- master
pull_request: ~

jobs:
symfony:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
version: ['^4.4', '@stable', '@dev'] # Test current LTS, current release, and future release
php: ['7.4', '8.0']
composer-version: [v1, v2]
exclude:
- version: '^4.4'
php: '8.0'
env:
allow_failure: ${{ matrix.version == '@dev' || matrix.php == '8.0' }}
name: "Symfony skeleton:${{ matrix.version }} - PHP${{ matrix.php }} - Composer ${{ matrix.composer-version }}"

steps:
- name: Checkout
uses: actions/checkout@v2
with:
path: phpinsights
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, mbstring, zip
coverage: none
tools: composer:${{ matrix.composer-version }}

- name: Install Symfony Skeleton
run: composer create-project --no-progress --ansi symfony/skeleton:${{matrix.version}} project
continue-on-error: ${{ env.allow_failure == 'true' }}
- name: Improve composer
working-directory: ./project
run: |
composer config name phpinsights/symfony-tester
composer config description "Symfony test"
continue-on-error: ${{ env.allow_failure == 'true' }}
- name: Linking library
working-directory: ./project
run: |
composer config repositories.phpinsights '{"type":"path", "url": "../phpinsights/", "options":{"symlink": false}}'
continue-on-error: ${{ env.allow_failure == 'true' }}
- name: Composer config
working-directory: ./project
run: |
composer config prefer-stable true
continue-on-error: ${{ env.allow_failure == 'true' }}
- name: Install PHPInsights
working-directory: ./project
run: composer require --dev nunomaduro/phpinsights:"dev-${GITHUB_SHA}" -n --ansi
continue-on-error: ${{ env.allow_failure == 'true' }}
- name: Launch PHPInsights
working-directory: ./project
run: php vendor/bin/phpinsights -n --ansi
continue-on-error: ${{ env.allow_failure == 'true' }}
- name: Launch PHPInsights Fixer
working-directory: ./project
run: php vendor/bin/phpinsights fix -n --ansi
continue-on-error: ${{ env.allow_failure == 'true' }}
laravel:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
version: ['^7.0', '^8.0']
php: ['7.4', '8.0']
composer-version: [v1, v2]
exclude:
- version: '^7.0'
php: '8.0'
env:
allow_failure: ${{ matrix.php == '8.0' }}
name: "Laravel:${{ matrix.version }} - PHP${{ matrix.php }} - Composer ${{ matrix.composer-version }}"

steps:
- name: Checkout
uses: actions/checkout@v2
with:
path: phpinsights
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, mbstring, zip
coverage: none
tools: composer:${{ matrix.composer-version }}

- name: Install Laravel
run: composer create-project --prefer-dist --no-progress --ansi laravel/laravel:${{matrix.version}} project
continue-on-error: ${{ env.allow_failure == 'true' }}
- name: Improve composer
working-directory: ./project
run: |
composer config name phpinsights/laravel-tester
composer config description "laravel test"
continue-on-error: ${{ env.allow_failure == 'true' }}
- name: Linking library
working-directory: ./project
run: |
composer config repositories.phpinsights '{"type":"path", "url": "../phpinsights/", "options":{"symlink": false}}'
continue-on-error: ${{ env.allow_failure == 'true' }}
- name: Composer config
working-directory: ./project
run: |
composer config prefer-stable true
continue-on-error: ${{ env.allow_failure == 'true' }}
- name: Require phpunit:^9
working-directory: ./project
run: composer require --dev phpunit/phpunit:^9.0 --update-with-dependencies -n --ansi
continue-on-error: ${{ env.allow_failure == 'true' }}
- name: Install PHPInsights
working-directory: ./project
run: composer require --dev nunomaduro/phpinsights:"dev-${GITHUB_SHA}" -n --ansi
continue-on-error: ${{ env.allow_failure == 'true' }}
- name: Artisan publish
working-directory: ./project
run: php artisan vendor:publish --provider="NunoMaduro\PhpInsights\Application\Adapters\Laravel\InsightsServiceProvider" --ansi
continue-on-error: ${{ env.allow_failure == 'true' }}
- name: Launch PHPInsights
working-directory: ./project
run: php artisan insights --ansi
continue-on-error: ${{ env.allow_failure == 'true' }}
- name: Launch PHPInsights Fixer
working-directory: ./project
run: php artisan insights --ansi --fix
continue-on-error: ${{ env.allow_failure == 'true' }}
53 changes: 53 additions & 0 deletions .github/workflows/standalone.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Standalone

on:
pull_request: ~
push:
branches:
- master

jobs:
ci:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
php: ['7.4', '8.0']
dependency-version: [prefer-lowest, prefer-stable]
composer-version: [v1, v2]
exclude:
- dependency-version: prefer-lowest
php: '8.0'

name: ${{ matrix.php }} - ${{ matrix.os }} - Composer ${{ matrix.composer-version }} --${{ matrix.dependency-version }}

steps:
- name: "Configure Git"
if: ${{ matrix.os == 'windows-latest' }}
run: |
git config --system core.autocrlf false
git config --system core.eol lf

- name: Checkout
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ matrix.composer-version }}-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, mbstring, zip
coverage: none
tools: composer:${{ matrix.composer-version }}

- name: Install Composer dependencies
run: composer update --${{ matrix.dependency-version }} --ansi --no-interaction --prefer-dist --no-dev --ignore-platform-reqs

- name: Test launching phpinsights
run: php bin/phpinsights analyse --ansi -v --no-interaction --disable-security-check --flush-cache
44 changes: 44 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Unit Tests

on:
pull_request: ~
push:
branches:
- master
jobs:
ci:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: ['7.4', '8.0']
dependency-version: [prefer-lowest, prefer-stable]
composer-version: [ v1, v2 ]
exclude:
- dependency-version: prefer-lowest
php: '8.0'

name: ${{ matrix.php }} - Composer ${{ matrix.composer-version }} --${{ matrix.dependency-version }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ matrix.composer-version }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, mbstring, zip, xml
coverage: none
tools: composer:${{ matrix.composer-version }}

- name: Install Composer dependencies
run: composer update --${{ matrix.dependency-version }} --ansi --no-interaction --prefer-dist --ignore-platform-reqs
- name: Unit Tests
run: vendor/bin/phpunit --color=always
45 changes: 0 additions & 45 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": "^7.4",
"php": "^7.4 || ^8.0",
"ext-iconv": "*",
"ext-json": "*",
"ext-mbstring": "*",
Expand Down
Loading