Repository navigation
254 lines (218 loc) · 6.85 KB
/
Copy pathada-ci.yml
File metadata and controls
254 lines (218 loc) · 6.85 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# This workflow is managed by gh actions-lock.
# SPDX-License-Identifier: MPL-2.0
# This workflow is managed by gh actions-lock.
name: Ada/SPARK CI
on:
push:
branches: [ main, develop ]
paths:
- 'src/**'
- '*.gpr'
- 'Justfile'
- '.github/workflows/ada-ci.yml'
pull_request:
branches: [ main ]
paths:
- 'src/**'
- '*.gpr'
- 'Justfile'
- '.github/workflows/ada-ci.yml'
workflow_dispatch:
schedule:
- cron: '0 0 * * 0' # Weekly build
env:
APP_NAME: trigger
ADA_VERSION: "community-2024"
jobs:
build:
name: Build
runs-on: ubuntu-latest
container:
image: ghcr.io/alire-project/gnat-native:latest
steps:
- name: Checkout repository
uses: actions/checkout@v4.4.0
with:
fetch-depth: 0
submodules: recursive
- name: Install build dependencies
run: |
apt-get update && apt-get install -y --no-install-recommends \
git \
wget \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
- name: Build with GNAT
run: |
mkdir -p obj bin
gprbuild -P trigger.gpr -XLIBRARY_TYPE=static
ls -la bin/
- name: Verify binary
run: |
if [ -f bin/trigger ]; then
echo "Binary built successfully"
file bin/trigger
size=$(stat -c%s bin/trigger)
echo "Binary size: $size bytes"
else
echo "::error::Binary not found"
exit 1
fi
- name: Upload artifact
uses: actions/upload-artifact@v3.2.1
with:
name: trigger-binaries
path: |
bin/trigger
obj/
test:
name: Test
runs-on: ubuntu-latest
container:
image: ghcr.io/alire-project/gnat-native:latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v4.4.0
- name: Download artifact
uses: actions/download-artifact@v3.0.2
with:
name: trigger-binaries
path: .
- name: Run tests
run: |
if [ -f tests/test_trigger.adb ]; then
echo "Compiling tests..."
gprbuild -P trigger.gpr tests/test_trigger.adb
echo "Running tests..."
./obj/test_trigger
else
echo "::warning::No test file found"
fi
zig-ffi:
name: Zig FFI
runs-on: ubuntu-latest
container:
image: ghcr.io/alire-project/gnat-native:latest
steps:
- name: Checkout repository
uses: actions/checkout@v4.4.0
- name: Install Zig
run: |
wget -O /tmp/zig.tar.xz https://ziglang.org/builds/zig-linux-x86_64-0.11.0.tar.xz
tar -xf /tmp/zig.tar.xz -C /usr/local
ln -s /usr/local/zig-linux-x86_64-0.11.0/zig /usr/local/bin/zig
rm /tmp/zig.tar.xz
zig version
- name: Build Zig FFI
run: |
cd ffi/zig
zig build-lib -dynamic telegram.zig
cd ../..
ls -la ffi/zig/
- name: Upload Zig artifact
uses: actions/upload-artifact@v3.2.1
with:
name: zig-ffi
path: ffi/zig/
diagnostics:
name: Diagnostics
runs-on: ubuntu-latest
container:
image: ghcr.io/alire-project/gnat-native:latest
steps:
- name: Checkout repository
uses: actions/checkout@v4.4.0
- name: Run self-diagnostics
run: |
if [ -f bin/trigger ]; then
./bin/trigger --diagnose || true
else
echo "Binary not built, running static checks..."
echo "Checking for required files..."
for f in LICENSE README.adoc trigger.gpr; do
if [ -f "$f" ]; then
echo " [OK] $f"
else
echo " [MISSING] $f"
fi
done
fi
- name: Check file permissions
run: |
echo "Checking file permissions..."
find . -name "*.adb" -o -name "*.ads" | head -10 | while read f; do
perms=$(stat -c "%a" "$f")
echo " $f: $perms"
done
- name: Check line endings
run: |
echo "Checking line endings..."
files=$(find . -name "*.adb" -o -name "*.ads" -o -name "*.adoc")
for f in $files; do
if file "$f" | grep -q "CRLF"; then
echo " [WARNING] $f has CRLF line endings"
else
echo " [OK] $f"
fi
done
security:
name: Security Checks
runs-on: ubuntu-latest
container:
image: ghcr.io/alire-project/gnat-native:latest
steps:
- name: Checkout repository
uses: actions/checkout@v4.4.0
- name: Check for secrets
run: |
echo "Checking for secrets..."
# Check for API keys
if grep -r "api_id.*=" . --include="*.adb" --include="*.ads" --include="*.json" 2>/dev/null; then
echo "::warning::Potential API ID found"
fi
if grep -r "api_hash.*=" . --include="*.adb" --include="*.ads" --include="*.json" 2>/dev/null; then
echo "::warning::Potential API hash found"
fi
if grep -r "password.*=" . --include="*.adb" --include="*.ads" 2>/dev/null; then
echo "::warning::Potential password found"
fi
- name: Check for hardcoded sensitive data
run: |
echo "Checking for hardcoded sensitive data..."
# These should be configuration, not hardcoded
if grep -r "12345" src/ 2>/dev/null; then
echo "::warning::Potential test value found"
fi
- name: Check permissions on sensitive directories
run: |
echo "Checking permissions..."
if [ -d "sessions" ]; then
perms=$(stat -c "%a" sessions)
echo " sessions: $perms"
if [ "$perms" != "750" ] && [ "$perms" != "700" ]; then
echo "::warning::sessions directory has permissive permissions"
fi
fi
notifications:
name: Notifications
runs-on: ubuntu-latest
if: always()
needs: [build, test, zig-ffi, diagnostics, security]
steps:
- name: Check job status
run: |
echo "Build workflow completed"
echo "Job status:"
echo " build: ${{ needs.build.result }}"
echo " test: ${{ needs.test.result }}"
echo " zig-ffi: ${{ needs.zig-ffi.result }}"
echo " diagnostics: ${{ needs.diagnostics.result }}"
echo " security: ${{ needs.security.result }}"
- name: Send notification on failure
if: failure()
run: |
echo "::error::One or more jobs failed"
# In a real implementation, this would send a notification
# via GitHub Issues, Slack, Email, etc.