.gitlab-ci.yml 1.33 KB
Newer Older
Alexandre Morin's avatar
Alexandre Morin committed
1
# Docker images provided by https://github.com/cypress-io/cypress-docker-images
Alexandre Morin's avatar
Alexandre Morin committed
2
3
services:
  - docker:dind
Alexandre Morin's avatar
Alexandre Morin committed
4
# first, install Cypress, then run all tests (in parallel)
Alexandre Morin's avatar
Alexandre Morin committed
5
6
stages:
  - test
Alexandre Morin's avatar
Alexandre Morin committed
7
  - push
Alexandre Morin's avatar
Alexandre Morin committed
8

Alexandre Morin's avatar
Alexandre Morin committed
9
10
11
12
13
14
15
16
# to cache both npm modules and Cypress binary we use environment variables
# to point at the folders we can list as paths in "cache" job settings
variables:
  npm_config_cache: /builds/cypress-io/cypress-example-docker-gitlab/.npm
  CYPRESS_CACHE_FOLDER: /builds/cypress-io/cypress-example-docker-gitlab/cache/Cypress

# cache using branch name
# https://gitlab.com/help/ci/caching/index.md
Alexandre Morin's avatar
Alexandre Morin committed
17
18
19
20
21
22
cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - .npm
    - cache/Cypress
    - node_modules
Alexandre Morin's avatar
Alexandre Morin committed
23

Alexandre Morin's avatar
Alexandre Morin committed
24
25
# two jobs that run after "install" job finishes
# NPM dependencies and Cypress binary should be already installed
Alexandre Morin's avatar
Alexandre Morin committed
26
functional-test:cypress:
Alexandre Morin's avatar
Alexandre Morin committed
27
28
29
  image: cypress/base:10
  stage: test
  script:
Alexandre Morin's avatar
Alexandre Morin committed
30
31
    - npm ci
    - $(npm bin)/cypress verify
Alexandre Morin's avatar
Alexandre Morin committed
32
    - $(npm bin)/cypress run
Alexandre Morin's avatar
Alexandre Morin committed
33
34
  only:
    - schedules
Alexandre Morin's avatar
Alexandre Morin committed
35
36
37
38
39
40
  artifacts:
    expire_in: 1 week
    when: always
    paths:
      - cypress/screenshots
      - cypress/videos
Alexandre Morin's avatar
Alexandre Morin committed
41
42

build-dockerhub:
Alexandre Morin's avatar
Alexandre Morin committed
43
  stage: push
Alexandre Morin's avatar
Alexandre Morin committed
44
45
46
47
48
49
50
51
  script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
    - docker build dockerfile/version/ -t "$CI_REGISTRY_IMAGE"
    - docker push "$CI_REGISTRY_IMAGE"
  only:
    - feat/gitlab_ci
  except:
    - schedules