<commit_before>stages:
  - postinstall
  - tests
  - lint

########################################
# POSTINSTALL
########################################

postinstall:
  image: before-postinstall
  stage: postinstall
  script:
    - yunohost tools postinstall -d domain.tld -p the_password --ignore-dyndns

########################################
# TESTS
########################################

.test-stage:
  image: after-postinstall
  stage: tests
  before_script:
    - apt-get install python-pip -y
    - mkdir -p .pip
    - pip install -U pip
    - hash -d pip
    - pip --cache-dir=.pip install pytest pytest-sugar pytest-mock requests-mock mock
    - pushd src/yunohost/tests
    - >
       if [ ! -d "./apps" ]; then
         git clone https://github.com/YunoHost/test_apps ./apps
       fi
    - cd apps
    - git pull > /dev/null 2>&1
    - popd
    - export PYTEST_ADDOPTS="--color=yes"
  cache:
    paths: 
      - .pip
      - src/yunohost/tests/apps
    key: "$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG"

root-tests:
  extends: .test-stage
  script:
    - py.test tests

test-apps:
  extends: .test-stage
  script:
    - cd src/yunohost
    - py.test tests/test_apps.py

test-appscatalog:
  extends: .test-stage
  script:
    - cd src/yunohost
    - py.test tests/test_appscatalog.py

test-appurl:
  extends: .test-stage
  script:
    - cd src/yunohost
    - py.test tests/test_appurl.py

test-backuprestore:
  extends: .test-stage
  script:
    - cd src/yunohost
    - py.test tests/test_backuprestore.py

test-changeurl:
  extends: .test-stage
  script:
    - cd src/yunohost
    - py.test tests/test_changeurl.py

test-permission:
  extends: .test-stage
  script:
    - cd src/yunohost
    - py.test tests/test_permission.py

test-settings:
  extends: .test-stage
  script:
    - cd src/yunohost
    - py.test tests/test_settings.py

test-user-group:
  extends: .test-stage
  script:
    - cd src/yunohost
    - py.test tests/test_user-group.py
    
test-regenconf:
  extends: .test-stage
  script:
    - cd src/yunohost
    - py.test tests/test_regenconf.py

########################################
# LINTER
########################################

.lint-stage:
  image: before-postinstall
  stage: lint
  before_script:
    - apt-get install python3-pip -y
    - mkdir -p .pip3
    - pip3 install -U pip
    - hash -d pip3
    - pip3 --cache-dir=.pip3 install flake8 # black
  cache:
    paths: 
      - .pip3
    key: "$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG"

lint:
  extends: .lint-stage
  script:
    - flake8 src tests data

# Disabled, waiting for buster
#format-check:
#  extends: .lint-stage
#  script:
#    - black {posargs:--check --diff} src tests data<commit_msg>linter on all the repo<commit_after>stages:
  - postinstall
  - tests
  - lint

########################################
# POSTINSTALL
########################################

postinstall:
  image: before-postinstall
  stage: postinstall
  script:
    - yunohost tools postinstall -d domain.tld -p the_password --ignore-dyndns

########################################
# TESTS
########################################

.test-stage:
  image: after-postinstall
  stage: tests
  before_script:
    - apt-get install python-pip -y
    - mkdir -p .pip
    - pip install -U pip
    - hash -d pip
    - pip --cache-dir=.pip install pytest pytest-sugar pytest-mock requests-mock mock
    - pushd src/yunohost/tests
    - >
       if [ ! -d "./apps" ]; then
         git clone https://github.com/YunoHost/test_apps ./apps
       fi
    - cd apps
    - git pull > /dev/null 2>&1
    - popd
    - export PYTEST_ADDOPTS="--color=yes"
  cache:
    paths: 
      - .pip
      - src/yunohost/tests/apps
    key: "$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG"

root-tests:
  extends: .test-stage
  script:
    - py.test tests

test-apps:
  extends: .test-stage
  script:
    - cd src/yunohost
    - py.test tests/test_apps.py

test-appscatalog:
  extends: .test-stage
  script:
    - cd src/yunohost
    - py.test tests/test_appscatalog.py

test-appurl:
  extends: .test-stage
  script:
    - cd src/yunohost
    - py.test tests/test_appurl.py

test-backuprestore:
  extends: .test-stage
  script:
    - cd src/yunohost
    - py.test tests/test_backuprestore.py

test-changeurl:
  extends: .test-stage
  script:
    - cd src/yunohost
    - py.test tests/test_changeurl.py

test-permission:
  extends: .test-stage
  script:
    - cd src/yunohost
    - py.test tests/test_permission.py

test-settings:
  extends: .test-stage
  script:
    - cd src/yunohost
    - py.test tests/test_settings.py

test-user-group:
  extends: .test-stage
  script:
    - cd src/yunohost
    - py.test tests/test_user-group.py
    
test-regenconf:
  extends: .test-stage
  script:
    - cd src/yunohost
    - py.test tests/test_regenconf.py

########################################
# LINTER
########################################

.lint-stage:
  image: before-postinstall
  stage: lint
  before_script:
    - apt-get install python3-pip -y
    - mkdir -p .pip3
    - pip3 install -U pip
    - hash -d pip3
    - pip3 --cache-dir=.pip3 install flake8 # black
  cache:
    paths: 
      - .pip3
    key: "$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG"

lint:
  extends: .lint-stage
  script:
    - flake8

# Disabled, waiting for buster
#format-check:
#  extends: .lint-stage
#  script:
#    - black --check --diff
{'fraction_non_alphanumeric': 0.19385652743959542, 'fraction_numerical': 0.004120621839295748, 'mean_word_length': 2.5340833884844476, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '1013027', 'n_tokens_mistral': 1923, 'n_tokens_neox': 1913, 'n_words': 407}