Skip to content

Commit b17a039

Browse files
authored
Build Docker image (#1)
* Building Docker Image * New simple tests for Phar file and Docker * New structure of tests in Github Actions * New badges on Readme file
1 parent 3e7f8e1 commit b17a039

6 files changed

Lines changed: 206 additions & 7 deletions

File tree

.dockerignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# JBZoo Toolbox - CI-Report-Converter
3+
#
4+
# This file is part of the JBZoo Toolbox project.
5+
# For the full copyright and license information, please view the LICENSE
6+
# file that was distributed with this source code.
7+
#
8+
# @package CI-Report-Converter
9+
# @license MIT
10+
# @copyright Copyright (C) JBZoo.com, All rights reserved.
11+
# @link https://github.com/JBZoo/CI-Report-Converter
12+
#
13+
14+
.idea
15+
.phan
16+
vendor

.github/workflows/main.yml

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# @link https://github.com/JBZoo/CI-Report-Converter
1212
#
1313

14-
name: Continuous Integration
14+
name: CI
1515

1616
on:
1717
pull_request:
@@ -28,7 +28,7 @@ env:
2828
TERM_PROGRAM: Hyper
2929

3030
jobs:
31-
phpunit:
31+
genetal:
3232
name: PHPUnit Tests
3333
runs-on: ubuntu-latest
3434
env:
@@ -65,6 +65,96 @@ jobs:
6565
continue-on-error: ${{ matrix.experimental }}
6666
run: make test --no-print-directory
6767

68+
69+
linters:
70+
name: Liters
71+
runs-on: ubuntu-latest
72+
strategy:
73+
matrix:
74+
php-version: [ 7.4 ]
75+
experimental: [ false ]
76+
include:
77+
- php-version: "8.0"
78+
experimental: true
79+
- php-version: "8.1"
80+
experimental: true
81+
steps:
82+
- name: Checkout code
83+
uses: actions/checkout@v2
84+
with:
85+
fetch-depth: 0
86+
87+
- name: Setup PHP and composer
88+
uses: shivammathur/setup-php@v2
89+
with:
90+
php-version: ${{ matrix.php-version }}
91+
tools: composer
92+
93+
- name: Build the Project
94+
continue-on-error: ${{ matrix.experimental }}
95+
run: make update --no-print-directory
96+
6897
- name: 👍 Code Quality
6998
continue-on-error: ${{ matrix.experimental }}
7099
run: make codestyle --no-print-directory
100+
101+
102+
phar:
103+
name: Phar
104+
runs-on: ubuntu-latest
105+
strategy:
106+
matrix:
107+
php-version: [ 7.2, 7.3, 7.4 ]
108+
experimental: [ false ]
109+
include:
110+
- php-version: "8.0"
111+
experimental: true
112+
- php-version: "8.1"
113+
experimental: true
114+
steps:
115+
- name: Checkout code
116+
uses: actions/checkout@v2
117+
with:
118+
fetch-depth: 0
119+
120+
- name: Setup PHP and composer
121+
uses: shivammathur/setup-php@v2
122+
with:
123+
php-version: ${{ matrix.php-version }}
124+
tools: composer
125+
126+
- name: Building Phar binary file
127+
continue-on-error: ${{ matrix.experimental }}
128+
run: make build --no-print-directory
129+
130+
- name: Trying to use the phar file
131+
continue-on-error: ${{ matrix.experimental }}
132+
run: |
133+
echo "::group::Try to run it"
134+
./build/ci-report-converter.phar
135+
echo "::endgroup::"
136+
echo "::group::Show help message"
137+
./build/ci-report-converter.phar --help
138+
echo "::endgroup::"
139+
140+
141+
docker:
142+
name: Docker
143+
runs-on: ubuntu-latest
144+
steps:
145+
- name: Checkout code
146+
uses: actions/checkout@v2
147+
with:
148+
fetch-depth: 0
149+
150+
- name: 🐳 Building Docker Image
151+
run: make build-docker
152+
153+
- name: Trying to use the Docker Image
154+
run: |
155+
echo "::group::Try to run it"
156+
docker run --rm jbzoo-ci-report-converter
157+
echo "::endgroup::"
158+
echo "::group::Show help message"
159+
docker run --rm jbzoo-ci-report-converter convert --help
160+
echo "::endgroup::"

Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# JBZoo Toolbox - Mock-Server
3+
#
4+
# This file is part of the JBZoo Toolbox project.
5+
# For the full copyright and license information, please view the LICENSE
6+
# file that was distributed with this source code.
7+
#
8+
# @package Mock-Server
9+
# @license MIT
10+
# @copyright Copyright (C) JBZoo.com, All rights reserved.
11+
# @link https://github.com/JBZoo/Mock-Server
12+
#
13+
14+
FROM php:7.4-cli-alpine
15+
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
16+
17+
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
18+
RUN chmod +x /usr/local/bin/install-php-extensions \
19+
&& sync \
20+
&& install-php-extensions \
21+
opcache \
22+
zip \
23+
@composer
24+
25+
ENV COMPOSER_ALLOW_SUPERUSER=1
26+
COPY . /app
27+
RUN cd /app \
28+
&& composer install --no-dev --optimize-autoloader --no-progress \
29+
&& composer clear-cache
30+
31+
# Experimental. Forced colored output
32+
ENV TERM_PROGRAM=Hyper
33+
34+
ENTRYPOINT ["/app/ci-report-converter"]

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ build: ##@Project Install all 3rd party dependencies
2424
@make create-symlink
2525

2626

27+
build-docker:
28+
$(call title,"Building Docker Image")
29+
@docker build -t jbzoo-ci-report-converter .
30+
31+
2732
update: ##@Project Install/Update all 3rd party dependencies
2833
@echo "Composer flags: $(JBZOO_COMPOSER_UPDATE_FLAGS)"
2934
@composer update --optimize-autoloader --no-progress $(JBZOO_COMPOSER_UPDATE_FLAGS)

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
# JBZoo / CI-Report-Converter
22

3-
[![Build Status](https://travis-ci.org/JBZoo/CI-Report-Converter.svg?branch=master)](https://travis-ci.org/JBZoo/CI-Report-Converter) [![Coverage Status](https://coveralls.io/repos/JBZoo/CI-Report-Converter/badge.svg)](https://coveralls.io/github/JBZoo/CI-Report-Converter) [![Psalm Coverage](https://shepherd.dev/github/JBZoo/CI-Report-Converter/coverage.svg)](https://shepherd.dev/github/JBZoo/CI-Report-Converter) [![PHP Strict Types](https://img.shields.io/badge/strict__types-%3D1-brightgreen)](https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.strict)
4-
[![Stable Version](https://poser.pugx.org/jbzoo/ci-report-converter/version)](https://packagist.org/packages/jbzoo/ci-report-converter) [![Latest Unstable Version](https://poser.pugx.org/jbzoo/ci-report-converter/v/unstable)](https://packagist.org/packages/jbzoo/ci-report-converter) [![Dependents](https://poser.pugx.org/jbzoo/ci-report-converter/dependents)](https://packagist.org/packages/jbzoo/ci-report-converter/dependents?order_by=downloads) [![GitHub Issues](https://img.shields.io/github/issues/jbzoo/ci-report-converter)](https://github.com/JBZoo/CI-Report-Converter/issues) [![Total Downloads](https://poser.pugx.org/jbzoo/ci-report-converter/downloads)](https://packagist.org/packages/jbzoo/ci-report-converter/stats) [![GitHub License](https://img.shields.io/github/license/jbzoo/ci-report-converter)](https://github.com/JBZoo/CI-Report-Converter/blob/master/LICENSE)
3+
[![Travis](https://travis-ci.org/JBZoo/CI-Report-Converter.svg?branch=master)](https://travis-ci.org/JBZoo/CI-Report-Converter) [![CI](https://github.com/JBZoo/CI-Report-Converter/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/JBZoo/CI-Report-Converter/actions/workflows/main.yml) [![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/jbzoo/ci-report-converter.svg)](https://hub.docker.com/r/jbzoo/ci-report-converter) [![Coverage Status](https://coveralls.io/repos/JBZoo/CI-Report-Converter/badge.svg)](https://coveralls.io/github/JBZoo/CI-Report-Converter) [![Psalm Coverage](https://shepherd.dev/github/JBZoo/CI-Report-Converter/coverage.svg)](https://shepherd.dev/github/JBZoo/CI-Report-Converter) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/jbzoo/ci-report-converter/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/jbzoo/ci-report-converter/?branch=master) [![PHP Strict Types](https://img.shields.io/badge/strict__types-%3D1-brightgreen)](https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.strict)
4+
[![PHP Version](https://img.shields.io/packagist/php-v/jbzoo/ci-report-converter)](https://github.com/JBZoo/CI-Report-Converter/blob/master/composer.json) [![Stable Version](https://poser.pugx.org/jbzoo/ci-report-converter/version)](https://packagist.org/packages/jbzoo/ci-report-converter) [![Total Downloads](https://poser.pugx.org/jbzoo/ci-report-converter/downloads)](https://packagist.org/packages/jbzoo/ci-report-converter/stats) [![Docker Pulls](https://img.shields.io/docker/pulls/jbzoo/ci-report-converter.svg)](https://hub.docker.com/r/jbzoo/ci-report-converter) [![GitHub Issues](https://img.shields.io/github/issues/jbzoo/ci-report-converter)](https://github.com/JBZoo/CI-Report-Converter/issues) [![GitHub License](https://img.shields.io/github/license/jbzoo/ci-report-converter)](https://github.com/JBZoo/CI-Report-Converter/blob/master/LICENSE)
55

66

77

88
### Installing
99

1010
```sh
1111
composer require jbzoo/ci-report-converter
12+
php ./vendor/bin/ci-report-converter --help
1213

13-
# OR use phar file.
14+
# OR use phar file
1415
wget https://github.com/JBZoo/CI-Report-Converter/releases/latest/download/ci-report-converter.phar
16+
php ./ci-report-converter.phar --help
17+
18+
# OR just pull the Docker Image
19+
docker run --rm jbzoo/ci-report-converter --help
1520
```
1621

1722

tests/CiReportConverterReadmeTest.php

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
namespace JBZoo\PHPUnit;
1919

20+
use JBZoo\CiReportConverter\Converters\Map;
2021
use JBZoo\MermaidPHP\Graph;
2122
use JBZoo\MermaidPHP\Helper;
2223
use JBZoo\MermaidPHP\Link;
2324
use JBZoo\MermaidPHP\Node;
24-
use JBZoo\CiReportConverter\Converters\Map;
2525

2626
/**
2727
* Class CiReportConverterReadmeTest
@@ -35,6 +35,26 @@ class CiReportConverterReadmeTest extends AbstractReadmeTest
3535
*/
3636
protected $packageName = 'CI-Report-Converter';
3737

38+
/**
39+
* @var string[]
40+
*/
41+
protected $badgesTemplate = [
42+
'travis',
43+
'github_actions',
44+
'docker_build',
45+
'coveralls',
46+
'psalm_coverage',
47+
'scrutinizer',
48+
'strict_types',
49+
'__BR__',
50+
'php_version',
51+
'latest_stable_version',
52+
'total_downloads',
53+
'docker_pulls',
54+
'github_issues',
55+
'github_license',
56+
];
57+
3858
/**
3959
* @inheritDoc
4060
*/
@@ -43,6 +63,11 @@ protected function setUp(): void
4363
parent::setUp();
4464

4565
$this->params['strict_types'] = true;
66+
$this->params['docker_build'] = true;
67+
$this->params['docker_pulls'] = true;
68+
$this->params['github_actions'] = true;
69+
$this->params['scrutinizer'] = true;
70+
$this->params['php_version'] = true;
4671
}
4772

4873
/**
@@ -51,12 +76,36 @@ protected function setUp(): void
5176
protected function checkBadgeTravis(): ?string
5277
{
5378
return $this->getPreparedBadge($this->getBadge(
54-
'Build Status',
79+
'Travis',
5580
'https://travis-ci.org/__VENDOR_ORIG__/__PACKAGE_ORIG__.svg?branch=master',
5681
'https://travis-ci.org/__VENDOR_ORIG__/__PACKAGE_ORIG__'
5782
));
5883
}
5984

85+
/**
86+
* @return string|null
87+
*/
88+
protected function checkBadgeGithubActions(): ?string
89+
{
90+
return $this->getPreparedBadge($this->getBadge(
91+
'CI',
92+
'https://github.com/__VENDOR_ORIG__/__PACKAGE_ORIG__/actions/workflows/main.yml/badge.svg?branch=master',
93+
'https://github.com/__VENDOR_ORIG__/__PACKAGE_ORIG__/actions/workflows/main.yml'
94+
));
95+
}
96+
97+
/**
98+
* @return string|null
99+
*/
100+
protected function checkBadgePhpVersion(): ?string
101+
{
102+
return $this->getPreparedBadge($this->getBadge(
103+
'PHP Version',
104+
'https://img.shields.io/packagist/php-v/__VENDOR__/__PACKAGE__',
105+
'https://github.com/__VENDOR_ORIG__/__PACKAGE_ORIG__/blob/master/composer.json'
106+
));
107+
}
108+
60109
public function testMapTable()
61110
{
62111
isFileContains(Map::getMarkdownTable(), PROJECT_ROOT . '/README.md');

0 commit comments

Comments
 (0)