-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
156 lines (145 loc) · 5 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
variables:
POSTGRES_USER: sipam
POSTGRES_PASSWORD: sipam
POSTGRES_DB: sipam
POETRY_VERSION: "1.5.1"
PYTHON_VERSION: "3.11"
prometheus_multiproc_dir: /tmp
KUBECONFORM_VERSION: "0.4.8"
NODE_VERSION: "18"
HELM_KUBECTL_VERSION: "3.12.1"
stages:
- test
- build
- build_containers
eslint:
image: node:${NODE_VERSION}-alpine
stage: test
before_script:
- cd frontend
- yarn install
script:
- yarn lint
yarn_build:
image: node:${NODE_VERSION}-alpine
stage: build
before_script:
- cd frontend
- yarn install
script:
- yarn build
artifacts:
paths:
- frontend/dist
helm_build:
image: docker.io/dtzar/helm-kubectl:${HELM_KUBECTL_VERSION}
stage: build
before_script:
- helm repo add bitnami https://charts.bitnami.com/bitnami
- helm repo add selfnet "${NEXUS_URL}/repository/selfnet-helm/" --username "${NEXUS_USERNAME}" --password "${NEXUS_PASSWORD}"
script:
- helm dependency build deploy/helm/sipam
- helm package --version ${CI_COMMIT_REF_NAME#v} --app-version ${CI_COMMIT_REF_NAME} deploy/helm/sipam
- curl -T *.tgz -v -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" "${NEXUS_URL}/repository/selfnet-helm/"
needs:
- helm_lint
only:
- tags
helm_lint:
image: docker.io/dtzar/helm-kubectl:${HELM_KUBECTL_VERSION}
stage: test
before_script:
- helm repo add bitnami https://charts.bitnami.com/bitnami
- wget "https://github.com/yannh/kubeconform/releases/download/v${KUBECONFORM_VERSION}/kubeconform-linux-amd64.tar.gz"
- tar xzvf kubeconform-linux-amd64.tar.gz kubeconform
- mv kubeconform /kubeconform
- chmod +x /kubeconform
script:
- |
bash -c "! grep -r -I -n '[[:blank:]]$' deploy/"
- helm dependency build deploy/helm/sipam
- helm lint deploy/helm/sipam
- helm template sipam deploy/helm/sipam | /kubeconform -ignore-missing-schemas -summary
ruff:
image: python:${PYTHON_VERSION}-bullseye
stage: test
before_script:
- cd backend
- pip install "poetry==${POETRY_VERSION}"
- poetry install --only dev
script:
- poetry run poe lint
pytest:
image: python:${PYTHON_VERSION}-bullseye
services:
- postgres:latest
stage: test
before_script:
- cd backend
- pip install "poetry==${POETRY_VERSION}"
- poetry install
script:
- poetry run coverage run -m pytest
- poetry run coverage report
backend_container:
image: quay.io/redhat-github-actions/buildah-runner:latest
stage: build_containers
before_script:
- export BUILDAH_FORMAT=docker
- echo "$CI_REGISTRY_PASSWORD" | buildah login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
script:
- buildah bud -t $CI_REGISTRY_IMAGE/backend:$CI_COMMIT_SHORT_SHA -f Containerfile backend
- buildah push $CI_REGISTRY_IMAGE/backend:$CI_COMMIT_SHORT_SHA
- if [ "$CI_COMMIT_REF_NAME" == "main" ]; then buildah tag $CI_REGISTRY_IMAGE/backend:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE/backend:latest; fi
- if [ "$CI_COMMIT_REF_NAME" == "main" ]; then buildah push $CI_REGISTRY_IMAGE/backend:latest; fi
needs:
- ruff
- pytest
only:
- branches
frontend_container:
image: quay.io/redhat-github-actions/buildah-runner:latest
stage: build_containers
before_script:
- export BUILDAH_FORMAT=docker
- echo "$CI_REGISTRY_PASSWORD" | buildah login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
script:
- buildah bud -t $CI_REGISTRY_IMAGE/frontend:$CI_COMMIT_SHORT_SHA -f Containerfile frontend
- buildah push $CI_REGISTRY_IMAGE/frontend:$CI_COMMIT_SHORT_SHA
- if [ "$CI_COMMIT_REF_NAME" == "main" ]; then buildah tag $CI_REGISTRY_IMAGE/frontend:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE/frontend:latest; fi
- if [ "$CI_COMMIT_REF_NAME" == "main" ]; then buildah push $CI_REGISTRY_IMAGE/frontend:latest; fi
needs:
- yarn_build
- eslint
only:
- branches
backend_container_release:
image: quay.io/redhat-github-actions/buildah-runner:latest
stage: build_containers
before_script:
- export BUILDAH_FORMAT=docker
- echo "$CI_REGISTRY_PASSWORD" | buildah login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
script:
- buildah bud -t $CI_REGISTRY_IMAGE/backend:$CI_COMMIT_SHORT_SHA -t $CI_REGISTRY_IMAGE/backend:$CI_COMMIT_REF_NAME -f Containerfile backend
- buildah push $CI_REGISTRY_IMAGE/backend:$CI_COMMIT_SHORT_SHA
- buildah push $CI_REGISTRY_IMAGE/backend:$CI_COMMIT_REF_NAME
needs:
- ruff
- pytest
only:
- tags
frontend_container_release:
image: quay.io/redhat-github-actions/buildah-runner:latest
stage: build_containers
before_script:
- export BUILDAH_FORMAT=docker
- echo "$CI_REGISTRY_PASSWORD" | buildah login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
script:
- buildah bud -t $CI_REGISTRY_IMAGE/frontend:$CI_COMMIT_SHORT_SHA -t $CI_REGISTRY_IMAGE/frontend:$CI_COMMIT_REF_NAME -f Containerfile frontend
- buildah push $CI_REGISTRY_IMAGE/frontend:$CI_COMMIT_SHORT_SHA
- buildah push $CI_REGISTRY_IMAGE/frontend:$CI_COMMIT_REF_NAME
needs:
- yarn_build
- eslint
only:
- tags