image: node:latest

cache:
    paths:
        - node_modules

stages:
    - lint
    - test
    - test:build
    - deploy

merge:test:lint:
    stage: lint
    script:
        - npm install
        - cp example.env.local .env.local
        - cp example.env.local .env.test
        - npm run lint
    only:
        - merge_requests

merge:test:jest:
    stage: test
    script:
        - npm install
        - cp example.env.local .env.local
        - cp example.env.local .env.test
        - npm run test
    only:
        - merge_requests

#merge:test:build:
#    stage: test:build
#    script:
#        - npm install
#        - cp example.env.local .env.local
#        - cp example.env.local .env.test
#        - npm run build
#    only:
#        - merge_requests

test:lint:
    stage: lint
    script:
        - npm install
        - cp example.env.local .env.local
        - cp example.env.local .env.test
        - npm run lint
    only:
        - develop
        - main

test:jest:
    stage: test
    script:
        - npm install
        - cp example.env.local .env.local
        - cp example.env.local .env.test
        - npm run test
    only:
        - develop
        - main

#test:build:
#    stage: test:build
#    script:
#        - npm install
#        - cp example.env.local .env.local
#        - cp example.env.local .env.test
#        - npm run build
#    only:
#        - develop
#        - main

deploy:
    stage: deploy
    script:
        - echo "Run deploy project"
    only:
        - main