<commit_before>stages:
  - test
  - build
  - review
  - cleanup

variables:
  COMPOSER_HOME: /cache/composer

  # The PF_PROJECT_ID is required.
  # PF_PROJECT_ID:
  PF_PARENT_ENV: 3.x
  PF_NO_CLONE_PARENT: 1 # CLI environments are stateless, so no need for data cloning

quick-tests:
  stage: test
  image: php:7.4-cli
  before_script:
    - apt-get update
    - apt-get install zip unzip git lsof -y
    - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    - php composer-setup.php
    - mkdir -p /cache/composer/bin && chmod +x composer.phar && mv composer.phar /cache/composer/bin/composer
  script:
    - export PATH="/cache/composer/bin:$PATH"
    # No Composer scripts, because Box isn't needed (and Box needs PHP 7.4).
    - composer install --no-interaction --no-scripts
    - scripts/test/unit.sh
    - scripts/test/offline.sh

build:
  stage: build
  needs:
    - quick-tests
  image: php:7.4-cli
  before_script:
    - apt-get update
    - apt-get install zip unzip
    - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    - php composer-setup.php
    - mkdir -p /cache/composer/bin && chmod +x composer.phar && mv composer.phar /cache/composer/bin/composer
  script:
    - export PATH="/cache/composer/bin:$PATH"
    - composer install --no-dev --no-interaction
    - |
      cd vendor-bin/box
      composer install --no-interaction
      cd -
      mkdir -p vendor/bin
      ln -s "$(realpath vendor-bin/box/vendor/bin/box)" vendor/bin/box
    - ./bin/platform self:build --no-composer-rebuild --yes --replace-version "$CI_COMMIT_REF_NAME"-"$CI_COMMIT_SHORT_SHA" --output platform.phar
  artifacts:
    expose_as: 'cli-phar'
    paths: ['platform.phar']

push-review-env:
  image: pjcdawkins/platformsh-cli
  script:
    - bash scripts/gitlab-ci/push-platform.sh
  needs:
    - quick-tests
  stage: review
  artifacts:
    reports:
      dotenv: environment.env # makes PRIMARY_URL available
  environment:
    name: review/$CI_COMMIT_REF_SLUG
    url: $PRIMARY_URL
    auto_stop_in: 7 day
    on_stop: delete-review-env
  only:
    - branches

cleanup-review-envs:
  image: pjcdawkins/platformsh-cli
  script:
    - bash scripts/gitlab-ci/cleanup-platform.sh
  needs:
    - push-review-env
  stage: cleanup
  allow_failure: true

delete-review-env:
  image: pjcdawkins/platformsh-cli
  script:
    - bash scripts/gitlab-ci/delete-platform.sh
  stage: cleanup
  when: manual
  needs:
    - push-review-env
  environment:
    name: review/$CI_COMMIT_REF_SLUG
    action: stop
  only:
    - branches
  except:
    - 3.x
    - 4.x
    - master
<commit_msg>Run GitLab cleanup job on branches only<commit_after>stages:
  - test
  - build
  - review
  - cleanup

variables:
  COMPOSER_HOME: /cache/composer

  # The PF_PROJECT_ID is required.
  # PF_PROJECT_ID:
  PF_PARENT_ENV: 3.x
  PF_NO_CLONE_PARENT: 1 # CLI environments are stateless, so no need for data cloning

quick-tests:
  stage: test
  image: php:7.4-cli
  before_script:
    - apt-get update
    - apt-get install zip unzip git lsof -y
    - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    - php composer-setup.php
    - mkdir -p /cache/composer/bin && chmod +x composer.phar && mv composer.phar /cache/composer/bin/composer
  script:
    - export PATH="/cache/composer/bin:$PATH"
    # No Composer scripts, because Box isn't needed (and Box needs PHP 7.4).
    - composer install --no-interaction --no-scripts
    - scripts/test/unit.sh
    - scripts/test/offline.sh

build:
  stage: build
  needs:
    - quick-tests
  image: php:7.4-cli
  before_script:
    - apt-get update
    - apt-get install zip unzip
    - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    - php composer-setup.php
    - mkdir -p /cache/composer/bin && chmod +x composer.phar && mv composer.phar /cache/composer/bin/composer
  script:
    - export PATH="/cache/composer/bin:$PATH"
    - composer install --no-dev --no-interaction
    - |
      cd vendor-bin/box
      composer install --no-interaction
      cd -
      mkdir -p vendor/bin
      ln -s "$(realpath vendor-bin/box/vendor/bin/box)" vendor/bin/box
    - ./bin/platform self:build --no-composer-rebuild --yes --replace-version "$CI_COMMIT_REF_NAME"-"$CI_COMMIT_SHORT_SHA" --output platform.phar
  artifacts:
    expose_as: 'cli-phar'
    paths: ['platform.phar']

push-review-env:
  image: pjcdawkins/platformsh-cli
  script:
    - bash scripts/gitlab-ci/push-platform.sh
  needs:
    - quick-tests
  stage: review
  artifacts:
    reports:
      dotenv: environment.env # makes PRIMARY_URL available
  environment:
    name: review/$CI_COMMIT_REF_SLUG
    url: $PRIMARY_URL
    auto_stop_in: 7 day
    on_stop: delete-review-env
  only:
    - branches

cleanup-review-envs:
  image: pjcdawkins/platformsh-cli
  script:
    - bash scripts/gitlab-ci/cleanup-platform.sh
  needs:
    - push-review-env
  stage: cleanup
  allow_failure: true
  only:
    - branches

delete-review-env:
  image: pjcdawkins/platformsh-cli
  script:
    - bash scripts/gitlab-ci/delete-platform.sh
  stage: cleanup
  when: manual
  needs:
    - push-review-env
  environment:
    name: review/$CI_COMMIT_REF_SLUG
    action: stop
  only:
    - branches
  except:
    - 3.x
    - 4.x
    - master

{'fraction_non_alphanumeric': 0.11973559962228518, 'fraction_numerical': 0.004154863078375827, 'mean_word_length': 2.649896623018608, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2169674', 'n_tokens_mistral': 1953, 'n_tokens_neox': 1883, 'n_words': 418}