-
Notifications
You must be signed in to change notification settings - Fork 5
/
.gitlab-ci.yml
89 lines (80 loc) · 2.67 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
image: docker:latest
variables:
REGISTRY: $CI_REGISTRY
PROJECT_PATH: none
DOCKER_DRIVER: overlay2
# SELECT ONE OF INTERNAL,EXTERNAL
CI_DEPLOY_NETWORK: INTERNAL
CI_DEPLOY_TAG: none
# SELECT ONE OF public,private
CI_PUBLISH: public
# hotfix for https://gitlab.com/gitlab-org/gitlab-ce/issues/64959
DOCKER_TLS_CERTDIR: ""
stages:
- build
- test
build:
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
services:
- name: docker:dind
command: ["--experimental"]
stage: build
script:
- apk update && apk add git
- git describe --always --long --dirty > hash.file
- PROJECT_PATH=$(echo $CI_PROJECT_PATH | tr '[:upper:]' '[:lower:]')
- CONTAINER_IMAGE=$REGISTRY/$PROJECT_PATH
- docker pull $CONTAINER_IMAGE:latest || true
# - docker build --squash --cache-from $CONTAINER_IMAGE:latest --tag $CONTAINER_IMAGE:$CI_COMMIT_REF_SLUG --tag $CONTAINER_IMAGE:latest .
- docker build --cache-from $CONTAINER_IMAGE:latest --tag $CONTAINER_IMAGE:$CI_COMMIT_REF_SLUG --tag $CONTAINER_IMAGE:latest --tag $CONTAINER_IMAGE:$CI_COMMIT_SHORT_SHA .
# - docker build --squash --cache-from $CONTAINER_IMAGE:latest --tag $CONTAINER_IMAGE:git_$CI_COMMIT_SHORT_SHA .
- docker push $CONTAINER_IMAGE:$CI_COMMIT_REF_SLUG
- docker push $CONTAINER_IMAGE:$CI_COMMIT_SHORT_SHA
- |
if [ "$CI_COMMIT_BRANCH" == "main" ]; then
docker push $CONTAINER_IMAGE:latest
fi
tags:
- docker
test:
stage: test
before_script:
- apk update && apk add make zip python3
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- PROJECT_PATH=$(echo $CI_PROJECT_PATH | tr '[:upper:]' '[:lower:]')
- CONTAINER_IMAGE=$REGISTRY/$PROJECT_PATH:$CI_COMMIT_SHORT_SHA
services:
- name: docker:19.03.0-dind
command: ["--experimental"]
script:
- echo $CONTAINER_IMAGE
- unzip data/lfq_example/evidence.zip -d data/lfq_example/
- make IMAGE=$CONTAINER_IMAGE DATA=$(pwd)/data/lfq_example/ all
tags:
- docker
artifacts:
paths:
- data/lfq_example/results.zip
expire_in: 1 week
pytest:
stage: test
image: python:3.8.12
before_script:
- pip install -U pip poetry
- poetry config virtualenvs.create false
- poetry install
script:
- echo $CONTAINER_IMAGE
- python3 -m pytest --cov=picked_group_fdr --cov-report term --junitxml=report.xml tests/unit_tests
- coverage xml
tags:
- docker
coverage: /(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/
artifacts:
when: always
reports:
junit: report.xml
coverage_report:
coverage_format: cobertura
path: coverage.xml