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

Add composer-require-checker to static analysis checks #1

Merged
merged 6 commits into from
Aug 26, 2022
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
35 changes: 35 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env:

jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-latest
steps:
- name: Check out code
Expand Down Expand Up @@ -45,3 +46,37 @@ jobs:
run: vendor/bin/phpstan
analyse
--error-format=github

require-checker:
name: Require checker
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache Composer packages
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Install dependencies
run: composer update
--no-ansi
--no-interaction
--no-progress
--no-suggest
--prefer-dist

- name: Composer require-checker
run: vendor/bin/composer-require-checker check
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"php": "^7.3 || ^8.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^2.0 || ^3.0 || ^4.0",
"mheap/phpunit-github-actions-printer": "^1.5",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
Expand Down
23 changes: 23 additions & 0 deletions src/Example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Your\Library;

/**
* This file exists to:
* a) Demonstrate the default namespace setup
* b) Provide something for composer-require-checker to find when CI runs
* against the actual template repository.
*
* You won't want to keep it!
*/
class Example
{
public string $message;

public function __construct(string $message)
{
$this->message = $message;
}
}