Skip to content

Commit

Permalink
[#1] Local environment integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrzej Rosiek committed Jul 24, 2024
1 parent caabe2a commit da93b8c
Show file tree
Hide file tree
Showing 9 changed files with 1,907 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
UID=503
GID=20
PHP_IDE_CONFIG=serverName=Docker
XDEBUG_SESSION=PHPSTORM
82 changes: 82 additions & 0 deletions .github/workflows/cart-sample.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Cart sample PHP CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
phpstan:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ 8.3 ]

services:
docker:
image: docker:20.10
options: --privileged

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, xml

- name: Install dependencies
run: composer install

- name: Run PHPStan
run: vendor/bin/phpstan analyse -l max

unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ 8.3 ]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, xml

- name: Install dependencies
run: composer install

- name: Run Unit Tests
run: vendor/bin/phpunit --configuration phpunit.xml --testsuite unit

integration-tests:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ 8.3 ]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, xml

- name: Install dependencies
run: composer install

- name: Run Integration Tests
run: vendor/bin/phpunit --configuration phpunit.xml --testsuite integration

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.phpunit.cache
vendor
.idea
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
# cart-sample
# Sample cart project

## requirements

- docker
- docker-compose

## instalation

1. `docker-compose up -d`
2. inside container `composer install`

## run tests:

- unit / integration:
- inside container: `composer test`
- static tests (phpstan)
- inside container: `composer analyse`

## assumptions:

- json file is used as products database
-
28 changes: 28 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "sample/cart",
"description": "Challenge project",
"type": "project",
"require": {
"php": "^8.3"
},
"require-dev": {
"phpunit/phpunit": "^11.0",
"phpstan/phpstan": "^1.0"
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"scripts": {
"test": "phpunit --configuration phpunit.xml",
"analyse": "phpstan analyse"
},
"minimum-stability": "stable",
"prefer-stable": true
}
Loading

0 comments on commit da93b8c

Please sign in to comment.