Skip to content

Commit

Permalink
Add GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.claeys committed Feb 11, 2021
1 parent 1e79593 commit b1e8374
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 81 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/run-linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: run-linting

on:
push:
pull_request:

jobs:
run-linting:
runs-on: ubuntu-latest

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

- name: Fix style
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php_cs --dry-run --diff-format="udiff"
44 changes: 44 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: run-tests

on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'

jobs:
run-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ 7.4, 7.3 ]
laravel: [ 8.*, 7.* ]
dependency-version: [ prefer-lowest, prefer-stable ]
include:
- laravel: 8.*
testbench: 6.*
- laravel: 7.*
testbench: 5.*

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-version }}

steps:
- name: Update apt
run: sudo apt-get update --fix-missing

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
- name: Execute tests
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ docs
vendor
coverage
.phpunit.result.cache
.php_cs.cache
141 changes: 141 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?php

// Based on ruleset of Laravel Shift (https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200)

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$rules = [
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space',
'operators' => ['=>' => null]
],
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => [
'statements' => ['return']
],
'braces' => true,
'cast_spaces' => true,
'class_attributes_separation' => [
'elements' => ['method']
],
'class_definition' => true,
'concat_space' => [
'spacing' => 'none'
],
'declare_equal_normalize' => true,
'elseif' => true,
'encoding' => true,
'full_opening_tag' => true,
'fully_qualified_strict_types' => true,
'function_declaration' => true,
'function_typehint_space' => true,
'heredoc_to_nowdoc' => true,
'include' => true,
'increment_style' => ['style' => 'post'],
'indentation_type' => true,
'linebreak_after_opening_tag' => true,
'line_ending' => true,
'lowercase_cast' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
'lowercase_static_reference' => true,
'magic_method_casing' => true,
'magic_constant_casing' => true,
'method_argument_space' => true,
'native_function_casing' => true,
'no_alias_functions' => true,
'no_extra_blank_lines' => [
'tokens' => [
'extra',
'throw',
'use',
'use_trait',
]
],
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_closing_tag' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => [
'use' => 'echo'
],
'no_multiline_whitespace_around_double_arrow' => true,
'multiline_whitespace_before_semicolons' => [
'strategy' => 'no_multi_line'
],
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
'no_spaces_inside_parenthesis' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unneeded_control_parentheses' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'normalize_index_brace' => true,
'not_operator_with_successor_space' => true,
'object_operator_without_whitespace' => true,
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
'phpdoc_indent' => true,
'phpdoc_inline_tag' => true,
'phpdoc_no_access' => true,
'phpdoc_no_package' => true,
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_scalar' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => true,
'phpdoc_to_comment' => true,
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_var_without_name' => true,
'psr4' => true,
'self_accessor' => true,
'short_scalar_cast' => true,
'simplified_null_return' => false,
'single_blank_line_at_eof' => true,
'single_blank_line_before_namespace' => true,
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_line_comment_style' => [
'comment_types' => ['hash']
],
'single_quote' => true,
'space_after_semicolon' => true,
'standardize_not_equals' => true,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => [
'elements' => ['method', 'property']
],
'whitespace_after_comma_in_array' => true,
];

$finder = Finder::create()
->notPath('vendor')
->in(__DIR__)
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);

return Config::create()
->setFinder($finder)
->setRules($rules)
->setRiskyAllowed(true)
->setUsingCache(true);
32 changes: 0 additions & 32 deletions .scrutinizer.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .styleci.yml

This file was deleted.

42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Laravel Poeditor Synchronization

[![Latest Version on Packagist](https://img.shields.io/packagist/v/nextapps/laravel-poeditor-sync.svg?style=flat-square)](https://packagist.org/packages/nextapps/laravel-poeditor-sync)
[![Build Status](https://img.shields.io/travis/nextapps-be/laravel-poeditor-sync/master.svg?style=flat-square)](https://travis-ci.org/nextapps-be/laravel-poeditor-sync)
[![Quality Score](https://img.shields.io/scrutinizer/g/nextapps-be/laravel-poeditor-sync.svg?style=flat-square)](https://scrutinizer-ci.com/g/nextapps-be/laravel-poeditor-sync)
[![GitHub 'Run Tests' Workflow Status](https://img.shields.io/github/workflow/status/gdebrauwer/laravel-hateoas/run-tests?label=tests&style=flat-square&logo=github)]
(https://github.com/gdebrauwer/laravel-hateoas/actions?query=workflow%3Arun-tests)
[![Total Downloads](https://img.shields.io/packagist/dt/nextapps/laravel-poeditor-sync.svg?style=flat-square)](https://packagist.org/packages/nextapps/laravel-poeditor-sync)

Upload and download POEditor translations.
Expand Down Expand Up @@ -78,6 +78,12 @@ php artisan poeditor:upload --force
composer test
```

## Linting

```bash
composer lint
```

### Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"symfony/var-exporter": "^5.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"orchestra/testbench": "^5.0|^6.0",
"phpunit/phpunit": "^9.1"
},
Expand All @@ -39,7 +40,9 @@
},
"scripts": {
"test": "vendor/bin/phpunit",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
"test-coverage": "vendor/bin/phpunit --coverage-html coverage",
"lint": "vendor/bin/php-cs-fixer fix",
"lint-dry": "vendor/bin/php-cs-fixer fix --dry-run --diff-format=udiff"
},
"config": {
"sort-packages": true
Expand Down

0 comments on commit b1e8374

Please sign in to comment.