-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
87 lines (74 loc) · 1.95 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
image: docker:latest
services:
- docker:dind
include:
- template: SAST.gitlab-ci.yml
- template: Dependency-Scanning.gitlab-ci.yml
- template: Container-Scanning.gitlab-ci.yml
- template: Code-Quality.gitlab-ci.yml
- template: Secret-Detection.gitlab-ci.yml
variables:
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
CONTAINER_TEST_IMAGE_LATEST: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:latest
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
CONTAINER_RELEASE_IMAGE_LATEST: $CI_REGISTRY_IMAGE:latest
.docker-setup_template: &docker-setup
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
stages:
- build
- test
- tag
- release
- deploy
build:
stage: build
before_script:
- *docker-setup
script:
- docker build -t $CONTAINER_TEST_IMAGE .
- docker push $CONTAINER_TEST_IMAGE
test:
stage: test
before_script:
- *docker-setup
script:
- docker pull $CONTAINER_TEST_IMAGE
- docker run -v $PWD/htmlcov:/app/htmlcov $CONTAINER_TEST_IMAGE -m pytest --cov-report term --cov-report html --cov=app.main
coverage: "/TOTAL.+ ([0-9]{1,3}%)/"
artifacts:
paths:
- htmlcov
tag-dev-image:
stage: tag
before_script:
- *docker-setup
script:
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_TEST_IMAGE_LATEST
- docker push $CONTAINER_TEST_IMAGE_LATEST
except:
- main
release-image:
stage: release
before_script:
- *docker-setup
script:
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE
- docker tag $CONTAINER_RELEASE_IMAGE $CONTAINER_RELEASE_IMAGE_LATEST
- docker push $CONTAINER_RELEASE_IMAGE_LATEST
only:
- main
pages:
stage: deploy
dependencies:
- test
script:
- mkdir public
- mv htmlcov public/coverage
artifacts:
paths:
- public
only:
- develop