Skip to content

Commit c43fdd4

Browse files
authored
Add Dockerfile + upgrade composer + upgrade php to 7.4 + fix
1 parent 2a6e379 commit c43fdd4

File tree

8 files changed

+1870
-740
lines changed

8 files changed

+1870
-740
lines changed

.circleci/config.yml

Lines changed: 56 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,60 @@ version: 2.1
22

33
jobs:
44
build:
5-
docker:
6-
- image: akeneo/php:7.2
5+
machine:
6+
image: ubuntu-2004:202111-01
77
steps:
8-
- checkout
9-
- run: composer install
8+
- run:
9+
name: Change rights on project dir
10+
command: sudo chmod -R 777 ../project
11+
- checkout
12+
- run:
13+
name: Build project
14+
command: make dependencies
1015
- persist_to_workspace:
1116
root: ~/
1217
paths:
1318
- project
19+
test_php_unit:
20+
machine:
21+
image: ubuntu-2004:202111-01
22+
steps:
23+
- attach_workspace:
24+
at: ~/
25+
- run:
26+
name: Run PHPUnit tests
27+
command: make unit
1428

15-
test_php:
16-
docker:
17-
- image: akeneo/php:7.2
29+
test_php_spec:
30+
machine:
31+
image: ubuntu-2004:202111-01
1832
steps:
1933
- attach_workspace:
2034
at: ~/
21-
- run: bin/phpunit -c phpunit.xml.dist
22-
- run: bin/phpspec run
35+
- run:
36+
name: Run PHPSpec tests
37+
command: make spec
2338

2439
test_php_code_style:
25-
docker:
26-
- image: akeneo/php:7.2
40+
machine:
41+
image: ubuntu-2004:202111-01
2742
steps:
2843
- attach_workspace:
2944
at: ~/
30-
- run: bin/php-cs-fixer fix --diff --dry-run --config=.php_cs.php -vvv
45+
- run:
46+
name: Change rights on project dir
47+
command: sudo chmod -R 777 ../project
48+
- run:
49+
name: Launch code style checker
50+
command: make cs
3151

3252
workflow_success:
33-
docker:
34-
- image: akeneo/php:7.2
53+
machine:
54+
image: ubuntu-2004:202111-01
3555
steps:
36-
- run:
37-
name: Success
38-
command: echo "The build has run with success! Let's merge :)"
56+
- run:
57+
name: Success
58+
command: echo "The build has run with success! Let's merge :)"
3959

4060
workflows:
4161
pull_request:
@@ -49,15 +69,19 @@ workflows:
4969
- build:
5070
requires:
5171
- wait_for_user_approval
52-
- test_php:
72+
- test_php_unit:
73+
requires:
74+
- build
75+
- test_php_spec:
5376
requires:
5477
- build
5578
- test_php_code_style:
5679
requires:
5780
- build
5881
- workflow_success:
5982
requires:
60-
- test_php
83+
- test_php_unit
84+
- test_php_spec
6185
- test_php_code_style
6286

6387
after_merge:
@@ -67,7 +91,10 @@ workflows:
6791
branches:
6892
only:
6993
- master
70-
- test_php:
94+
- test_php_unit:
95+
requires:
96+
- build
97+
- test_php_spec:
7198
requires:
7299
- build
73100
- test_php_code_style:
@@ -80,7 +107,13 @@ workflows:
80107
- equal: [ scheduled_pipeline, << pipeline.trigger_source >> ]
81108
- equal: [ "nightly_master", << pipeline.schedule.name >> ]
82109
jobs:
83-
- build
84-
- test_php:
110+
- build
111+
- test_php_unit:
112+
requires:
113+
- build
114+
- test_php_spec:
85115
requires:
86-
- build
116+
- build
117+
- test_php_code_style:
118+
requires:
119+
- build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ tests/etc/parameters.yml
55
phpspec.yml
66
phpunit.xml
77
.php_cs.cache
8+
.php-cs-fixer.cache

.php_cs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
return PhpCsFixer\Config::create()
3+
return (new PhpCsFixer\Config())
44
->setRules(array(
55
'@PSR2' => true,
66
'linebreak_after_opening_tag' => true,

Dockerfile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
FROM debian:bullseye-slim
2+
3+
# Install some useful packages
4+
RUN apt-get update && \
5+
apt-get --no-install-recommends --no-install-suggests --yes --quiet install \
6+
apt-transport-https \
7+
bash-completion \
8+
ca-certificates \
9+
curl \
10+
git \
11+
gnupg \
12+
imagemagick \
13+
less \
14+
make \
15+
perceptualdiff \
16+
procps \
17+
ssh-client \
18+
sudo \
19+
unzip \
20+
vim \
21+
wget && \
22+
apt-get clean && apt-get --yes --quiet autoremove --purge && \
23+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
24+
/usr/share/doc/* /usr/share/groff/* /usr/share/info/* /usr/share/linda/* \
25+
/usr/share/lintian/* /usr/share/locale/* /usr/share/man/*
26+
27+
# Install PHP with some extensions
28+
RUN apt-get update && \
29+
apt-get --no-install-recommends --no-install-suggests --yes --quiet install \
30+
php7.4-cli \
31+
php7.4-apcu \
32+
php7.4-mbstring \
33+
php7.4-curl \
34+
php7.4-gd \
35+
php7.4-imagick \
36+
php7.4-intl \
37+
php7.4-bcmath \
38+
php7.4-xdebug \
39+
php7.4-xml \
40+
php7.4-zip && \
41+
apt-get clean && apt-get --yes --quiet autoremove --purge && \
42+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
43+
/usr/share/doc/* /usr/share/groff/* /usr/share/info/* /usr/share/linda/* \
44+
/usr/share/lintian/* /usr/share/locale/* /usr/share/man/*
45+
46+
# Add a "docker" user
47+
RUN useradd docker --shell /bin/bash --create-home \
48+
&& usermod --append --groups sudo docker \
49+
&& echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers \
50+
&& echo 'docker:secret' | chpasswd
51+
52+
WORKDIR /home/docker/
53+
54+
# Install composer
55+
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
56+
57+
ENV PATH=bin:vendor/bin:$PATH

Makefile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
DOCKER_RUN = docker-compose run client_72
1+
DOCKER_RUN = DOCKER_BUILDKIT=1 docker-compose run php_client
22

33
.PHONY: help
44
help:
@@ -11,16 +11,27 @@ dependencies: ## Install composer dependencies
1111
$(DOCKER_RUN) composer install
1212

1313
.PHONY: tests
14-
tests: ## Run PHPUnit & PHPSpec tests, and code style check
14+
tests: unit spec cs ## Run PHPUnit & PHPSpec tests, and code style check
15+
unit
16+
spec
17+
cs
18+
19+
.PHONY: unit
20+
unit: ## Run PHPUnit tests
1521
@echo "-----------"
1622
@echo "- PHPUnit -"
1723
@echo "-----------"
1824
$(DOCKER_RUN) bin/phpunit -c phpunit.xml.dist
19-
@echo ""
25+
26+
.PHONY: spec
27+
spec: ## Run PHPSpec tests
2028
@echo "-----------"
2129
@echo "- PHPSpec -"
2230
@echo "-----------"
2331
$(DOCKER_RUN) bin/phpspec run
32+
33+
.PHONY: cs
34+
cs: ## Run code style check
2435
@echo "------------------"
2536
@echo "- PHP code style -"
2637
@echo "------------------"

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
}
2121
},
2222
"require": {
23-
"php": ">=7.1",
23+
"php": ">=7.4",
2424
"psr/http-message": "^1.0",
2525
"psr/http-client": "^1.0",
2626
"psr/http-factory": "^1.0",
@@ -30,9 +30,9 @@
3030
"php-http/multipart-stream-builder": "^1.0"
3131
},
3232
"require-dev": {
33-
"friendsofphp/php-cs-fixer": "^2.14",
33+
"friendsofphp/php-cs-fixer": "^3.5",
3434
"phpunit/phpunit": "^7.0",
35-
"phpspec/phpspec": "^5.0",
35+
"phpspec/phpspec": "^7.1",
3636
"symfony/yaml": "^4.2",
3737
"donatj/mock-webserver": "^2.0",
3838
"http-interop/http-factory-guzzle": "^1.0",
@@ -41,7 +41,7 @@
4141
"config": {
4242
"bin-dir": "bin",
4343
"platform": {
44-
"php": "7.1.3"
44+
"php": "7.4"
4545
}
4646
},
4747
"suggest": {

0 commit comments

Comments
 (0)