Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
36 changes: 36 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Run tests

# Controls when the workflow will run
on:
# Triggers the workflow on pull request events but only for the "main" and "develop" branch
pull_request:
branches: [ "main" , "develop"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
phpunit-params:
required: false
type: string
description: 'Permet de passer des options supplémentaires'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: zip, intl, gd, imagick, exif, xdebug
coverage: xdebug
- uses: php-actions/composer@v6
with:
args: --ignore-platform-reqs
memory_limit: -1
- name: Run tests
run: |
export XDEBUG_MODE=coverage
vendor/bin/phpunit --configuration phpunit.xml.dist --coverage-text
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Fichiers temporaires (cache, logs, librairies tierces)
logs/
cache/
vendor/

# PHPStorm
.idea/

# Visual Studio Code
.vscode/

# PHPUnit
.phpunit.cache/
.phpunit.result.cache
53 changes: 53 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Select image from https://hub.docker.com/_/php/
image: php:8.3

# Select what we should cache
cache:
paths:
- vendor/

before_script:
# Install some libs
- apt update -yqq
- apt install -yqq zip unzip

# Install Xdebug
- pecl install xdebug
- docker-php-ext-enable xdebug

# Install composer
- curl -sS https://getcomposer.org/installer | php

# Install all project dependencies
- php composer.phar install

stages: # List of stages for jobs, and their order of execution
- build
- test
- deploy

build-job: # This job runs in the build stage
stage: build
script:
- echo "Running unit tests... This will take about 60 seconds."
- export XDEBUG_MODE=coverage
- vendor/bin/phpunit --configuration phpunit.xml.dist --coverage-text
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"

lint-test-job: # This job runs in the test stage
stage: test
script:
- echo "Linting code... This will take about 10 seconds."
- echo "No lint issues found."
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"

deploy-job: # This job runs in the deploy stage.
stage: deploy
environment: production
script:
- echo "Deploying application..."
- echo "Application successfully deployed."
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
10 changes: 10 additions & 0 deletions calc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

require __DIR__ . '/vendor/autoload.php';

$iA = 5;
$iB = 2;

$oCalc = new \App\Calculator();
print_r(sprintf('%s + %s = %s', $iA, $iB, $oCalc->add($iA, $iB)) . PHP_EOL);
print_r(sprintf('%s - %s = %s', $iA, $iB, $oCalc->sub($iA, $iB)) . PHP_EOL);
21 changes: 21 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"description": "...",
"license": "proprietary",
"minimum-stability": "dev",
"config": {
"platform": {
"php": "8.3.0"
}
},
"require-dev": {
"phpunit/phpunit": "^12.5"
},
"autoload": {
"psr-4": {
"App\\": "src"
}
},
"scripts": {
"test": "phpunit"
}
}
Loading
Loading