Skip to content
Snippets Groups Projects
.gitlab-ci.yml 2.48 KiB
# workflow
stages:
 - build
 - test
 - integration
 - acceptance
 - release
 - deploy

# default image for jobs
default:
  image: node:14

# cache modules between jobs
cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - .npm/

## BUILD ##

build:
  stage: build
  before_script:
    - npm ci --cache .npm --prefer-offline --only=production
  script:
    - cp config.sample.json config.json
    - npm run build
  artifacts:
    when: on_success
    expire_in: 1 day
    paths:
      - dist/
  except:
    - tags
    - feature/ansible
  tags:
    - test

## TESTING ##

test:e2e:
  stage: test
  image: 
    name: cypress/included:7.6.0
    entrypoint: [""]
  services:
    - name: ${CI_REGISTRY_IMAGE}/djangoldp:latest
  before_script:
    # install missing dependencies
    - npm install -g sirv-cli
    - npm install cypress-localstorage-commands
     # making sure the process is orphan
    - sirv dist --port 3000 > /dev/null 2>&1 &
  script:
    - cypress run -e CYPRESS_baseUrl=http://localhost:3000
  except:
    - tags
    - feature/ansible
  tags:
    - test

## VALIDATION ##

include:
  - project: infra/gitlab
    ref: master
    file: templates/deploy.ci.yml
  - project: infra/gitlab
    ref: master
    file: templates/nodejs.ci.yml

test1:
  extends: .ansible
  stage: integration
  environment:
    name: dev/test1
    url: https://test1.startinblox.com
  variables:
    ANSIBLE_INVENTORY: inventory/dev/
  only:
    - /^feature\/.*/
  when: manual

test2:
  extends: .ansible
  stage: integration
  environment:
    name: dev/test2
    url: https://test2.startinblox.com
  variables:
    ANSIBLE_INVENTORY: inventory/dev
  only:
    - /^feature\/.*/
  when: manual

test3:
  extends: .ansible
  stage: integration
  environment:
    name: dev/test3
    url: https://test3.startinblox.com
  variables:
    ANSIBLE_INVENTORY: inventory/dev
  only:
    - /^feature\/.*/
  when: manual

stg1:
  extends: .ansible
  stage: acceptance
  environment:
    name: review/stg1
    url: https://stg1.startinblox.com
  variables:
    ANSIBLE_INVENTORY: inventory/stg
  only:
    - /^release\/.*/
  when: manual

stg2:
  extends: .ansible
  stage: acceptance
  environment:
    name: review/stg2
    url: https://stg2.startinblox.com
  variables:
    ANSIBLE_INVENTORY: inventory/stg
  only:
    - /^release\/.*/
  when: manual

## RELEASE TAGGING ##

publish:
  extends: .publish_npm
  stage: release

## LIVE DEPLOYMENTS ##
hubl:
  extends: .ansible
  variables:
    ANSIBLE_INVENTORY: inventory/prd
  only:
    - master
  when: manual