Skip to content

Commit

Permalink
Add Dockerfile + upgrade composer + upgrade php to 7.4 + fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tomglvng authored Jan 25, 2022
1 parent 2a6e379 commit c43fdd4
Show file tree
Hide file tree
Showing 8 changed files with 1,870 additions and 740 deletions.
79 changes: 56 additions & 23 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,60 @@ version: 2.1

jobs:
build:
docker:
- image: akeneo/php:7.2
machine:
image: ubuntu-2004:202111-01
steps:
- checkout
- run: composer install
- run:
name: Change rights on project dir
command: sudo chmod -R 777 ../project
- checkout
- run:
name: Build project
command: make dependencies
- persist_to_workspace:
root: ~/
paths:
- project
test_php_unit:
machine:
image: ubuntu-2004:202111-01
steps:
- attach_workspace:
at: ~/
- run:
name: Run PHPUnit tests
command: make unit

test_php:
docker:
- image: akeneo/php:7.2
test_php_spec:
machine:
image: ubuntu-2004:202111-01
steps:
- attach_workspace:
at: ~/
- run: bin/phpunit -c phpunit.xml.dist
- run: bin/phpspec run
- run:
name: Run PHPSpec tests
command: make spec

test_php_code_style:
docker:
- image: akeneo/php:7.2
machine:
image: ubuntu-2004:202111-01
steps:
- attach_workspace:
at: ~/
- run: bin/php-cs-fixer fix --diff --dry-run --config=.php_cs.php -vvv
- run:
name: Change rights on project dir
command: sudo chmod -R 777 ../project
- run:
name: Launch code style checker
command: make cs

workflow_success:
docker:
- image: akeneo/php:7.2
machine:
image: ubuntu-2004:202111-01
steps:
- run:
name: Success
command: echo "The build has run with success! Let's merge :)"
- run:
name: Success
command: echo "The build has run with success! Let's merge :)"

workflows:
pull_request:
Expand All @@ -49,15 +69,19 @@ workflows:
- build:
requires:
- wait_for_user_approval
- test_php:
- test_php_unit:
requires:
- build
- test_php_spec:
requires:
- build
- test_php_code_style:
requires:
- build
- workflow_success:
requires:
- test_php
- test_php_unit
- test_php_spec
- test_php_code_style

after_merge:
Expand All @@ -67,7 +91,10 @@ workflows:
branches:
only:
- master
- test_php:
- test_php_unit:
requires:
- build
- test_php_spec:
requires:
- build
- test_php_code_style:
Expand All @@ -80,7 +107,13 @@ workflows:
- equal: [ scheduled_pipeline, << pipeline.trigger_source >> ]
- equal: [ "nightly_master", << pipeline.schedule.name >> ]
jobs:
- build
- test_php:
- build
- test_php_unit:
requires:
- build
- test_php_spec:
requires:
- build
- build
- test_php_code_style:
requires:
- build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ tests/etc/parameters.yml
phpspec.yml
phpunit.xml
.php_cs.cache
.php-cs-fixer.cache
2 changes: 1 addition & 1 deletion .php_cs.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setRules(array(
'@PSR2' => true,
'linebreak_after_opening_tag' => true,
Expand Down
57 changes: 57 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM debian:bullseye-slim

# Install some useful packages
RUN apt-get update && \
apt-get --no-install-recommends --no-install-suggests --yes --quiet install \
apt-transport-https \
bash-completion \
ca-certificates \
curl \
git \
gnupg \
imagemagick \
less \
make \
perceptualdiff \
procps \
ssh-client \
sudo \
unzip \
vim \
wget && \
apt-get clean && apt-get --yes --quiet autoremove --purge && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
/usr/share/doc/* /usr/share/groff/* /usr/share/info/* /usr/share/linda/* \
/usr/share/lintian/* /usr/share/locale/* /usr/share/man/*

# Install PHP with some extensions
RUN apt-get update && \
apt-get --no-install-recommends --no-install-suggests --yes --quiet install \
php7.4-cli \
php7.4-apcu \
php7.4-mbstring \
php7.4-curl \
php7.4-gd \
php7.4-imagick \
php7.4-intl \
php7.4-bcmath \
php7.4-xdebug \
php7.4-xml \
php7.4-zip && \
apt-get clean && apt-get --yes --quiet autoremove --purge && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
/usr/share/doc/* /usr/share/groff/* /usr/share/info/* /usr/share/linda/* \
/usr/share/lintian/* /usr/share/locale/* /usr/share/man/*

# Add a "docker" user
RUN useradd docker --shell /bin/bash --create-home \
&& usermod --append --groups sudo docker \
&& echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers \
&& echo 'docker:secret' | chpasswd

WORKDIR /home/docker/

# Install composer
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer

ENV PATH=bin:vendor/bin:$PATH
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DOCKER_RUN = docker-compose run client_72
DOCKER_RUN = DOCKER_BUILDKIT=1 docker-compose run php_client

.PHONY: help
help:
Expand All @@ -11,16 +11,27 @@ dependencies: ## Install composer dependencies
$(DOCKER_RUN) composer install

.PHONY: tests
tests: ## Run PHPUnit & PHPSpec tests, and code style check
tests: unit spec cs ## Run PHPUnit & PHPSpec tests, and code style check
unit
spec
cs

.PHONY: unit
unit: ## Run PHPUnit tests
@echo "-----------"
@echo "- PHPUnit -"
@echo "-----------"
$(DOCKER_RUN) bin/phpunit -c phpunit.xml.dist
@echo ""

.PHONY: spec
spec: ## Run PHPSpec tests
@echo "-----------"
@echo "- PHPSpec -"
@echo "-----------"
$(DOCKER_RUN) bin/phpspec run

.PHONY: cs
cs: ## Run code style check
@echo "------------------"
@echo "- PHP code style -"
@echo "------------------"
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
},
"require": {
"php": ">=7.1",
"php": ">=7.4",
"psr/http-message": "^1.0",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
Expand All @@ -30,9 +30,9 @@
"php-http/multipart-stream-builder": "^1.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.14",
"friendsofphp/php-cs-fixer": "^3.5",
"phpunit/phpunit": "^7.0",
"phpspec/phpspec": "^5.0",
"phpspec/phpspec": "^7.1",
"symfony/yaml": "^4.2",
"donatj/mock-webserver": "^2.0",
"http-interop/http-factory-guzzle": "^1.0",
Expand All @@ -41,7 +41,7 @@
"config": {
"bin-dir": "bin",
"platform": {
"php": "7.1.3"
"php": "7.4"
}
},
"suggest": {
Expand Down
Loading

0 comments on commit c43fdd4

Please sign in to comment.