.gitlab-ci.yml 1.31 KB
Newer Older
1
image: docker:19.03.1
Christian Rohlfing's avatar
Christian Rohlfing committed
2
3
services:
  - docker:19.03.1-dind
4
5
6
7
8

stages:
- build
- test

Christian Rohlfing's avatar
Christian Rohlfing committed
9
10
11
12
13
variables:
  GIT_SUBMODULE_STRATEGY: recursive
  DOCKER_TLS_CERTDIR: "/certs"
  DOCKER_HOST: tcp://docker:2376 # Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled

14
15
16
17
18
19
20
21
22
23
24
build:
  stage: build
  script:
  - docker pull ${CI_REGISTRY_IMAGE}:latest || true
  - docker build --cache-from ${CI_REGISTRY_IMAGE}:latest
                 --tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}
                 --tag ${CI_REGISTRY_IMAGE}:latest .
  - docker push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}
  - docker push ${CI_REGISTRY_IMAGE}:latest
  only:
  - master
Christian Rohlfing's avatar
Christian Rohlfing committed
25
26
  before_script:
  - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
27
28
29
30

test:
  stage: test
  script:
Christian Rohlfing's avatar
Christian Rohlfing committed
31
  - mkdir out
Christian Rohlfing's avatar
Christian Rohlfing committed
32
  - chmod 777 out 
Christian Rohlfing's avatar
Christian Rohlfing committed
33
  - docker run --name examscan --rm -v $(pwd):$(pwd) -w $(pwd) ${CI_REGISTRY_IMAGE}:latest watermark.py tests/assets/pdfs out
34
35
36
  artifacts:
    paths:
    - out/
Christian Rohlfing's avatar
Christian Rohlfing committed
37
38
39
40
41
42
43
44
45
46

test-coverage:
  image: 
    name: ${CI_REGISTRY_IMAGE}:latest
    entrypoint: [""]
  stage: test
  script:
    - pip3 install pytest pytest-cov
    - cd /app
    - python3 -m pytest --cov=./ tests
Christian Rohlfing's avatar
Christian Rohlfing committed
47
    - python3 -m coverage xml -o reports/coverage.xml
Christian Rohlfing's avatar
Christian Rohlfing committed
48
  artifacts:
Christian Rohlfing's avatar
Christian Rohlfing committed
49
50
    paths:
      - reports/coverage.xml
Christian Rohlfing's avatar
Christian Rohlfing committed
51
    reports:
Christian Rohlfing's avatar
Christian Rohlfing committed
52
      cobertura: reports/coverage.xml