-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
160 lines (137 loc) · 4.3 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
157
158
159
160
# SPDX-FileCopyrightText: Magenta ApS
#
# SPDX-License-Identifier: MPL-2.0
---
# ---------------------------------------------------------------------------
# ---------------------------------------------------------------------------
# Global
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
PRE_COMMIT_HOME: "$CI_PROJECT_DIR/.cache/pre-commit"
RELEASE_REGISTRY: index.docker.io
RELEASE_REGISTRY_NAMESPACE: ${RELEASE_REGISTRY}/magentaaps
cache:
key: "${CI_JOB_NAME}"
paths:
- .venv/
- .cache/pip
- .cache/pre-commit
stages:
- lint
- test
- release
- deploy
workflow:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_MERGE_REQUEST_ID
include:
- project: labs/salt-automation
file:
- gitlab-ci-templates/common/conventional-commits.v1.yml
- gitlab-ci-templates/common/config-updater-meta.v1.yml
# ---------------------------------------------------------------------------
# Templates
# ---------------------------------------------------------------------------
.install-deps-template: &install-deps
before_script:
# Install pre-commit
- pip install pre-commit
# Install yamllint
- pip install yamllint
# Install shellcheck
- apt-get update && apt-get install -y shellcheck
# Install Helm
- curl https://baltocdn.com/helm/signing.asc | apt-key add -
- apt-get update && apt-get install -y apt-transport-https coreutils
- |-
echo "deb https://baltocdn.com/helm/stable/debian/ all main" |
tee /etc/apt/sources.list.d/helm-stable-debian.list
- apt-get update && apt-get install -y helm
- curl -sL https://github.com/instrumenta/kubeval/releases/latest/download/kubeval-linux-amd64.tar.gz | tar xz -C /usr/bin/
.lint-template: &lint
<<: *install-deps
image: python:3.10
stage: lint
.test-template: &test
<<: *install-deps
image: python:3.10
stage: test
# ---------------------------------------------------------------------------
# Lint
# ---------------------------------------------------------------------------
Lint Project:
<<: *lint
script:
- pre-commit run --all-files
Lint Chart:
stage: lint
image: quay.io/helmpack/chart-testing:v3.4.0
script:
- ct lint --all --chart-dirs .
# ---------------------------------------------------------------------------
# Test
# ---------------------------------------------------------------------------
Generate Project:
<<: *test
script:
- helm template --kube-version 1.19.11 os2mo
- helm template --kube-version 1.19.11 os2mo | kubeval --schema-location https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master -
Release build:
stage: release
needs: []
image:
name: alpine/helm:3.9.4
entrypoint: [""]
before_script:
- helm registry login --username ${CI_REGISTRY_USER} --password ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
script:
- 'sed -i "s/name: .*/name: os2mo-helm-chart/g" os2mo/Chart.yaml'
- helm package --version=0.0.0-${CI_COMMIT_SHA} os2mo
- helm push os2mo-helm-chart-0.0.0-${CI_COMMIT_SHA}.tgz oci://$CI_REGISTRY_IMAGE
Release version:
stage: release
needs: []
image:
name: alpine/helm:3.9.4
entrypoint: [""]
before_script:
- helm registry login --username ${RELEASE_REGISTRY_USER} --password ${RELEASE_REGISTRY_PASSWORD} ${RELEASE_REGISTRY}
script:
- 'sed -i "s/name: .*/name: os2mo-helm-chart/g" os2mo/Chart.yaml'
- helm package --version=${CI_COMMIT_TAG} os2mo
- helm push os2mo-helm-chart-${CI_COMMIT_TAG}.tgz oci://${RELEASE_REGISTRY_NAMESPACE}
rules:
- if: $CI_COMMIT_TAG =~ /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
pages:
image: python:3.10
stage: release
needs: []
before_script:
- pip install mkdocs-material
- pip install mkdocs-autorefs
script:
- mkdocs build --strict --site-dir public
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_TAG =~ /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
# Release stage
###############
Release to Dev:
extends: .release-to-dev
needs: ["Release version"]
variables:
ENDPOINT: os2mo/flux/helm/update-dev
Release to Test:
extends: .release-to-test
needs: []
variables:
ENDPOINT: os2mo/flux/helm/update-test
Release to Prod:
extends: .release-to-prod
needs: []
variables:
ENDPOINT: os2mo/flux/helm/update-prod