# You can override the included template(s) by including variable overrides
# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/#customizing-settings
# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings
# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings
# Note that environment variables can be set in several places
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
stages:
  - test
  - build
  - publish

sast:
  stage: test
include:
  - template: Security/SAST.gitlab-ci.yml

build-dev:
  image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/node:16.14.2-alpine3.14
  stage: build
  before_script:
    - apk add git
    - apk add bash
  script:
    - yarn
    - yarn build
    - git config --global user.name build-token
    - git config --global user.email "$GIT_USER"
    - git config --global user.password "$GIT_PWD"
    - git config user.email "$GIT_USER"
    - git remote set-url origin https://"$GIT_USER":"$GIT_PWD"@forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector.git
    - git config --global credential.helper store
    - yarn deploy-dev

unit-test:
  image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/node:16.14.2-alpine3.14
  stage: test
  before_script:
    - apk add git
    - apk add bash
  script:
    - yarn
    - yarn test --ci --reporters=default --reporters=jest-junit --coverage
  coverage: "/All files[^|]*\\|[^|]*\\s+([\\d\\.]+)/"
  artifacts:
    when: always
    reports:
      junit:
        - junit.xml

build:
  image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/node:16.14.2-alpine3.14
  stage: build
  before_script:
    - apk add git
    - apk add bash
  script:
    - yarn
    - yarn build
    - git config --global user.name build-token
    - git config --global user.email "$GIT_USER"
    - git config --global user.password "$GIT_PWD"
    - git config user.email "$GIT_USER"
    - git remote set-url origin https://"$GIT_USER":"$GIT_PWD"@forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector.git
    - git config --global credential.helper store
    - yarn deploy
  only:
    - master

publish:
  stage: publish
  before_script:
    - apk add git
  script:
    - yarn cozyPublish
  only:
    - tags
  when: manual
