-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
executable file
·73 lines (60 loc) · 1.78 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
---
stages:
- build
- lint
- test
variables:
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
OS_VER: '20.04'
SALT_VER: '3005.1'
default:
image: $CI_REGISTRY_IMAGE:$OS_VER-$SALT_VER-$CI_COMMIT_REF_NAME-latest
# Build matrix
.build_matrix:
parallel: &build_matrix
matrix:
- OS_VER: '20.04'
SALT_VER:
- '3004.2'
- '3005.1'
- OS_VER: '22.04'
SALT_VER:
- '3004.2'
- '3005.1'
docker_build:
stage: build
image: docker
services:
- docker:dind
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $CI_REGISTRY_IMAGE:$OS_VER-$SALT_VER-main-latest || true
rules:
- if: $CI_COMMIT_BRANCH
changes:
- .gitlab-ci.yml
- etc/Dockerfile
- etc/requirements.txt
when: on_success
script:
- "docker build --build-arg SALT_VER=$SALT_VER --build-arg OS_VER=$OS_VER \
--cache-from $CI_REGISTRY_IMAGE:$OS_VER-$SALT_VER-latest \
--tag $CI_REGISTRY_IMAGE:$OS_VER-$SALT_VER-$CI_COMMIT_SHORT_SHA \
--tag $CI_REGISTRY_IMAGE:$OS_VER-$SALT_VER-$CI_COMMIT_REF_NAME-latest \
-f etc/Dockerfile ."
- docker push $CI_REGISTRY_IMAGE:$OS_VER-$SALT_VER-$CI_COMMIT_SHORT_SHA
- docker push $CI_REGISTRY_IMAGE:$OS_VER-$SALT_VER-$CI_COMMIT_REF_NAME-latest # yamllint disable-line rule:line-length
parallel: *build_matrix
lint:
stage: lint
script:
- /opt/virtualenv/bin/yamllint -c etc/yamllint .
- git ls-files -- '*.sls' | xargs /opt/virtualenv/bin/salt-lint
pytest:
stage: test
image: $CI_REGISTRY_IMAGE:$OS_VER-$SALT_VER-$CI_COMMIT_REF_NAME-latest
script:
- /opt/virtualenv/bin/pytest --allow-state-apply
--exitfirst --verbose --failed-first
parallel: *build_matrix