Skip to content

thled/thled_bugtracker

Repository files navigation

THlEd BUGTRACKER

Version MIT License Symfony Pipeline Codecov Quality Gate Status

Requirements

Server

  • PHP 7.4 or higher
  • PostgreSQL 12.1 or higher
  • PHP extensions:
    • Ctype
    • iconv
    • JSON
    • PCRE
    • Session
    • SimpleXML
    • Tokenizer

Development

Installation

  1. Clone this repository: $ git clone [email protected]:thled/thled_bugtracker.git
  2. Change to project directory: $ cd thled_bugtracker
  3. Copy .env for Docker-Compose: $ cp .env.dist .env
  4. Build and start the docker containers: $ docker-compose up -d
  5. Initialize the app: $ docker-compose exec app composer bootstrap

Usage

  • Access the application: localhost:80
  • SSH into container: $ docker-compose exec app bash
  • SSH into node container for using Yarn: $ docker-compose exec frontend ash
  • Manage DB with Adminer: localhost:8080
    • System: PostgreSQL
    • Server: db
    • Username: db
    • Password: db
    • Database: db
  • Receive mails with Mailcatcher: http://localhost:1080
  • Debug with xDebug:
    • Maybe adjust local IP of host with xdebug.remote_host in docker/php/xdebug.ini
    • Vim configuration:
      • Use Vdebug Plugin from vim-vdebug/vdebug
      • Copy local rc file: $ cp .nvimrc.dist .nvimrc
      • Change second part of path_maps to the project on host in .nvimrc
    • PHPStorm configuration:
      • Change debug port under Settings/Languages/PHP/Debug to 9001
      • Add new server under Settings/Languages/PHP/Servers
        • Name: docker-server
        • Host: localhost
        • Port: 80
        • Debugger: Xdebug
        • Select "Use path mappings" and map "Project files" to /usr/src/app
    • Start "Listening for PHP Debug Connections"
  • Lint with CodeSniffer:
    • PHPStorm configuration:
      • Set path to script under Settings/Languages/PHP/Quality_Tools/PHP_CodeSniffer to path/to/project/app/scripts/phpcs.sh
      • Activate "PHP_CodeSniffer validation" under Settings/Editor/Inspections/PHP/Quality_tools

Code Quality

PHPStan Codecov

Master Pipeline, Develop Pipeline Develop

Quality Gate Status

Reliability Rating: Bugs

Security Rating: Vulnerabilities

Maintainability Rating: Code Smells, Duplicated Lines (%)

To ensure a high quality of the code base different tools are used to analyse, lint and fix code which does not adhere to the standards (PSR, Symfony etc.). There are manual tools and automatic tools for this purpose. Manual tools should be executed regularly while developing and automatic tools are executed in the Github Actions Workflow (alias Pipeline) or externally (e.g. SonarQube/SonarCloud).

Manual tools

  • PHP Code Beautifier and Fixer: $ composer fix

Automatic tools

  • PHPStan: $ composer analyse
  • PHP_CodeSniffer: $ composer lint
  • SonarCloud (triggered by pushing to Master branch)
  • Codecov (triggered by pushing)

Developing

Workflow

This project uses a custom workflow named "THlEd-FLOW" which is based on "GitHub flow".

Tests

Usage

  • Run whole test suite: $ composer tests
  • Run unit tests: $ composer unit
  • Run integration tests: $ composer integration
  • Run functional tests: $ composer functional
  • Run code coverage: $ composer code-coverage (then open app/coverage/index.html)

Writing tests

Setup
  • PHPUnit is used as testing framework.
  • Prophecy is used as object mocking framework.
  • There are three types of tests:
    • Unit Tests: Testing methods in isolation. (E.g. Service classes)
    • Integration Tests: Testing modules without stubbing/mocking dependencies like a database. (E.g. Repository classes)
    • Functional Tests: Testing frontend behavior. (E.g. Controller classes)
Philosophy
  • Seek for high code coverage (>90%).
  • Every test must have a @covers annotation for the class it covers to not accidentally cover classes which are not under test.
  • Code coverage should be reached by Unit Tests. Exceptions are Controllers and Repositories which are tested by Functional Tests and Integration Tests respectively.
  • Do not test private/protected methods explicitly.
  • Do not test objects which have no logic like Entities and Models/DTOs.
  • Do not test code which will not run in production like DataFixtures.
  • It is not necessary to stub/mock third party libraries and objects without logic like the ones mentioned before.

Contribute

Please do contribute! Issues and pull requests are welcome.