-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
211 lines (196 loc) · 5.78 KB
/
.gitlab-ci.yml
File metadata and controls
211 lines (196 loc) · 5.78 KB
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# GitLab CI/CD Pipeline para dotfiles
# Pipeline Python - Tests de instalación y validación
stages:
- lint
- test
- validate
# Template para cache de Python
.python_cache: &python_cache
cache:
key: python-cache
paths:
- .cache/pip
variables:
DEBIAN_FRONTEND: noninteractive
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
#######################
# Stage: Lint
#######################
python-lint:
stage: lint
image: python:3-slim
before_script:
- pip install --upgrade pip
- pip install pyyaml
script:
# Verificar sintaxis de todos los scripts Python
- echo "=== Verificando sintaxis Python ==="
- python -m py_compile scripts/install.py
- python -m py_compile .github/scripts/check-english.py
- python -m py_compile .github/scripts/check-mappings.py
- python -m py_compile .github/scripts/test_install.py
- python -m py_compile .github/scripts/test_sanitize.py
- echo "✅ Sintaxis Python válida"
<<: *python_cache
check-executables:
stage: lint
image: alpine/git
script:
- apk add --no-cache bash
- |
fail=0
files=$(git ls-files || true)
if [ -n "$files" ]; then
for f in $files; do
if [ -f "$f" ]; then
if head -n1 "$f" | grep -q '^#!'; then
mode=$(git ls-files --stage "$f" | awk '{print $1}')
if [ "$mode" != "100755" ]; then
echo "$f tiene shebang pero no es ejecutable"
fail=1
fi
fi
fi
done
fi
if [ "$fail" -eq 1 ]; then exit 1; fi
check-i18n:
stage: lint
image: python:3-slim
before_script:
- pip install --upgrade pip
- pip install pyyaml
script:
# Verificar no reintroducción de texto en inglés
- python .github/scripts/check-english.py
<<: *python_cache
#######################
# Stage: Test
#######################
test-install-default:
stage: test
image: python:3-slim
before_script:
- apt-get update
- apt-get install -y git-lfs rsync
- pip install --upgrade pip
- pip install pyyaml
script:
- echo "=== Ejecutando test_install.py (Default - Sin Temas) ==="
- python .github/scripts/test_install.py 2>&1 | tee /tmp/test-default.log
<<: *python_cache
test-install-with-themes:
stage: test
image: python:3-slim
before_script:
- apt-get update
- apt-get install -y git-lfs rsync
- pip install --upgrade pip
- pip install pyyaml
script:
- echo "=== Ejecutando test_install.py (Con Temas) ==="
- python .github/scripts/test_install.py --with-themes 2>&1 | tee /tmp/test-themes.log
<<: *python_cache
artifacts:
when: on_failure
paths:
- /tmp/test-themes.log
expire_in: 1 week
test-quick-install:
stage: test
image: python:3-slim
before_script:
- apt-get update
- apt-get install -y git-lfs rsync
- pip install --upgrade pip
- pip install pyyaml
script:
- TMP=$(mktemp -d)
- echo "Testing installer against: $TMP"
- python scripts/install.py --target "$TMP" modules/shell/bash 2>&1 | head -50
- echo "Verificando instalación..."
- ls -la "$TMP" | head -20
- find "$TMP" -type l 2>/dev/null | head -10 || echo "No symlinks found yet"
<<: *python_cache
after_script:
- rm -rf "$TMP" || true
#######################
# Stage: Validate
#######################
validate-mappings:
stage: validate
image: python:3-slim
before_script:
- pip install --upgrade pip
- pip install pyyaml
script:
# Verificar cobertura de mapeos
- python .github/scripts/check-mappings.py
<<: *python_cache
validate-module-coverage:
stage: validate
image: python:3-slim
before_script:
- pip install --upgrade pip
- pip install pyyaml
script:
- |
echo "=== Verificando archivos top-level en módulos ==="
cd modules
FAIL=0
ALLOWED=''
if [ -f ../install-mappings.yml ]; then
raw_keys=$(sed -n 's/^[[:space:]]*//;s/#.*//;s/:.*$//;s/|.*$//;p' ../install-mappings.yml | sed '/^[[:space:]]*-/d' | sed '/^$/d' || true)
if [ -n "$raw_keys" ]; then
pats=$(printf '%s\n' "$raw_keys" | awk -F: '
/^[[:space:]]*#/ { next }
/^[[:space:]]*$/ { next }
{ line=$1; sub(/^[[:space:]]*/, "", line); sub(/[[:space:]]*$/, "", line); sub(/\|.*$/, "", line);
n=split(line, parts, "/"); base=parts[n];
printf "%s|%s\n", line, base
}
' | tr '\n' '|' | sed 's/|$//' || true)
esc=$(printf '%s' "$pats" | sed -E 's/([^a-zA-Z0-9_\-\.\/|])/\\\\\1/g' || true)
ALLOWED="^$(printf '%s' "$esc" | sed 's/|/\$|^/g')$|^\..+"
fi
fi
if [ -z "$ALLOWED" ]; then
ALLOWED='^\..+'
fi
for m in */ ; do
m=$(basename "$m")
while IFS= read -r -d $'\0' f; do
fname=$(basename "$f")
if [[ ! "$fname" =~ $ALLOWED ]] && [[ ! "$fname" =~ ^\..+ ]]; then
echo "ERROR: El módulo $m contiene archivo en raíz sin mapear: $fname"
FAIL=1
fi
done < <(find "$m" -maxdepth 1 -type f -print0 || true)
done
if [ "$FAIL" -eq 1 ]; then
echo "❌ Se detectaron archivos sin mapear"
exit 1
else
echo "✅ Todos los archivos están mapeados"
fi
<<: *python_cache
# Job solo para tags/releases
validate-release:
stage: validate
image: python:3-slim
only:
- tags
before_script:
- apt-get update
- apt-get install -y git-lfs rsync
- pip install --upgrade pip
- pip install pyyaml
script:
- echo "=== Validando release $CI_COMMIT_TAG ==="
- TMP=$(mktemp -d)
# Ejecutar test completo
- python .github/scripts/test_install.py
- echo "✅ Release $CI_COMMIT_TAG validado correctamente"
<<: *python_cache
after_script:
- rm -rf "$TMP" || true