-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
139 lines (128 loc) · 2.88 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
---
image: docker:latest
stages:
- preflight
- check
- deploy
variables:
GIT_STRATEGY: clone
GIT_SUBMODULE_STRATEGY: recursive
# Generic preflight template
.preflight: &preflight
stage: preflight
tags:
- preflight
# Generic ESPHome template
.esphome: &esphome
stage: check
variables:
PYTHONPATH: "/usr/src/app:$PYTHONPATH"
before_script:
- esphome dummy.yaml version
# secrets is used in common
- cp ./.stubs/secrets.yaml ./common/
# secrets is used in root
- cp ./.stubs/secrets.yaml ./
script:
- |
for file in $(find \
./ \
-maxdepth 1 \
-type f \
-name "*.yaml"\
-not -name "secrets.yaml"
); do
echo "Config validation for $file"
esphome $file config
done
tags:
- config
# Generic deployment template
.esphome-deploy: &esphome-deploy
stage: deploy
variables:
PYTHONPATH: "/usr/src/app:$PYTHONPATH"
image:
name: esphome/esphome:latest
entrypoint: [""]
before_script:
- apt update && apt install -y git-crypt openssl
- |
openssl enc -aes-256-cbc -pbkdf2 -d -in git-crypt.key.enc -out \
git-crypt.key -k $OPENSSL_PASSPHRASE
- git-crypt unlock git-crypt.key
- esphome dummy.yaml version
after_script:
- rm -f git-crypt.key
retry: 2
tags:
- esphome
# Preflight jobs
shellcheck:
<<: *preflight
image:
name: koalaman/shellcheck-alpine:stable
entrypoint: [""]
before_script:
- shellcheck --version
- apk --no-cache add grep
- |
find . -type f -print0 | \
xargs -0 sed -i 's:#!/usr/bin/with-contenv bash:#!/bin/bash:g'
script:
- |
for file in $(grep -IRl "#\!\(/usr/bin/env \|/bin/\)" --exclude-dir ".git" "${ADDON_TARGET}"); do
if ! shellcheck $file; then
export FAILED=1
else
echo "$file OK"
fi
done
if [ "${FAILED}" = "1" ]; then
exit 1
fi
yamllint:
<<: *preflight
image: sdesbure/yamllint
before_script:
- yamllint --version
# secrets is used in common
- cp ./.stubs/secrets.yaml ./common/
# secrets is used in root
- cp ./.stubs/secrets.yaml ./
script:
- yamllint .
jsonlint:
<<: *preflight
image: sahsu/docker-jsonlint
before_script:
- jsonlint --version || true
script:
- |
for file in $(find . -type f -name "*.json"); do
if ! jsonlint -q $file; then
export FAILED=1
else
echo "$file OK"
fi
done
if [ "${FAILED}" = "1" ]; then
exit 1
fi
markdownlint:
<<: *preflight
image: pipelinecomponents/markdownlint:latest
script:
- mdl --style all --warnings .
# ESPHome test jobs
esphome-latest:
<<: *esphome
image:
name: esphome/esphome:latest
entrypoint: [""]
esphome-beta:
<<: *esphome
image:
name: esphome/esphome:beta
entrypoint: [""]
allow_failure: true