Skip to content

Commit

Permalink
Add composer-require-checker to static analysis checks (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Firehed authored Aug 26, 2022
1 parent 037266f commit c4bf6b2
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
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;
}
}

0 comments on commit c4bf6b2

Please sign in to comment.