diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..dbbe55a --- /dev/null +++ b/.github/workflows/codeql.yml @@ -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" \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..5babce5 --- /dev/null +++ b/.github/workflows/test.yml @@ -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 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3ba22f2..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: php - -php: -- 8.0 -- nightly - -notifications: - email: - - team@appwrite.io - -before_script: composer install --ignore-platform-reqs - -script: -- vendor/bin/phpunit --configuration phpunit.xml < tests/input.txt -- vendor/bin/psalm --show-info=true diff --git a/composer.json b/composer.json index 49e8f61..12160ff 100755 --- a/composer.json +++ b/composer.json @@ -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"} @@ -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" diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..a76a832 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + level: 5 + paths: + - src + - tests \ No newline at end of file diff --git a/src/CLI/Console.php b/src/CLI/Console.php index 43057bc..e2a47bd 100644 --- a/src/CLI/Console.php +++ b/src/CLI/Console.php @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 @@ -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 */ @@ -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"; diff --git a/tests/CLI/TaskTest.php b/tests/CLI/TaskTest.php index ec15613..ff34454 100755 --- a/tests/CLI/TaskTest.php +++ b/tests/CLI/TaskTest.php @@ -9,7 +9,7 @@ class TaskTest extends TestCase { /** - * @var Task + * @var ?Task */ protected $task;