From 463663f0758744a36ee953ce54729f81d5715d3e Mon Sep 17 00:00:00 2001 From: Pete Boere Date: Thu, 10 Aug 2023 13:04:59 +0100 Subject: [PATCH] Expand workflow. Handle false option for boilerplate. --- .github/workflows/php.yml | 53 +++++++++++++++++++++++++-------------- cli.php | 10 +++++--- composer.json | 3 ++- 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index edd94f4..5170997 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -3,27 +3,42 @@ name: CI on: [push] jobs: - build: + php-api: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Validate composer.json and composer.lock - run: composer validate --strict - - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v2 - with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- + strategy: + matrix: + php-versions: ['7.1', '8.2'] - - name: Install dependencies - run: composer install --prefer-dist --no-progress + steps: + - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + tools: composer:v2 + - name: Validate composer.json and composer.lock + run: composer validate --strict + - name: Install dependencies + run: composer install --prefer-dist --no-progress + - name: Lint + run: composer run-script lint + - name: Test + run: composer run-script test + + js-api: + runs-on: ubuntu-latest - - name: Run test suite - run: composer run-script test + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install dependencies + run: npm install + - name: Lint + run: npm run lint + - name: Check JS + run: npm run types + - name: Test + run: npm run test diff --git a/cli.php b/cli.php index d09d127..9662079 100755 --- a/cli.php +++ b/cli.php @@ -93,7 +93,7 @@ foreach (['boilerplate', 'formatter', 'newlines', 'stat_dump', 'source_map', 'import_path'] as $option) { - if ($args->$option) { + if ($args->$option || $args->$option === false) { $options[$option] = $args->$option; } } @@ -317,7 +317,7 @@ function pick(array &$arr) { foreach ($args as $key) { if (isset($arr[$key])) { - // Optional values return false but we want true is argument is present. + // Optional values return false but we want true if argument is present. return is_bool($arr[$key]) ? true : $arr[$key]; } } @@ -537,8 +537,12 @@ function parse_args() { else { $args->context = $args->input_file ? dirname($args->input_file) : getcwd(); } + if (is_string($args->boilerplate)) { - if (! ($args->boilerplate = realpath($args->boilerplate))) { + if ($args->boilerplate === 'false') { + $args->boilerplate = false; + } + else if (! ($args->boilerplate = realpath($args->boilerplate))) { throw new Exception('Boilerplate file does not exist.', STATUS_ERROR); } } diff --git a/composer.json b/composer.json index b413a5e..8a26477 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,8 @@ "homepage": "http://the-echoplex.net/csscrush", "license": "MIT", "scripts": { - "test": "vendor/bin/phpunit tests" + "test": "vendor/bin/phpunit tests", + "lint": "vendor/bin/phpstan" }, "authors": [ {