-
Notifications
You must be signed in to change notification settings - Fork 0
275 lines (238 loc) · 9.74 KB
/
build-test.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
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
name: Build and Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Set permissions explicitly for security best practices
permissions:
contents: read # For checking out code
packages: read # For pulling container images
jobs:
build-amd64:
name: Build and Test (Linux AMD64)
runs-on: ubuntu-latest # Standard x86_64 runner
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Create certificate file for build
env:
CA_BUNDLE: ${{ secrets.CA_BUNDLE }}
CA_BUNDLE_PART1: ${{ secrets.CA_BUNDLE_PART1 }}
CA_BUNDLE_PART2: ${{ secrets.CA_BUNDLE_PART2 }}
CA_BUNDLE_PART3: ${{ secrets.CA_BUNDLE_PART3 }}
CA_BUNDLE_PART4: ${{ secrets.CA_BUNDLE_PART4 }}
CA_BUNDLE_PART5: ${{ secrets.CA_BUNDLE_PART5 }}
CA_BUNDLE_PART6: ${{ secrets.CA_BUNDLE_PART6 }}
CA_BUNDLE_PART7: ${{ secrets.CA_BUNDLE_PART7 }}
CA_BUNDLE_PART8: ${{ secrets.CA_BUNDLE_PART8 }}
CA_BUNDLE_PART9: ${{ secrets.CA_BUNDLE_PART9 }}
run: |
./scripts/assemble-certificates.sh --verify
- name: Build amd64 minimal container
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile.optimized
push: false
platforms: linux/amd64
tags: cac-builder:minimal-test
cache-from: type=gha
cache-to: type=gha,mode=max
load: true
- name: Test minimal container
run: |
docker run --rm cac-builder:minimal-test -c "mkdir -p /content/build && cd /content/build && cmake .. && echo 'Build environment test: SUCCESS'"
- name: Build amd64 full container
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: false
platforms: linux/amd64
tags: cac-builder:full-test
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_TYPE=full
load: true
- name: Test full container
run: |
mkdir -p output
docker run -v ${{ github.workspace }}/output:/output --rm cac-builder:full-test -c "ls /content/build/ssg-* && cp /content/build/ssg-* /output/ 2>/dev/null || echo 'No content found, checking build environment'"
- name: Collect build info
run: |
# Create a detailed build-info file
{
echo "===== AMD64 Build Information ====="
echo "Build timestamp: $(date)"
echo "Architecture: amd64"
echo "Runner: ${{ runner.os }}"
echo "Build triggered by: ${{ github.event_name }}"
echo "Job ID: ${{ github.job }}"
echo "Commit: ${{ github.sha }}"
echo "===== Output Files ====="
if [ "$(ls -A output/ 2>/dev/null)" ]; then
find output -type f -name "*.xml" | sort > output/amd64-file-list.txt
echo "File listing:"
cat output/amd64-file-list.txt
echo "File sizes:"
find output -type f -name "*.xml" -exec du -h {} \; | sort -h
else
echo "No output files found."
fi
} > output/amd64-build-info.txt
# Update to v4
- name: Upload amd64 artifacts
uses: actions/upload-artifact@v4
with:
name: cac-test-content-amd64
path: |
output/*.xml
output/*.xccdf.xml
output/*.ds.xml
output/amd64-build-info.txt
output/amd64-file-list.txt
if-no-files-found: warn
retention-days: 7
build-arm64:
name: Build and Test (Apple Silicon ARM64)
runs-on: macos-14 # macOS Sonoma with Apple Silicon
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Check system information
run: |
echo "OS: $(uname -s)"
echo "Architecture: $(uname -m)"
echo "Processor: $(sysctl -n machdep.cpu.brand_string)"
- name: Install Docker for Apple Silicon
run: |
# Install latest Docker Desktop for Apple Silicon
curl -L https://desktop.docker.com/mac/main/arm64/Docker.dmg -o Docker.dmg
sudo hdiutil attach Docker.dmg
sudo cp -R "/Volumes/Docker/Docker.app" /Applications/
sudo hdiutil detach "/Volumes/Docker"
open -a "/Applications/Docker.app" --args --unattended
# Wait for Docker to start
echo "Waiting for Docker to start..."
timeout=60
while ! docker info > /dev/null 2>&1; do
if [ "$timeout" -le 0 ]; then
echo "Docker failed to start"
exit 1
fi
sleep 1
timeout=$((timeout - 1))
done
echo "Docker is running"
# Show Docker info
docker info
- name: Create certificate file for build
env:
CA_BUNDLE: ${{ secrets.CA_BUNDLE }}
CA_BUNDLE_PART1: ${{ secrets.CA_BUNDLE_PART1 }}
CA_BUNDLE_PART2: ${{ secrets.CA_BUNDLE_PART2 }}
CA_BUNDLE_PART3: ${{ secrets.CA_BUNDLE_PART3 }}
CA_BUNDLE_PART4: ${{ secrets.CA_BUNDLE_PART4 }}
CA_BUNDLE_PART5: ${{ secrets.CA_BUNDLE_PART5 }}
CA_BUNDLE_PART6: ${{ secrets.CA_BUNDLE_PART6 }}
CA_BUNDLE_PART7: ${{ secrets.CA_BUNDLE_PART7 }}
CA_BUNDLE_PART8: ${{ secrets.CA_BUNDLE_PART8 }}
CA_BUNDLE_PART9: ${{ secrets.CA_BUNDLE_PART9 }}
run: |
./scripts/assemble-certificates.sh --verify
- name: Build arm64 minimal container
run: |
docker build -t cac-builder:minimal-test-arm64 -f Dockerfile.optimized .
- name: Test minimal container
run: |
docker run --rm cac-builder:minimal-test-arm64 -c "mkdir -p /content/build && cd /content/build && cmake .. && echo 'Build environment test: SUCCESS'"
- name: Build arm64 full container
run: |
docker build -t cac-builder:full-test-arm64 -f Dockerfile --build-arg BUILD_TYPE=full .
- name: Test full container
run: |
mkdir -p output
docker run -v ${{ github.workspace }}/output:/output --rm cac-builder:full-test-arm64 -c "ls /content/build/ssg-* && cp /content/build/ssg-* /output/ 2>/dev/null || echo 'No content found, checking build environment'"
- name: Collect build info
run: |
# Create a detailed build-info file
{
echo "===== ARM64 Build Information ====="
echo "Build timestamp: $(date)"
echo "Architecture: arm64"
echo "Runner: ${{ runner.os }} (Apple Silicon)"
echo "Build triggered by: ${{ github.event_name }}"
echo "Job ID: ${{ github.job }}"
echo "Commit: ${{ github.sha }}"
echo "===== Output Files ====="
if [ "$(ls -A output/ 2>/dev/null)" ]; then
find output -type f -name "*.xml" | sort > output/arm64-file-list.txt
echo "File listing:"
cat output/arm64-file-list.txt
echo "File sizes:"
find output -type f -name "*.xml" -exec du -h {} \; | sort -h
else
echo "No output files found."
fi
} > output/arm64-build-info.txt
# Update to v4
- name: Upload arm64 artifacts
uses: actions/upload-artifact@v4
with:
name: cac-test-content-arm64
path: |
output/*.xml
output/*.xccdf.xml
output/*.ds.xml
output/arm64-build-info.txt
output/arm64-file-list.txt
if-no-files-found: warn
retention-days: 7
summarize:
name: Generate Build Summary
needs: [build-amd64, build-arm64]
runs-on: ubuntu-latest
steps:
# Update to v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare summary report
run: |
mkdir -p summary
echo "# CAC-Builder Test Results" > summary/README.md
echo "" >> summary/README.md
echo "## Build Summary" >> summary/README.md
echo "- Date: $(date)" >> summary/README.md
echo "- Commit: ${{ github.sha }}" >> summary/README.md
echo "- Triggered by: ${{ github.event_name }}" >> summary/README.md
echo "" >> summary/README.md
echo "## AMD64 Build" >> summary/README.md
if [ -f artifacts/cac-test-content-amd64/amd64-build-info.txt ]; then
echo '```' >> summary/README.md
cat artifacts/cac-test-content-amd64/amd64-build-info.txt >> summary/README.md
echo '```' >> summary/README.md
else
echo "No AMD64 build info available" >> summary/README.md
fi
echo "" >> summary/README.md
echo "## ARM64 Build" >> summary/README.md
if [ -f artifacts/cac-test-content-arm64/arm64-build-info.txt ]; then
echo '```' >> summary/README.md
cat artifacts/cac-test-content-arm64/arm64-build-info.txt >> summary/README.md
echo '```' >> summary/README.md
else
echo "No ARM64 build info available" >> summary/README.md
fi
# Update to v4
- name: Upload summary
uses: actions/upload-artifact@v4
with:
name: cac-builder-test-summary
path: summary/
retention-days: 14