-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
126 lines (112 loc) · 2.84 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
image: docker:stable
stages:
- build-base
- build-test
- linting
- testing
- versions
- build-box
- pypi
- cleanup
variables:
BASE_IMAGE: $CI_REGISTRY_IMAGE:mobile_api_extensions-mobile_api_extensions
TEST_IMAGE: $CI_REGISTRY_IMAGE:mobile_api_extensions-mobile_api_extensions-test
BUILD_BOX_IMAGE: $CI_REGISTRY_IMAGE:mobile_api_extensions-mobile_api_extensions-build
STYLELINTRC_PATH: https://raw.githubusercontent.com/raccoongang/frontend/master/.stylelintrc
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
services:
- docker:stable-dind
build-box:
stage: build-box
script:
- docker pull $BASE_IMAGE || true
- docker build --cache-from $BASE_IMAGE -t $BUILD_BOX_IMAGE --target=build-box .
- docker push $BUILD_BOX_IMAGE
rules:
- if: $CI_COMMIT_TAG
build-base:
stage: build-base
script:
- docker pull $BASE_IMAGE || true
- docker build --cache-from $BASE_IMAGE -t $BASE_IMAGE --target=base-image .
- docker push $BASE_IMAGE
resource_group: build
only:
refs:
- main
- merge_requests
changes:
- Dockerfile
- .gitlab-ci.yml
build-test:
stage: build-test
script:
- docker pull $BASE_IMAGE
- docker pull $TEST_IMAGE || true
- docker build --cache-from $BASE_IMAGE --cache-from $TEST_IMAGE -t $TEST_IMAGE --target=test-image .
- docker push $TEST_IMAGE
resource_group: build
only:
refs:
- main
- merge_requests
changes:
- Dockerfile
- requirements/test.txt
- .gitlab-ci.yml
.test:
stage: testing
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker pull $TEST_IMAGE
only:
- main
- merge_requests
pytest:
extends: .test
script:
- docker run --rm -v ${PWD}:/app $TEST_IMAGE make python-test
coverage: "/TOTAL.+ ([0-9]{1,3}%)/"
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
quality:
extends: .test
stage: linting
script:
- docker run --rm -v ${PWD}:/app $TEST_IMAGE make quality
stylelint:
stage: linting
image: pipelinecomponents/stylelint:0.9.0
before_script:
- apk add --update curl && rm -rf /var/cache/apk/*
- curl $STYLELINTRC_PATH > .stylelintrc
script:
- stylelint '**/*.scss' --config .stylelintrc --allow-empty-input
only:
- main
- merge_requests
check_tag_version:
stage: versions
image: python:3.8
before_script:
- ''
script:
- python check_version.py
rules:
- if: $CI_COMMIT_TAG
pypi_build_and_publish:
stage: pypi
script:
- docker run --rm -v ${PWD}:/app -e CI_JOB_TOKEN -e CI_PROJECT_ID -e CI_API_V4_URL $BUILD_BOX_IMAGE make pypi
rules:
- if: $CI_COMMIT_TAG
clean_up:
stage: cleanup
script:
- docker rmi -f $BUILD_BOX_IMAGE || true
rules:
- if: $CI_COMMIT_TAG