From a613bf43237c22e9311cdf4086dd92a6ef299e7b Mon Sep 17 00:00:00 2001 From: Denis Smet Date: Mon, 11 Mar 2024 03:57:34 +0400 Subject: [PATCH 1/3] Build phar binary Build phar binary file and update build settings for Csv-Blueprint. Create symlink for testing. Update box.json.dist and composer.json. --- .github/workflows/main.yml | 36 +++++++++++++++++++++++++ Makefile | 14 +++++++++- box.json.dist | 22 ++++++++++++++++ composer.json | 2 ++ csv-blueprint | 51 +++++++++-------------------------- csv-blueprint.php | 54 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 140 insertions(+), 39 deletions(-) create mode 100644 box.json.dist create mode 100644 csv-blueprint.php diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5cf213ea..b5c389dd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -138,3 +138,39 @@ jobs: with: name: Reports - ${{ matrix.php-version }} path: build/ + + phar: + name: Phar + runs-on: ubuntu-latest + strategy: + matrix: + php-version: [ 8.1, 8.2, 8.3 ] + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: xdebug + tools: composer + extensions: ast + + - name: Build the project + run: make build --no-print-directory + + - name: Building Phar binary file + run: make build-phar --no-print-directory + + - name: Trying to use the phar file + run: ./build/csv-blueprint.phar --help + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + continue-on-error: true + with: + name: Reports - ${{ matrix.php-version }} + path: build/ diff --git a/Makefile b/Makefile index 6629f209..3d1e8fbd 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ # @see https://github.com/JBZoo/Csv-Blueprint # +.PHONY: build ifneq (, $(wildcard ./vendor/jbzoo/codestyle/src/init.Makefile)) include ./vendor/jbzoo/codestyle/src/init.Makefile @@ -17,10 +18,21 @@ endif OUTPUT ?= table -update: ##@Project Install/Update all 3rd party dependencies +build: ##@Project Install all 3rd party dependencies $(call title,"Install/Update all 3rd party dependencies") + @composer install + @make build-phar + @make create-symlink + + +update: ##@Project Install/Update all 3rd party dependencies @echo "Composer flags: $(JBZOO_COMPOSER_UPDATE_FLAGS)" @composer update $(JBZOO_COMPOSER_UPDATE_FLAGS) + @make build-phar + + +create-symlink: ##@Project Create Symlink (alias for testing) + @ln -sfv `pwd`/ci-report-converter `pwd`/vendor/bin/ci-report-converter test-all: ##@Project Run all project tests at once diff --git a/box.json.dist b/box.json.dist new file mode 100644 index 00000000..b7336f27 --- /dev/null +++ b/box.json.dist @@ -0,0 +1,22 @@ +{ + "banner" : [ + "JBZoo Toolbox - Csv-Blueprint", + "", + "This file is part of the JBZoo Toolbox project.", + "For the full copyright and license information, please view the LICENSE", + "file that was distributed with this source code.", + "", + "@package Csv-Blueprint", + "@license MIT", + "@copyright Copyright (C) JBZoo.com, All rights reserved.", + "@link https://github.com/JBZoo/Csv-Blueprint" + ], + + "output" : "build/csv-blueprint.phar", + + "directories" : ["src"], + "files" : ["csv-blueprint.php"], + "git-version" : "git-version", + + "finder" : [{"in" : "vendor"}] +} diff --git a/composer.json b/composer.json index ef26dcbe..9c38208f 100644 --- a/composer.json +++ b/composer.json @@ -42,6 +42,8 @@ "jbzoo/toolbox-dev" : "^7.1" }, + "bin" : ["csv-blueprint"], + "autoload" : { "psr-4" : {"JBZoo\\CsvBlueprint\\" : "src"} }, diff --git a/csv-blueprint b/csv-blueprint index c98a086a..30f40786 100644 --- a/csv-blueprint +++ b/csv-blueprint @@ -1,43 +1,18 @@ #!/usr/bin/env php registerCommandsByPath(PATH_ROOT . '/src/Commands', __NAMESPACE__) - ->setLogo( - <<<'EOF' - _____ ______ _ _ _ - / __ \ | ___ \ | (_) | | - | / \/_____ __ | |_/ / |_ _ ___ _ __ _ __ _ _ __ | |_ - | | / __\ \ / / | ___ \ | | | |/ _ \ '_ \| '__| | '_ \| __| - | \__/\__ \\ V / | |_/ / | |_| | __/ |_) | | | | | | | |_ - \____/___/ \_/ \____/|_|\__,_|\___| .__/|_| |_|_| |_|\__| - | | - |_| - EOF, - ) - ->run(); +require_once __DIR__ . '/csv-blueprint.php'; diff --git a/csv-blueprint.php b/csv-blueprint.php new file mode 100644 index 00000000..330bce06 --- /dev/null +++ b/csv-blueprint.php @@ -0,0 +1,54 @@ +registerCommandsByPath(PATH_ROOT . '/src/Commands', __NAMESPACE__) + ->setLogo( + <<<'EOF' + _____ ______ _ _ _ + / __ \ | ___ \ | (_) | | + | / \/_____ __ | |_/ / |_ _ ___ _ __ _ __ _ _ __ | |_ + | | / __\ \ / / | ___ \ | | | |/ _ \ '_ \| '__| | '_ \| __| + | \__/\__ \\ V / | |_/ / | |_| | __/ |_) | | | | | | | |_ + \____/___/ \_/ \____/|_|\__,_|\___| .__/|_| |_|_| |_|\__| + | | + |_| + EOF, + ) + ->run(); From 280dd4af4309a634f57f4a5839005bcb9aae8a3f Mon Sep 17 00:00:00 2001 From: Denis Smet Date: Mon, 11 Mar 2024 04:01:09 +0400 Subject: [PATCH 2/3] Add phar build and usage workflows Added phar build and usage workflows for building and using the phar file in the project. --- .github/workflows/demo.yml | 22 ++++++++++++++++++++++ .github/workflows/main.yml | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml index 5c2e204a..99138151 100644 --- a/.github/workflows/demo.yml +++ b/.github/workflows/demo.yml @@ -66,3 +66,25 @@ jobs: - name: Validate CSV (junit) run: OUTPUT=junit make demo-github continue-on-error: true + + phar: + name: Phar + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.3 + tools: composer + + - name: Build the project + run: make build --no-print-directory + + - name: Trying to use the phar file + run: ./build/csv-blueprint.phar validate:csv --csv=./tests/fixtures/demo.csv --schema=./tests/schemas/demo_invalid.yml + continue-on-error: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b5c389dd..bc869c47 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -166,7 +166,7 @@ jobs: run: make build-phar --no-print-directory - name: Trying to use the phar file - run: ./build/csv-blueprint.phar --help + run: ./build/csv-blueprint.phar - name: Upload Artifacts uses: actions/upload-artifact@v3 From 38b4883f8ea0afbb0b6e00f657cefcb18f14fc00 Mon Sep 17 00:00:00 2001 From: Denis Smet Date: Mon, 11 Mar 2024 04:06:11 +0400 Subject: [PATCH 3/3] Add symfony/yaml to dependencies and symlink for testing - Add symfony/yaml to composer.json dependencies - Create a symlink for csv-blueprint for testing purposes - Update content-hash in composer.lock --- Makefile | 2 +- composer.json | 3 +- composer.lock | 146 +++++++++++++++++++++++++------------------------- 3 files changed, 76 insertions(+), 75 deletions(-) diff --git a/Makefile b/Makefile index 3d1e8fbd..2f8cfa4d 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ update: ##@Project Install/Update all 3rd party dependencies create-symlink: ##@Project Create Symlink (alias for testing) - @ln -sfv `pwd`/ci-report-converter `pwd`/vendor/bin/ci-report-converter + @ln -sfv `pwd`/csv-blueprint `pwd`/vendor/bin/csv-blueprint test-all: ##@Project Run all project tests at once diff --git a/composer.json b/composer.json index 9c38208f..f1085b3d 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,8 @@ "jbzoo/utils" : "^7.1", "jbzoo/ci-report-converter" : "^7.2", "league/csv" : "^9.15", - "fakerphp/faker" : "^1.23" + "fakerphp/faker" : "^1.23", + "symfony/yaml" : "^6.4" }, "require-dev" : { diff --git a/composer.lock b/composer.lock index b3c61e26..9ff9a5bd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "aa2d64e2d78d191e4bc83a4ad90051b6", + "content-hash": "b20133b2673ce83b855f63c4993bcf8d", "packages": [ { "name": "bluepsyduck/symfony-process-manager", @@ -1665,6 +1665,78 @@ } ], "time": "2024-02-01T13:16:41+00:00" + }, + { + "name": "symfony/yaml", + "version": "v6.4.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "d75715985f0f94f978e3a8fa42533e10db921b90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/d75715985f0f94f978e3a8fa42533e10db921b90", + "reference": "d75715985f0f94f978e3a8fa42533e10db921b90", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "symfony/console": "<5.4" + }, + "require-dev": { + "symfony/console": "^5.4|^6.0|^7.0" + }, + "bin": [ + "Resources/bin/yaml-lint" + ], + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Loads and dumps YAML files", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/yaml/tree/v6.4.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-23T14:51:35+00:00" } ], "packages-dev": [ @@ -7790,78 +7862,6 @@ ], "time": "2024-02-26T08:37:45+00:00" }, - { - "name": "symfony/yaml", - "version": "v6.4.3", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "d75715985f0f94f978e3a8fa42533e10db921b90" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/d75715985f0f94f978e3a8fa42533e10db921b90", - "reference": "d75715985f0f94f978e3a8fa42533e10db921b90", - "shasum": "" - }, - "require": { - "php": ">=8.1", - "symfony/deprecation-contracts": "^2.5|^3", - "symfony/polyfill-ctype": "^1.8" - }, - "conflict": { - "symfony/console": "<5.4" - }, - "require-dev": { - "symfony/console": "^5.4|^6.0|^7.0" - }, - "bin": [ - "Resources/bin/yaml-lint" - ], - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Loads and dumps YAML files", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/yaml/tree/v6.4.3" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-01-23T14:51:35+00:00" - }, { "name": "theseer/tokenizer", "version": "1.2.3",