Repository navigation
136 lines (117 loc) Β· 5.92 KB
/
Copy pathvalidate-generation.yml
File metadata and controls
136 lines (117 loc) Β· 5.92 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
name: Validate File Generation
on:
pull_request:
paths:
- 'asterisk/supported-asterisk-builds.yml'
- 'configs/generated/**'
- 'asterisk/*-*/**'
jobs:
validate-consistency:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Install dependencies
run: pip install -r requirements.txt
- name: Validate generation consistency
run: |
python3 << 'EOF'
import re
import yaml
import os
import sys
errors = []
SHA256 = re.compile(r"^[a-f0-9]{64}$")
APKVER = re.compile(r"^[0-9][0-9A-Za-z._]*-r[0-9]+$")
with open('asterisk/supported-asterisk-builds.yml', 'r') as f:
data = yaml.safe_load(f)
for build in data.get('latest_builds', []):
version = build.get('version')
os_matrix = build.get('os_matrix')
deprecated_at = build.get('deprecated_at')
# Skip intentionally disabled versions
if not os_matrix:
print(f"βοΈ Skipping {version} (intentionally disabled)")
continue
# Skip deprecated versions (kept in YAML for history)
if deprecated_at:
print(f"βοΈ Skipping {version} (deprecated since {deprecated_at})")
continue
# git versions clone at a recorded SHA (content-addressed); no tarball.
if version == 'git' or str(version).startswith('git-'):
continue
# Enforcement (plan 002): every active release version MUST carry a
# pinned tarball_sha256, so a future hand-added version cannot skip
# verification silently. addons_sha256 is required only for the
# legacy-addons variants (1.2/1.4/1.6) that build an addons tarball.
sha = build.get('tarball_sha256')
if not sha:
errors.append(f"{version}: missing tarball_sha256 (required for active builds)")
elif not SHA256.match(str(sha)):
errors.append(f"{version}: malformed tarball_sha256 (expected 64 hex chars): {sha!r}")
major_minor = '.'.join(str(version).split('.')[:2])
if major_minor in ('1.2', '1.4', '1.6'):
addons_sha = build.get('addons_sha256')
if not addons_sha:
errors.append(f"{version}: missing addons_sha256 (required for legacy-addons builds)")
elif not SHA256.match(str(addons_sha)):
errors.append(f"{version}: malformed addons_sha256 (expected 64 hex chars): {addons_sha!r}")
for os_config in os_matrix:
os_name = os_config.get('os', 'debian')
dist = os_config.get('distribution')
# build_slug: Debian keeps the bare distribution name; Alpine
# namespaces it (alpine-3.24, alpine-edge). See
# lib/template_generator.build_slug.
slug = f'alpine-{dist}' if os_name == 'alpine' else dist
# Check YAML config
config_file = f'configs/generated/asterisk-{version}-{slug}.yml'
if not os.path.exists(config_file):
errors.append(f"Missing config: {config_file}")
# Alpine members install prebuilt apks - no compile, no
# build.sh - and MUST carry an exact apk pin so a hand-added
# member cannot ship an unpinned (git-snapshot) install.
if os_name == 'alpine':
required_files = ['Dockerfile', 'entrypoint.sh', 'healthcheck.sh',
'cloudsmith-asterisk-alpine.rsa.pub']
apk_version = os_config.get('apk_version')
if not apk_version:
errors.append(f"{version} ({slug}): missing apk_version (required for Alpine members)")
elif not APKVER.match(str(apk_version)):
errors.append(f"{version} ({slug}): malformed apk_version (expected e.g. 22.10.1-r0): {apk_version!r}")
else:
required_files = ['Dockerfile', 'build.sh', 'healthcheck.sh']
# Check Dockerfile directory
dockerfile_dir = f'asterisk/{version}-{slug}'
if not os.path.isdir(dockerfile_dir):
errors.append(f"Missing directory: {dockerfile_dir}/")
else:
for required_file in required_files:
file_path = os.path.join(dockerfile_dir, required_file)
if not os.path.exists(file_path):
errors.append(f"Missing file: {file_path}")
# Alpine images must not carry a build.sh (nothing compiles)
if os_name == 'alpine' and os.path.exists(os.path.join(dockerfile_dir, 'build.sh')):
errors.append(f"{version} ({slug}): unexpected build.sh in an Alpine image dir")
if errors:
print("β Validation FAILED:")
for error in errors:
print(f" - {error}")
sys.exit(1)
else:
print("β
All expected files present and checksums pinned")
EOF
# Telegram ping to the owner when an unattended run fails. Requires repo
# secret TELEGRAM_BOT_TOKEN + variable TELEGRAM_CHAT_ID; skips with a warning when unset.
notify-failure:
needs: [validate-consistency]
if: failure()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: ./.github/actions/telegram-notify
with:
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
chat-id: ${{ vars.TELEGRAM_CHAT_ID }}