Skip to content
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

Laravel 10 support #36

Merged
merged 11 commits into from
Apr 18, 2023
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trim_trailing_whitespace = false
max_line_length = 120

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

[*.php]
ij_php_align_key_value_pairs = false
Expand Down
103 changes: 67 additions & 36 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,81 @@
name: run-tests

on: [push, pull_request]
on: [ push, pull_request ]

jobs:
psalm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
coverage: none

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --no-progress --no-ansi

- name: Run Psalm
run: composer run-script psalm
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [8.1, 8.0]
laravel: [9.*, 8.*]
php: [ 8.0, 8.1, 8.2 ]
laravel: [ 8.*, 9.*, 10.* ]
include:
- laravel: 9.*
testbench: 7.*
- laravel: 8.*
testbench: 6.*
- laravel: 9.*
testbench: 7.*
- laravel: 10.*
testbench: 8.*
exclude:
- php: 8.0
laravel: 10.*

name: Laravel ${{ matrix.laravel }} with PHP ${{ matrix.php }}

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

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

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

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

- name: Setup PHP
uses: shivammathur/[email protected]
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: xdebug

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-suggest

- name: Execute psalm
run: composer psalm

- name: Execute tests
run: composer test-coverage

- name: Send coverage
run: bash <(curl -s https://codecov.io/bash)
- name: Setup PHP
uses: shivammathur/[email protected]
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: xdebug

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-suggest

- name: Execute tests
run: composer test-coverage

- name: Send coverage
run: bash <(curl -s https://codecov.io/bash)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
![PHP](https://img.shields.io/badge/PHP-%E2%89%A5%208.0-blue)
![Laravel](https://img.shields.io/badge/Laravel-%E2%89%A5%208.0-orange)
[![License](https://poser.pugx.org/lukasss93/laravel-larex/license)](https://packagist.org/packages/lukasss93/laravel-larex)
![Build](https://img.shields.io/github/workflow/status/Lukasss93/laravel-larex/run-tests)
![Build](https://img.shields.io/github/actions/workflow/status/Lukasss93/laravel-larex/run-tests.yml)
[![Coverage](https://img.shields.io/codecov/c/github/lukasss93/laravel-larex?token=XcLU2ccFQ7)](https://codecov.io/gh/Lukasss93/laravel-larex)

Laravel Larex lets you translate your whole Laravel application with a single CSV file.
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
"php": "^8.0",
"ext-dom": "*",
"ext-json": "*",
"illuminate/support": "^8.0|^9.0",
"illuminate/support": "^8.0|^9.0|^10.0",
"loilo/fuse": "^6.4.6",
"spatie/laravel-collection-macros": "^7.12",
"spatie/simple-excel": "^1.13.1"
"spatie/simple-excel": "^3.0.1",
"spatie/laravel-collection-macros": "^7.12"
},
"require-dev": {
"orchestra/testbench": "^6.0|^7.0|^8.0",
"pestphp/pest": "^1.21",
"psalm/plugin-laravel": "^2.0",
"vimeo/psalm": "^4.24"
Expand Down
8 changes: 5 additions & 3 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
<referencedClass name="Lukasss93\Larex\Contracts\Linter"/>
</errorLevel>
</UndefinedClass>
<InaccessibleProperty>
<errorLevel type="suppress">
<file name="src/LarexServiceProvider.php"/>
</errorLevel>
</InaccessibleProperty>
</issueHandlers>
<plugins>
<pluginClass class="Psalm\LaravelPlugin\Plugin"/>
</plugins>
</psalm>
2 changes: 1 addition & 1 deletion src/Console/LarexRemoveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function handle(): int
});

if ($force || $this->confirm("Are you sure you want to delete {$remove->count()} ".Str::plural('string',
$remove->count()).'?')) {
$remove->count()).'?')) {
CsvWriter::create(csv_path())->addRows($keep->toArray());

$this->info('Removed successfully.');
Expand Down
1 change: 0 additions & 1 deletion src/Support/CsvParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public function parse(bool $skipEmpty = true): array

//loop rows
foreach ($rows as $columns) {

//get first two columns values
$group = trim($columns->get('group'));
$key = trim($columns->get('key'));
Expand Down
3 changes: 3 additions & 0 deletions src/Support/CsvReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public static function create(string $path): self
return new self($path);
}

/**
* @return Collection<int,string>
*/
public function getHeader(): Collection
{
$header = $this->reader->getHeaders();
Expand Down
2 changes: 2 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Illuminate\Support\Str;

function csv_path($relative = false): string
{
$path = config('larex.csv.path');
Expand Down
3 changes: 1 addition & 2 deletions tests/Console/LarexExportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@

it('does not export strings due to invalid exporter', function () {
config([
'larex.exporters.list.foo' => new class()
{
'larex.exporters.list.foo' => new class() {
},
]);

Expand Down
3 changes: 1 addition & 2 deletions tests/Console/LarexImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

it('does not import strings due to invalid importer', function () {
config([
'larex.importers.list.foo' => new class()
{
'larex.importers.list.foo' => new class() {
},
]);

Expand Down