Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-review required dependency matching
- Loading branch information
1 parent
a8e271a
commit 08f3d30
Showing
5 changed files
with
105 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Automatic Code Review | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- composer.json | ||
- spark | ||
- '**.php' | ||
- .github/workflows/test-autoreview.yml | ||
push: | ||
paths: | ||
- composer.json | ||
- spark | ||
- '**.php' | ||
- .github/workflows/test-autoreview.yml | ||
|
||
jobs: | ||
auto-review-tests: | ||
name: Automatic Code Review | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.0' | ||
coverage: none | ||
|
||
- name: Get composer cache directory | ||
id: composercache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.composercache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
|
||
- name: Install dependencies | ||
run: composer update --ansi | ||
env: | ||
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} | ||
|
||
- name: Run AutoReview Tests | ||
run: vendor/bin/phpunit --color=always --group=auto-review --no-coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of CodeIgniter 4 framework. | ||
* | ||
* (c) CodeIgniter Foundation <admin@codeigniter.com> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace CodeIgniter\AutoReview; | ||
|
||
use JsonException; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @coversNothing | ||
* @group auto-review | ||
*/ | ||
final class ComposerJsonTest extends TestCase | ||
{ | ||
public function testFrameworkRequireIsTheSameWithDevRequire(): void | ||
{ | ||
$devComposer = $this->getComposerJson(dirname(__DIR__, 2) . '/composer.json'); | ||
$frameworkComposer = $this->getComposerJson(dirname(__DIR__, 2) . '/admin/framework/composer.json'); | ||
|
||
$this->assertSame( | ||
$devComposer['require'], | ||
$frameworkComposer['require'], | ||
'The framework\'s "require" section is not updated with the main composer.json.' | ||
); | ||
} | ||
|
||
private function getComposerJson(string $path): array | ||
{ | ||
try { | ||
return json_decode((string) file_get_contents($path), true, 512, JSON_THROW_ON_ERROR); | ||
} catch (JsonException $e) { | ||
$this->fail(sprintf( | ||
'The composer.json at "%s" is not readable or does not exist. Error was "%s".', | ||
clean_path($path), | ||
$e->getMessage() | ||
)); | ||
} | ||
} | ||
} |