Skip to content
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
16 changes: 16 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: "CodeQL"

on: [pull_request]
jobs:
lint:
name: CodeQL
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Run CodeQL
run: |
docker run --rm -v $PWD:/app composer sh -c \
"composer install --profile --ignore-platform-reqs && composer check"
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Tests"

on: [pull_request]
jobs:
lint:
name: Tests ${{ matrix.php-versions }}
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.1', '8.2', '8.3', 'nightly']

steps:
- name: Checkout repository
uses: actions/checkout@v3

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

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

- name: Compose install
run: composer install --ignore-platform-reqs

- name: Run tests
run: composer test
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
"license": "MIT",

"scripts": {
"test": ".vendor/bin/phpunit --configuration phpunit.xml < tests/input.txt",
"lint": "./vendor/bin/pint --test",
"format": "./vendor/bin/pint"
"test": "vendor/bin/phpunit --configuration phpunit.xml < tests/input.txt",
"check": "vendor/bin/phpstan analyse -c phpstan.neon",
"lint": "vendor/bin/pint --test",
"format": "vendor/bin/pint"
},
"autoload": {
"psr-4": {"Utopia\\CLI\\": "src/CLI"}
Expand All @@ -20,7 +21,7 @@
"require-dev": {
"phpunit/phpunit": "^9.3",
"squizlabs/php_codesniffer": "^3.6",
"vimeo/psalm": "4.0.1",
"phpstan/phpstan": "^1.10",
"laravel/pint": "1.2.*"
},
"minimum-stability": "dev"
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
level: 5
paths:
- src
- tests
17 changes: 8 additions & 9 deletions src/CLI/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static function title(string $title): bool
* Log messages to console
*
* @param string $message
* @return bool|int
* @return int|false
*/
public static function log(string $message): int|false
{
Expand All @@ -36,7 +36,7 @@ public static function log(string $message): int|false
* Log success messages to console
*
* @param string $message
* @return bool|int
* @return int|false
*/
public static function success(string $message): int|false
{
Expand All @@ -49,7 +49,7 @@ public static function success(string $message): int|false
* Log error messages to console
*
* @param string $message
* @return bool|int
* @return int|false
*/
public static function error(string $message): int|false
{
Expand All @@ -62,7 +62,7 @@ public static function error(string $message): int|false
* Log informative messages to console
*
* @param string $message
* @return bool|int
* @return int|false
*/
public static function info(string $message): int|false
{
Expand All @@ -75,7 +75,7 @@ public static function info(string $message): int|false
* Log warning messages to console
*
* @param string $message
* @return bool|int
* @return int|false
*/
public static function warning(string $message): int|false
{
Expand Down Expand Up @@ -111,7 +111,7 @@ public static function confirm(string $question): string
*
* Log warning messages to console
*
* @param string $message
* @param int $status
* @return void
*/
public static function exit(int $status = 0): void
Expand All @@ -126,8 +126,7 @@ public static function exit(int $status = 0): void
*
* @param string $cmd
* @param string $stdin
* @param string $stdout
* @param string $stderr
* @param string $output
* @param int $timeout
* @return int
*/
Expand Down Expand Up @@ -159,7 +158,7 @@ public static function execute(string $cmd, string $stdin, string &$output, int
$stdoutContents = \stream_get_contents($pipes[1]) ?: '';
$stderrContents = \stream_get_contents($pipes[2]) ?: '';

$outputContents = $stdoutContents ?? '';
$outputContents = $stdoutContents;

if (! empty($stderrContents)) {
$separator = empty($outputContents) ? '' : "\n";
Expand Down
2 changes: 1 addition & 1 deletion tests/CLI/TaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class TaskTest extends TestCase
{
/**
* @var Task
* @var ?Task
*/
protected $task;

Expand Down