<commit_before>image: lorisleiva/laravel-docker:latest

variables:
  APP_ENV: "local"
  APP_KEY: "<KEY>
  APP_DEBUG: "true"
  DB_DATABASE: "laravel"
  DB_USERNAME: "root"
  DB_PASSWORD: ""
  GITHUB_SHA: $CI_COMMIT_SHA
  GITHUB_REF: $CI_COMMIT_REF_NAME

cache:
  key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"

before_script:
  - apk add --no-cache docker-compose

stages:
  - build
  - tests
  - metrics

sail:
  stage: build
  script:
    - docker-compose up --build -d

composer:
  stage: build
  cache:
    key: ${CI_COMMIT_REF_SLUG}-composer
    paths:
      - vendor/
  script:
    - composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
  artifacts:
    expire_in: 1 month
    paths:
      - vendor/
      - .env

npm:
  stage: build
  cache:
    key: ${CI_COMMIT_REF_SLUG}-npm
    paths:
      - node_modules/
  script:
      - npm install
      - npm run production
  artifacts:
    expire_in: 1 month
    paths:
      - node_modules/
      - public/css/
      - public/js/

phpunit:
  stage: tests
  script:
    - ./vendor/bin/sail php phpunit --coverage-text --colors=never
  artifacts:
    paths:
      - ./storage/logs # for debugging
    expire_in: 7 days
    when: always

dusk:
  stage: tests
  script:
    - ./vendor/bin/sail dusk
  artifacts:
    paths:
      - ./storage/logs # for debugging
      - ./tests/Browser/screenshots
      - ./tests/Browser/console
    expire_in: 7 days
    when: always

php-metrics:
  stage: metrics
  script:
    - composer global require --dev phpmetrics/phpmetrics
    - phpmetrics --report-html=var/php-metrics app tests
  artifacts:
    paths:
      - var/php-metrics/
  allow_failure: true

php-mess-detector:
  stage: metrics
  script:
    - wget -c https://phpmd.org/static/latest/phpmd.phar
    - wget -c https://gist.githubusercontent.com/slayerfat/2b3cc4faf94d2863b505/raw/5229a520c69010c6c13fd9a66d14309c214c241a/phpmd-ruleset.xml
    - php phpmd.phar app,tests text phpmd-ruleset.xml
  artifacts:
    paths:
      - var/phpmd.html
  allow_failure: true

php-assumptions:
  stage: metrics
  script:
    - composer global require --dev rskuipers/php-assumptions
    - phpa app tests
  allow_failure: true

composer-unused:
  stage: metrics
  script:
    - wget https://github.com/icanhazstring/composer-unused/releases/latest/download/composer-unused.phar
    - php composer-unused.phar --no-progress --excludePackage=spatie/laravel-blade-javascript
  allow_failure: true

php-copypaste-detector:
  stage: metrics
  script:
    - wget https://phar.phpunit.de/phpcpd.phar
    - php phpcpd.phar --fuzzy app tests
  allow_failure: true

php-security-checker:
  stage: metrics
  script:
    - wget https://get.sensiolabs.org/security-checker.phar
    - php security-checker.phar security:check composer.lock
  allow_failure: true

php-churn:
  stage: metrics
  script:
    - composer global require --dev bmitch/churn-php
    - churn run app tests
  allow_failure: true

php-code-analyzer:
  stage: metrics
  script:
    - wget https://github.com/wapmorgan/PhpCodeAnalyzer/releases/download/1.0.6/phpca.phar
    - php phpca.phar app
  allow_failure: true

php-code-fixer:
  stage: metrics
  script:
    - wget https://github.com/wapmorgan/PhpCodeFixer/releases/download/2.0.23/phpcf-2.0.23.phar
    - php phpcf-2.0.23.phar app tests
  allow_failure: true

php-insights:
  stage: metrics
  script:
    - composer global require --dev nunomaduro/phpinsights
    - phpinsights
  allow_failure: true

phpstan:
  stage: metrics
  script:
    - composer global require --dev nunomaduro/larastan
    - wget https://gist.githubusercontent.com/Korko/19ad2705a8a8632819aa8370fcb631b8/raw/d79f918004273b8823a5530e57141119eba69ac6/phpstan.neon
    - phpstan analyse -c phpstan.neon
  allow_failure: true<commit_msg>Try with another docker image<commit_after>image: serversideup/php:8.0-cli

variables:
  APP_ENV: "local"
  APP_KEY: "<KEY>
  APP_DEBUG: "true"
  DB_DATABASE: "laravel"
  DB_USERNAME: "root"
  DB_PASSWORD: ""
  GITHUB_SHA: $CI_COMMIT_SHA
  GITHUB_REF: $CI_COMMIT_REF_NAME

cache:
  key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"

stages:
  - build
  - tests
  - metrics

composer:
  stage: build
  cache:
    key: ${CI_COMMIT_REF_SLUG}-composer
    paths:
      - vendor/
  script:
    - composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
  artifacts:
    expire_in: 1 month
    paths:
      - vendor/
      - .env

npm:
  stage: build
  cache:
    key: ${CI_COMMIT_REF_SLUG}-npm
    paths:
      - node_modules/
  script:
      - npm install
      - npm run production
  artifacts:
    expire_in: 1 month
    paths:
      - node_modules/
      - public/css/
      - public/js/

phpunit:
  stage: tests
  script:
    - ./vendor/bin/sail php phpunit --coverage-text --colors=never
  artifacts:
    paths:
      - ./storage/logs # for debugging
    expire_in: 7 days
    when: always

dusk:
  stage: tests
  script:
    - ./vendor/bin/sail dusk
  artifacts:
    paths:
      - ./storage/logs # for debugging
      - ./tests/Browser/screenshots
      - ./tests/Browser/console
    expire_in: 7 days
    when: always

php-metrics:
  stage: metrics
  script:
    - composer global require --dev phpmetrics/phpmetrics
    - phpmetrics --report-html=var/php-metrics app tests
  artifacts:
    paths:
      - var/php-metrics/
  allow_failure: true

php-mess-detector:
  stage: metrics
  script:
    - wget -c https://phpmd.org/static/latest/phpmd.phar
    - wget -c https://gist.githubusercontent.com/slayerfat/2b3cc4faf94d2863b505/raw/5229a520c69010c6c13fd9a66d14309c214c241a/phpmd-ruleset.xml
    - php phpmd.phar app,tests text phpmd-ruleset.xml
  artifacts:
    paths:
      - var/phpmd.html
  allow_failure: true

php-assumptions:
  stage: metrics
  script:
    - composer global require --dev rskuipers/php-assumptions
    - phpa app tests
  allow_failure: true

composer-unused:
  stage: metrics
  script:
    - wget https://github.com/icanhazstring/composer-unused/releases/latest/download/composer-unused.phar
    - php composer-unused.phar --no-progress --excludePackage=spatie/laravel-blade-javascript
  allow_failure: true

php-copypaste-detector:
  stage: metrics
  script:
    - wget https://phar.phpunit.de/phpcpd.phar
    - php phpcpd.phar --fuzzy app tests
  allow_failure: true

php-security-checker:
  stage: metrics
  script:
    - wget https://get.sensiolabs.org/security-checker.phar
    - php security-checker.phar security:check composer.lock
  allow_failure: true

php-churn:
  stage: metrics
  script:
    - composer global require --dev bmitch/churn-php
    - churn run app tests
  allow_failure: true

php-code-analyzer:
  stage: metrics
  script:
    - wget https://github.com/wapmorgan/PhpCodeAnalyzer/releases/download/1.0.6/phpca.phar
    - php phpca.phar app
  allow_failure: true

php-code-fixer:
  stage: metrics
  script:
    - wget https://github.com/wapmorgan/PhpCodeFixer/releases/download/2.0.23/phpcf-2.0.23.phar
    - php phpcf-2.0.23.phar app tests
  allow_failure: true

php-insights:
  stage: metrics
  script:
    - composer global require --dev nunomaduro/phpinsights
    - phpinsights
  allow_failure: true

phpstan:
  stage: metrics
  script:
    - composer global require --dev nunomaduro/larastan
    - wget https://gist.githubusercontent.com/Korko/19ad2705a8a8632819aa8370fcb631b8/raw/d79f918004273b8823a5530e57141119eba69ac6/phpstan.neon
    - phpstan analyse -c phpstan.neon
  allow_failure: true
{'fraction_non_alphanumeric': 0.10616024694671856, 'fraction_numerical': 0.030331499127633874, 'mean_word_length': 2.7846622651091923, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 16, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '452365', 'n_tokens_mistral': 2953, 'n_tokens_neox': 2788, 'n_words': 542}