Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build phar binary #3

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
36 changes: 36 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

- name: Upload Artifacts
uses: actions/upload-artifact@v3
continue-on-error: true
with:
name: Reports - ${{ matrix.php-version }}
path: build/
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,29 @@
# @see https://github.com/JBZoo/Csv-Blueprint
#

.PHONY: build

ifneq (, $(wildcard ./vendor/jbzoo/codestyle/src/init.Makefile))
include ./vendor/jbzoo/codestyle/src/init.Makefile
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`/csv-blueprint `pwd`/vendor/bin/csv-blueprint


test-all: ##@Project Run all project tests at once
Expand Down
22 changes: 22 additions & 0 deletions box.json.dist
Original file line number Diff line number Diff line change
@@ -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"}]
}
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@
"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" : {
"roave/security-advisories" : "dev-latest",
"jbzoo/toolbox-dev" : "^7.1"
},

"bin" : ["csv-blueprint"],

"autoload" : {
"psr-4" : {"JBZoo\\CsvBlueprint\\" : "src"}
},
Expand Down
146 changes: 73 additions & 73 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 13 additions & 38 deletions csv-blueprint
Original file line number Diff line number Diff line change
@@ -1,43 +1,18 @@
#!/usr/bin/env php
<?php

declare(strict_types=1);

namespace JBZoo\CsvBlueprint;

use JBZoo\Cli\CliApplication;

\define('PATH_ROOT', __DIR__);
/**
* 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.
*
* @license MIT
* @copyright Copyright (C) JBZoo.com, All rights reserved.
* @see https://github.com/JBZoo/Csv-Blueprint
*/

$vendorPaths = [
__DIR__ . '/../../autoload.php',
__DIR__ . '/../vendor/autoload.php',
__DIR__ . '/vendor/autoload.php',
];

foreach ($vendorPaths as $file) {
if (\file_exists($file)) {
\define('JBZOO_AUTOLOAD_FILE', $file);
break;
}
}

require_once JBZOO_AUTOLOAD_FILE;

\date_default_timezone_set('UTC');
declare(strict_types=1);

(new CliApplication('CSV Blueprint', '@git-version@'))
->registerCommandsByPath(PATH_ROOT . '/src/Commands', __NAMESPACE__)
->setLogo(
<<<'EOF'
_____ ______ _ _ _
/ __ \ | ___ \ | (_) | |
| / \/_____ __ | |_/ / |_ _ ___ _ __ _ __ _ _ __ | |_
| | / __\ \ / / | ___ \ | | | |/ _ \ '_ \| '__| | '_ \| __|
| \__/\__ \\ V / | |_/ / | |_| | __/ |_) | | | | | | | |_
\____/___/ \_/ \____/|_|\__,_|\___| .__/|_| |_|_| |_|\__|
| |
|_|
EOF,
)
->run();
require_once __DIR__ . '/csv-blueprint.php';
Loading
Loading