.gitlab-ci.yml 1.99 KB
Newer Older
Thomas Roos's avatar
Thomas Roos committed
1
# This base image can be found in 'Dockerfile'
2
image: $TEST_IMAGE
Thomas Roos's avatar
Thomas Roos committed
3 4

stages:
Hugo Kerstens's avatar
Hugo Kerstens committed
5
  - build-env
6
  - build
Thomas Roos's avatar
Thomas Roos committed
7 8
  - test

Hugo Kerstens's avatar
Hugo Kerstens committed
9
variables:
10
  TEST_IMAGE: ${CI_REGISTRY_IMAGE}/test
Thomas Roos's avatar
Thomas Roos committed
11

Hugo Kerstens's avatar
Hugo Kerstens committed
12 13
build-image:
  stage: build-env
14
  when: manual
Hugo Kerstens's avatar
Hugo Kerstens committed
15
  image:
Hugo Kerstens's avatar
Hugo Kerstens committed
16
    name: gcr.io/kaniko-project/executor:debug-v0.19.0
Hugo Kerstens's avatar
Hugo Kerstens committed
17
    entrypoint: [""]
18
  before_script:
Hugo Kerstens's avatar
Hugo Kerstens committed
19 20
    - mkdir -p /kaniko/.docker
    - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
Thomas Roos's avatar
Thomas Roos committed
21
  script:
Hugo Kerstens's avatar
Hugo Kerstens committed
22
    - mkdir docker
23
    - cp test.Dockerfile docker/
Hugo Kerstens's avatar
Hugo Kerstens committed
24 25 26 27
    - cp environment.yml docker/
    - cp package.json docker/
    - /kaniko/executor
      --context $CI_PROJECT_DIR/docker
28
      --dockerfile $CI_PROJECT_DIR/docker/test.Dockerfile
Hugo Kerstens's avatar
Hugo Kerstens committed
29 30
      --destination $TEST_IMAGE
      --cache=true
Thomas Roos's avatar
Thomas Roos committed
31

32
.conda-env: &conda-env
33
  before_script:
Hugo Kerstens's avatar
Hugo Kerstens committed
34
    - source activate zesje-dev
35
    - ln -s /yarn/* ./
36
    - if [[ $CI_JOB_NAME != *"py"* ]]; then yarn install; fi
37

38
build:
39
  <<: *conda-env
40
  stage: build
Thomas Roos's avatar
Thomas Roos committed
41
  script:
42
    - python3 -m compileall zesje
Thomas Roos's avatar
Thomas Roos committed
43
    - yarn build
44 45 46 47
  artifacts:
    paths:
      - zesje/static
    expire_in: 1 week
Thomas Roos's avatar
Thomas Roos committed
48

Pim Otte's avatar
Pim Otte committed
49
test_js:
50
  <<: *conda-env
Pim Otte's avatar
Pim Otte committed
51
  stage: test
52
  script:
Hugo Kerstens's avatar
Hugo Kerstens committed
53
    - yarn test:js
Anton Akhmerov's avatar
Anton Akhmerov committed
54 55 56
  artifacts:
    reports:
      junit: junit.xml
Thomas Roos's avatar
Thomas Roos committed
57

58
lint_js:
59
  <<: *conda-env
60 61 62 63 64 65
  stage: test
  allow_failure: true
  script:
    - yarn lint:js

lint_py:
66
  <<: *conda-env
67 68
  stage: test
  allow_failure: true
69
  script:
70
    - yarn lint:py
71

Ruben Young On's avatar
Ruben Young On committed
72
test_py:
73
  <<: *conda-env
74
  stage: test
Adrià Labay's avatar
Adrià Labay committed
75 76 77
  services:
    - mysql:5.7
  variables:
Adrià Labay's avatar
Adrià Labay committed
78
    MYSQL_DATABASE: "course_test"
Adrià Labay's avatar
Adrià Labay committed
79
    MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
Ruben Young On's avatar
Ruben Young On committed
80
  script:
Adrià Labay's avatar
Adrià Labay committed
81
    - echo -e "\nMYSQL_HOST = 'mysql'\nMYSQL_USER = 'root'\nMYSQL_PASSWORD = None" >> zesje_test_cfg.py
Adrià Labay's avatar
Adrià Labay committed
82
    - yarn test:py:cov
83 84 85
    # Patch against https://gitlab.com/gitlab-org/gitlab/-/issues/217664
    - 'sed -i "s=<source>.*zesje</source>=<source>./zesje</source>=g" cov.xml'
    - 'sed -i "s;filename=\";filename=\"zesje/;g" cov.xml'
Ruben Young On's avatar
Ruben Young On committed
86 87
  artifacts:
    paths:
88
      - cov.html/
Anton Akhmerov's avatar
Anton Akhmerov committed
89
    reports:
Anton Akhmerov's avatar
Anton Akhmerov committed
90 91
      cobertura: cov.xml
      junit: tests.xml
Ruben Young On's avatar
Ruben Young On committed
92
    expire_in: 1 week