From 17ca7a33b48cf20d03641cc3ef4c00a723e0b15f Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 24 Mar 2024 06:00:56 +0000 Subject: [PATCH 1/7] move test to github action --- .github/workflows/test.yml | 31 +++++++++++++++++++++++++++++++ .travis.yml | 15 --------------- 2 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..fe18408 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,31 @@ +name: "Tests" + +on: [pull_request] +jobs: + lint: + name: Tests ${{ matrix.php-versions }} + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: ['8.1', '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: vendor/bin/phpunit --configuration phpunit.xml < tests/input.txt + + - name: Run Psalm + run: vendor/bin/psalm --show-info=true \ No newline at end of file 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 From 012dab6271937b8189a4c105ddebecb76c501e31 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 24 Mar 2024 06:07:39 +0000 Subject: [PATCH 2/7] update to use phpstan and add codeql workflow --- .github/workflows/codeql.yml | 16 ++++++++++++++++ .github/workflows/test.yml | 5 +---- composer.json | 3 ++- 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/codeql.yml 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 index fe18408..f6652d4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,4 @@ jobs: run: composer install --ignore-platform-reqs - name: Run tests - run: vendor/bin/phpunit --configuration phpunit.xml < tests/input.txt - - - name: Run Psalm - run: vendor/bin/psalm --show-info=true \ No newline at end of file + run: composer test \ No newline at end of file diff --git a/composer.json b/composer.json index 49e8f61..4a61246 100755 --- a/composer.json +++ b/composer.json @@ -7,6 +7,7 @@ "scripts": { "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" }, @@ -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" From 35f2dc915ceee4ec8a47342d9e85fb05744155f3 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 24 Mar 2024 06:12:12 +0000 Subject: [PATCH 3/7] phpstan config --- phpstan.neon | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 phpstan.neon 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 From b9f3a1a14ed57c018a1f24b5a1f9481f720c8b24 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 24 Mar 2024 06:12:18 +0000 Subject: [PATCH 4/7] fix codeql errors --- src/CLI/Console.php | 17 ++++++++--------- tests/CLI/TaskTest.php | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) 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; From 998bb8fbe61899606dc2d61a0c57e1153fcb4cdf Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 24 Mar 2024 06:13:49 +0000 Subject: [PATCH 5/7] fix script --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 4a61246..b8adb7d 100755 --- a/composer.json +++ b/composer.json @@ -6,10 +6,10 @@ "license": "MIT", "scripts": { - "test": ".vendor/bin/phpunit --configuration phpunit.xml < tests/input.txt", + "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" + "lint": ".vendor/bin/pint --test", + "format": "vendor/bin/pint" }, "autoload": { "psr-4": {"Utopia\\CLI\\": "src/CLI"} From 8b0b9e4d326ee133a7d40303b57c4277b5e5c550 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 24 Mar 2024 06:14:50 +0000 Subject: [PATCH 6/7] fix script --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b8adb7d..12160ff 100755 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "scripts": { "test": "vendor/bin/phpunit --configuration phpunit.xml < tests/input.txt", "check": "vendor/bin/phpstan analyse -c phpstan.neon", - "lint": ".vendor/bin/pint --test", + "lint": "vendor/bin/pint --test", "format": "vendor/bin/pint" }, "autoload": { From 9c51e5870f047e768e10a83b9a3603d5cbb8b9e6 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 24 Mar 2024 12:14:59 +0545 Subject: [PATCH 7/7] Update test.yml --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f6652d4..5babce5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['8.1', '8.3', 'nightly'] + php-versions: ['8.1', '8.2', '8.3', 'nightly'] steps: - name: Checkout repository @@ -25,4 +25,4 @@ jobs: run: composer install --ignore-platform-reqs - name: Run tests - run: composer test \ No newline at end of file + run: composer test