.gitlab-ci.yml 1.55 KB
Newer Older
Sam Galson's avatar
Sam Galson committed
1 2 3
variables:
  IMAGE_ORG: pubsweet
  IMAGE_NAME: starter
Jure's avatar
Jure committed
4

Sam Galson's avatar
Sam Galson committed
5 6 7
stages:
  - build
  - test
Jure's avatar
Jure committed
8

Sam Galson's avatar
Sam Galson committed
9
build:
Jure's avatar
Jure committed
10 11 12
  image: docker:19.03.1
  services:
    - docker:19.03.1-dind
Sam Galson's avatar
Sam Galson committed
13
  stage: build
Jure's avatar
Jure committed
14
  script:
Sam Galson's avatar
Sam Galson committed
15 16 17 18 19 20 21 22 23
    - docker version
    - docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
    - echo "Ignore warning! Cannot perform an interactive login from a non TTY device"
    - docker build -t $IMAGE_ORG/$IMAGE_NAME:$CI_COMMIT_SHA .
    - docker push $IMAGE_ORG/$IMAGE_NAME:$CI_COMMIT_SHA

test:chrome:
  image: $IMAGE_ORG/$IMAGE_NAME:$CI_COMMIT_SHA
  stage: test
Tamlyn Rhodes's avatar
Tamlyn Rhodes committed
24
  variables:
Sam Galson's avatar
Sam Galson committed
25
    GIT_STRATEGY: none
26 27 28 29 30 31
    # setup data for postgres image
    POSTGRES_USER: test
    POSTGRES_PASSWORD: pw
    # connection details for tests
    PGUSER: test
    PGPASSWORD: pw
Tamlyn Rhodes's avatar
Tamlyn Rhodes committed
32
    NODE_ENV: test
33 34
  services:
    - postgres
Tamlyn Rhodes's avatar
Tamlyn Rhodes committed
35
  script:
Sam Galson's avatar
Sam Galson committed
36
    - cd ${HOME}
37 38
    # specify host here else it confuses the linked postgres image
    - PGHOST=postgres npx testcafe 'chrome:headless --no-sandbox' test/**/*.test.js
Sam Galson's avatar
Sam Galson committed
39 40 41 42

test:firefox:
  image: $IMAGE_ORG/$IMAGE_NAME:$CI_COMMIT_SHA
  stage: test
Tamlyn Rhodes's avatar
Tamlyn Rhodes committed
43
  variables:
Sam Galson's avatar
Sam Galson committed
44
    GIT_STRATEGY: none
45 46 47 48 49 50
    # setup data for postgres image
    POSTGRES_USER: test
    POSTGRES_PASSWORD: pw
    # connection details for tests
    PGUSER: test
    PGPASSWORD: pw
Tamlyn Rhodes's avatar
Tamlyn Rhodes committed
51
    NODE_ENV: test
52 53
  services:
    - postgres
Sam Galson's avatar
Sam Galson committed
54 55
  script:
    - cd ${HOME}
56 57
    # specify host here else it confuses the linked postgres image
    - PGHOST=postgres npx testcafe firefox:headless test/**/*.test.js
Jure's avatar
Jure committed
58 59

lint:
Sam Galson's avatar
Sam Galson committed
60 61 62 63
  image: $IMAGE_ORG/$IMAGE_NAME:$CI_COMMIT_SHA
  stage: test
  variables:
    GIT_STRATEGY: none
Jure's avatar
Jure committed
64
  script:
Sam Galson's avatar
Sam Galson committed
65
    - cd ${HOME}
Jure's avatar
Jure committed
66
    - npm run lint