Skip to content

Commit

Permalink
Expand workflow.
Browse files Browse the repository at this point in the history
Handle false option for boilerplate.
  • Loading branch information
peteboere committed Aug 10, 2023
1 parent 60b6977 commit e6be71a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 24 deletions.
53 changes: 34 additions & 19 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 --ignore-platform-reqs
- 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
10 changes: 7 additions & 3 deletions cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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];
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
2 changes: 1 addition & 1 deletion js/tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('csscrush.file', () => {
});
});

describe('csscrush.watch', {only: true}, () => {
describe('csscrush.watch', () => {

it('should minify CSS text', async () => {

Expand Down

0 comments on commit e6be71a

Please sign in to comment.