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 and test Docket image #4

Merged
merged 20 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
83c296c
Refactor Dockerfile, makefile and workflows configuration to use csv-…
Mar 11, 2024
410d0e7
Fix Docker Image and Makefile
Mar 11, 2024
55e8e76
Update Symfony components to version 6.4.4
Mar 11, 2024
1978384
Update docker image tag in release workflow
Mar 11, 2024
4252d92
Add DockerHub login and build and push steps to main.yml workflow.
Mar 11, 2024
aee0e6d
Update release-docker.yml for Csv-Blueprint project.
Mar 11, 2024
c7db9a2
Refactor Docker image tag and add a new command
Mar 11, 2024
20e8394
Remove ANSICON environment variable setting from csv-blueprint.php.
Mar 11, 2024
d91174f
Refactor Docker execution in workflow and Makefile
Mar 11, 2024
2e8b3ce
Fix typo in README.md and full.yml for "Deciaml" to "Decimal" in comm…
Mar 11, 2024
017a7d7
Add Docker container usage to README and update PHPUnit test setup.
Mar 11, 2024
df1df74
Add push event on master branch for Docker image release workflow.
Mar 11, 2024
730c8a1
Add build and test instructions for phar and docker image
Mar 11, 2024
caa6192
Fix indentation and add line breaks for readability.
Mar 11, 2024
2f8775c
Fix typo in demo.yml file
Mar 11, 2024
48c0f3a
Refactor GitHub workflow to include different types of reports
Mar 11, 2024
d988b0d
Add validation steps for valid and invalid CSV files
Mar 11, 2024
d6c213e
Update job name to "All Reports" in demo workflow
Mar 11, 2024
f26dbaa
Refactor report names in demo.yml & improve build command in Makefile
Mar 11, 2024
a96a111
Refactor report names in demo.yml & improve build command in Makefile
Mar 11, 2024
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
29 changes: 29 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# JBZoo Toolbox - CI-Report-Converter.
#
# 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/CI-Report-Converter
#

.git
.idea
.github
build
tests
vendor
schema-examples
.DS_Store
.editorconfig
.gitattributes
.gitignore
.phan.php
.phpunit.result.cache
action.yml
box.json.dist
phpunit.xml.dist
Makefile
107 changes: 91 additions & 16 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ env:
TERM_PROGRAM: Hyper

jobs:
pure-php:
name: Pure PHP
reports:
name: All Report Types
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -43,28 +43,61 @@ jobs:
- name: Build the Project
run: make update

- name: Validate CSV (default is table)
run: make demo-github
- name: Report - Table (Default)
run: make demo-github --no-print-directory
continue-on-error: true

- name: Validate CSV (text)
run: OUTPUT=text make demo-github
- name: Report - Text
run: OUTPUT=text make demo-github --no-print-directory
continue-on-error: true

- name: Validate CSV (github)
run: OUTPUT=github make demo-github
- name: Report - Github Actions
run: OUTPUT=github make demo-github --no-print-directory
continue-on-error: true

- name: Validate CSV (gitlab)
run: OUTPUT=gitlab make demo-github
- name: Report - GitLab
run: OUTPUT=gitlab make demo-github --no-print-directory
continue-on-error: true

- name: Validate CSV (teamcity)
run: OUTPUT=teamcity make demo-github
- name: Report - TeamCity CI
run: OUTPUT=teamcity make demo-github --no-print-directory
continue-on-error: true

- name: Validate CSV (junit)
run: OUTPUT=junit make demo-github
- name: Report - JUnit
run: OUTPUT=junit make demo-github --no-print-directory
continue-on-error: true

php:
name: Pure PHP
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-install --no-print-directory

- name: 👍 Valid CSV file
run: |
./csv-blueprint \
validate:csv \
--csv=./tests/fixtures/demo.csv \
--schema=./tests/schemas/demo_valid.yml

- name: 👎 Invalid CSV file
run: |
./csv-blueprint \
validate:csv \
--csv=./tests/fixtures/demo.csv \
--schema=./tests/schemas/demo_invalid.yml
continue-on-error: true

phar:
Expand All @@ -85,6 +118,48 @@ jobs:
- 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
- name: 👍 Valid CSV file
run: |
./build/csv-blueprint.phar \
validate:csv \
--csv=./tests/fixtures/demo.csv \
--schema=./tests/schemas/demo_valid.yml

- name: 👎 Invalid CSV file
run: |
./build/csv-blueprint.phar \
validate:csv \
--csv=./tests/fixtures/demo.csv \
--schema=./tests/schemas/demo_invalid.yml
continue-on-error: true

docker:
name: Docker
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: 🐳 Building Docker Image
run: make build-docker

- name: 👍 Valid CSV file
run: |
docker run \
-v `pwd`:/parent-host \
--rm jbzoo/csv-blueprint \
validate:csv \
--csv=/parent-host/tests/fixtures/demo.csv \
--schema=/parent-host/tests/schemas/demo_valid.yml

- name: 👎 Invalid CSV file
run: |
docker run \
-v `pwd`:/parent-host \
--rm jbzoo/csv-blueprint \
validate:csv \
--csv=/parent-host/tests/fixtures/demo.csv \
--schema=/parent-host/tests/schemas/demo_invalid.yml
continue-on-error: true
19 changes: 19 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,22 @@ jobs:
with:
name: Reports - ${{ matrix.php-version }}
path: build/

docker:
name: Docker
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: 🐳 Building Docker Image
run: make build-docker

- name: Trying to use the Docker Image
run: docker run --rm jbzoo/csv-blueprint --ansi

- name: Reporting example via Docker
run: make demo-docker --no-print-directory
continue-on-error: true
36 changes: 36 additions & 0 deletions .github/workflows/release-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# 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
#

name: Publish Docker Image

on:
release:
types: [ published ]
push:
branches:
- 'master'

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: jbzoo/csv-blueprint:${{ env.GITHUB_REF_NAME }}
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# 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
#

FROM php:8.1-cli-alpine
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

# Install PHP extensions
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN install-php-extensions opcache gd @composer

# Install application
ENV COMPOSER_ALLOW_SUPERUSER=1
COPY . /app
RUN cd /app \
&& composer install --no-dev --optimize-autoloader --no-progress \
&& composer clear-cache
RUN chmod +x app/csv-blueprint

# Color output by default
ENV TERM_PROGRAM=Hyper

ENTRYPOINT ["/app/csv-blueprint"]
33 changes: 28 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,53 @@ build: ##@Project Install all 3rd party dependencies
$(call title,"Install/Update all 3rd party dependencies")
@composer install
@make build-phar
@make create-symlink
@rm -f `pwd`/ci-report-converter

build-install: ##@Project Install all 3rd party dependencies as prod
$(call title,"Install/Update all 3rd party dependencies as prod")
@composer install --no-dev --no-progress --no-interaction --no-suggest
@rm -f `pwd`/ci-report-converter

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
@make test
@make codestyle


build-docker:
$(call title,"Building Docker Image")
@docker build -t jbzoo/csv-blueprint .


demo-valid: ##@Project Run demo valid CSV
$(call title,"Demo - Valid CSV")
@${PHP_BIN} ./csv-blueprint validate:csv \
--csv=./tests/fixtures/demo.csv \
--schema=./tests/schemas/demo_valid.yml

demo-docker: ##@Project Run demo via Docker
$(call title,"Demo - Valid CSV \(via Docker\)")
@docker run --rm \
-v `pwd`:/parent-host \
jbzoo/csv-blueprint \
validate:csv \
--csv=/parent-host/tests/fixtures/demo.csv \
--schema=/parent-host/tests/schemas/demo_valid.yml \
--ansi
$(call title,"Demo - Invalid CSV \(via Docker\)")
@docker run --rm \
-v `pwd`:/parent-host \
jbzoo/csv-blueprint \
validate:csv \
--csv=/parent-host/tests/fixtures/demo.csv \
--schema=/parent-host/tests/schemas/demo_invalid.yml \
--ansi


demo-invalid: ##@Project Run demo invalid CSV
$(call title,"Demo - Invalid CSV")
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# JBZoo / Csv-Blueprint

[![CI](https://github.com/JBZoo/Csv-Blueprint/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/JBZoo/Csv-Blueprint/actions/workflows/main.yml?query=branch%3Amaster) [![Coverage Status](https://coveralls.io/repos/github/JBZoo/Csv-Blueprint/badge.svg?branch=master)](https://coveralls.io/github/JBZoo/Csv-Blueprint?branch=master) [![Psalm Coverage](https://shepherd.dev/github/JBZoo/Csv-Blueprint/coverage.svg)](https://shepherd.dev/github/JBZoo/Csv-Blueprint) [![Psalm Level](https://shepherd.dev/github/JBZoo/Csv-Blueprint/level.svg)](https://shepherd.dev/github/JBZoo/Csv-Blueprint) [![CodeFactor](https://www.codefactor.io/repository/github/jbzoo/csv-blueprint/badge)](https://www.codefactor.io/repository/github/jbzoo/csv-blueprint/issues)
[![Stable Version](https://poser.pugx.org/jbzoo/csv-blueprint/version)](https://packagist.org/packages/jbzoo/csv-blueprint/) [![Total Downloads](https://poser.pugx.org/jbzoo/csv-blueprint/downloads)](https://packagist.org/packages/jbzoo/csv-blueprint/stats) [![Dependents](https://poser.pugx.org/jbzoo/csv-blueprint/dependents)](https://packagist.org/packages/jbzoo/csv-blueprint/dependents?order_by=downloads) [![GitHub License](https://img.shields.io/github/license/jbzoo/csv-blueprint)](https://github.com/JBZoo/Csv-Blueprint/blob/master/LICENSE)
[![Stable Version](https://poser.pugx.org/jbzoo/csv-blueprint/version)](https://packagist.org/packages/jbzoo/csv-blueprint/) [![Total Downloads](https://poser.pugx.org/jbzoo/csv-blueprint/downloads)](https://packagist.org/packages/jbzoo/csv-blueprint/stats) [![Docker Pulls](https://img.shields.io/docker/pulls/jbzoo/csv-blueprint.svg)](https://hub.docker.com/r/jbzoo/csv-blueprint) [![Dependents](https://poser.pugx.org/jbzoo/csv-blueprint/dependents)](https://packagist.org/packages/jbzoo/csv-blueprint/dependents?order_by=downloads) [![GitHub License](https://img.shields.io/github/license/jbzoo/csv-blueprint)](https://github.com/JBZoo/Csv-Blueprint/blob/master/LICENSE)



Expand All @@ -15,6 +15,18 @@ composer require jbzoo/csv-blueprint

### Usage

As Docker container:

```sh
@docker run --rm \
-v `pwd`:/parent-host \
jbzoo/csv-blueprint \
validate:csv \
--csv=/parent-host/tests/fixtures/demo.csv \
--schema=/parent-host/tests/schemas/demo_invalid.yml \
--ansi
```


### Schema file examples

Expand Down Expand Up @@ -55,7 +67,7 @@ columns:
only_uppercase: true # String is only upper-case. Example: "HELLO WORLD"
only_capitalize: true # String is only capitalized. Example: "Hello World"

# Deciaml and integer numbers
# Decimal and integer numbers
min: 10 # Can be integer or float, negative and positive
max: 100.50 # Can be integer or float, negative and positive
precision: 2 # Strict(!) number of digits after the decimal point
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@

"config" : {
"optimize-autoloader" : true,
"allow-plugins" : {"composer/package-versions-deprecated" : true}
"allow-plugins" : {"composer/package-versions-deprecated" : true},
"platform-check" : true
},

"extra" : {
Expand Down
Loading
Loading