---
pre-commit:
  stage: .pre
  needs: []
  image: registry.shore.co.il/ci-images:pre-commit
  tags: [ns4.shore.co.il]
  rules:
    - if: $CI_PIPELINE_SOURCE != "schedule"
      exists:
        - .pre-commit-config.yaml
  variables:
    XDG_CACHE_HOME: "$CI_PROJECT_DIR/.cache"
    SKIP: |-
      gitlab-ci-linter,pip-compile
    # yamllint disable-line rule:line-length
    TF_HTTP_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/default
    TF_HTTP_USERNAME: gitlab-ci-token
    TF_HTTP_PASSWORD: ${CI_JOB_TOKEN}
    # yamllint disable-line rule:line-length
    TF_HTTP_LOCK_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/default/lock
    TF_HTTP_LOCK_METHOD: POST
    # yamllint disable-line rule:line-length
    TF_HTTP_UNLOCK_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/default/lock
    TF_HTTP_UNLOCK_METHOD: DELETE
  script:
    - pre-commit run --all-files
  cache:
    paths:
      - .cache/
