Skip to content

Commit 7cae9ff

Browse files
committed
ci: environment tests moved from CodeSpaces CI to validate_environment.sh script
1 parent 32677f0 commit 7cae9ff

File tree

3 files changed

+86
-142
lines changed

3 files changed

+86
-142
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"--init"
7575
],
7676
"updateContentCommand": "sudo mkdir -p /workspaces/api_reference_deps && sudo chown -R ubuntu:ubuntu /workspaces/api_reference_deps",
77-
"postCreateCommand": "pipx upgrade conan && .devcontainer/api_reference.sh -s && .devcontainer/check_all.sh -d install",
77+
"postCreateCommand": "pipx upgrade-all && .devcontainer/validate_environment.sh && .devcontainer/check_all.sh -d install && .devcontainer/api_reference.sh -s",
7878
"postStartCommand": "echo '🚀 mp-units development environment ready!' && echo '🧪 Use `.devcontainer/check_all.sh [-d] build` to test all compiler configurations.' && echo '📖 Use `.devcontainer/api_reference.sh` to generate the API reference documentation.'",
7979
"forwardPorts": [
8080
8000
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
3+
# Validates that the mp-units Docker image has all required prerequisites
4+
# This runs BEFORE devcontainer lifecycle commands to ensure the base image is correct
5+
6+
set -e
7+
8+
echo "🧪 Validating mp-units Docker image prerequisites..."
9+
echo ""
10+
11+
# Verify essential tools are available in the base image
12+
echo "📋 Verifying essential tools:"
13+
tools=(gcc g++ clang clang++ cmake ninja conan pre-commit mkdocs)
14+
all_found=true
15+
for tool in "${tools[@]}"; do
16+
if command -v "$tool" >/dev/null 2>&1; then
17+
echo "$tool"
18+
else
19+
echo "$tool: NOT FOUND"
20+
all_found=false
21+
fi
22+
done
23+
24+
if [ "$all_found" = false ]; then
25+
echo ""
26+
echo "❌ Docker image is missing required tools"
27+
exit 1
28+
fi
29+
30+
echo ""
31+
echo "🔧 Default tool versions:"
32+
gcc --version | head -1
33+
g++ --version | head -1
34+
clang --version | head -1
35+
clang++ --version | head -1
36+
cmake --version | head -1
37+
ninja --version
38+
conan --version
39+
pre-commit --version
40+
mkdocs --version
41+
42+
echo ""
43+
echo "📋 Verifying compiler matrix:"
44+
45+
# Expected GCC versions (12, 13, 14, 15)
46+
expected_gcc=(12 13 14 15)
47+
for version in "${expected_gcc[@]}"; do
48+
if command -v "gcc-$version" >/dev/null 2>&1 && command -v "g++-$version" >/dev/null 2>&1; then
49+
echo " ✅ GCC-$version"
50+
else
51+
echo " ❌ GCC-$version: NOT FOUND"
52+
exit 1
53+
fi
54+
done
55+
56+
# Expected Clang versions (16, 17, 18, 19, 20, 21)
57+
expected_clang=(16 17 18 19 20 21)
58+
for version in "${expected_clang[@]}"; do
59+
if command -v "clang-$version" >/dev/null 2>&1 && command -v "clang++-$version" >/dev/null 2>&1; then
60+
echo " ✅ Clang-$version"
61+
else
62+
echo " ❌ Clang-$version: NOT FOUND"
63+
exit 1
64+
fi
65+
done
66+
67+
echo ""
68+
echo "📦 Verifying Conan profiles exist in image:"
69+
70+
# Verify expected Conan profiles exist in the Docker image
71+
expected_profiles=(gcc12 gcc13 gcc14 gcc15 clang16 clang17 clang18 clang19 clang20 clang21)
72+
for profile in "${expected_profiles[@]}"; do
73+
if conan profile show -pr "$profile" >/dev/null 2>&1; then
74+
echo " ✅ Profile $profile"
75+
else
76+
echo " ❌ Profile $profile: MISSING"
77+
exit 1
78+
fi
79+
done
80+
81+
echo ""
82+
echo "✅ Docker image validation passed! Ready for devcontainer lifecycle commands."

.github/workflows/codespaces-test.yml

Lines changed: 3 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -47,150 +47,12 @@ jobs:
4747
- name: Pull latest Docker image
4848
run: docker pull trainiteu/mp-units:latest
4949

50-
- name: Test Dev Container Build and mp-units Development Workflow
50+
- name: Test Dev Container Build and Setup
5151
uses: devcontainers/ci@v0.3.1900000417
5252
with:
5353
imageName: mp-units-dev
5454
cacheFrom: mp-units-dev
5555
push: never
5656
runCmd: |
57-
set -e # Exit on any error
58-
59-
echo "🧪 Testing mp-units development environment..."
60-
echo "📋 Verifying base tools and compilers:"
61-
62-
# Check essential tools are available
63-
tools=(gcc g++ clang clang++ cmake ninja conan python3 git pre-commit)
64-
for tool in "${tools[@]}"; do
65-
if command -v "$tool" >/dev/null 2>&1; then
66-
echo "✅ $tool: $(command -v "$tool")"
67-
else
68-
echo "❌ $tool: NOT FOUND"
69-
exit 1
70-
fi
71-
done
72-
73-
echo ""
74-
echo "📋 Compiler matrix verification:"
75-
echo "Available GCC versions: $(ls /usr/bin/gcc-* | grep -E 'gcc-[0-9]+$' | sort -V | tr '\n' ' ')"
76-
echo "Available Clang versions: $(ls /usr/bin/clang++-* /usr/local/bin/clang++-* 2>/dev/null | grep -E 'clang\+\+-[0-9]+$' | sort -V | tr '\n' ' ')"
77-
78-
# Test specific compiler versions expected for mp-units
79-
echo ""
80-
echo "🧪 Testing specific compiler versions:"
81-
82-
# Expected GCC versions (12, 13, 14, 15)
83-
expected_gcc=(12 13 14 15)
84-
for version in "${expected_gcc[@]}"; do
85-
if command -v "gcc-$version" >/dev/null 2>&1 && command -v "g++-$version" >/dev/null 2>&1; then
86-
gcc_ver=$(gcc-$version --version | head -1)
87-
echo "✅ GCC-$version: $gcc_ver"
88-
else
89-
echo "❌ GCC-$version: NOT FOUND"
90-
exit 1
91-
fi
92-
done
93-
94-
# Expected Clang versions (16, 17, 18, 19, 20)
95-
expected_clang=(16 17 18 19 20)
96-
for version in "${expected_clang[@]}"; do
97-
if command -v "clang-$version" >/dev/null 2>&1 && command -v "clang++-$version" >/dev/null 2>&1; then
98-
clang_ver=$(clang-$version --version | head -1)
99-
echo "✅ Clang-$version: $clang_ver"
100-
else
101-
echo "❌ Clang-$version: NOT FOUND"
102-
exit 1
103-
fi
104-
done
105-
106-
echo ""
107-
echo "🔧 Default tool versions:"
108-
gcc --version | head -1
109-
clang --version | head -1
110-
cmake --version | head -1
111-
ninja --version
112-
python3 --version
113-
conan --version
114-
115-
echo ""
116-
echo "📦 Conan configuration validation:"
117-
conan profile list
118-
119-
# Verify expected Conan profiles exist
120-
expected_profiles=(gcc12 gcc13 gcc14 clang16 clang17 clang18 clang20)
121-
for profile in "${expected_profiles[@]}"; do
122-
if conan profile show "$profile" >/dev/null 2>&1; then
123-
echo "✅ Profile $profile: available"
124-
else
125-
echo "❌ Profile $profile: MISSING"
126-
exit 1
127-
fi
128-
done
129-
130-
echo ""
131-
echo "🏗️ Testing mp-units comprehensive setup with check_all.sh:"
132-
133-
# Run the comprehensive installation and validation script
134-
echo "Running check_all.sh install to validate all compiler configurations..."
135-
if .devcontainer/check_all.sh install; then
136-
echo "✅ check_all.sh install completed successfully"
137-
echo "✅ All compiler profiles validated and dependencies installed"
138-
else
139-
echo "❌ check_all.sh install failed"
140-
exit 1
141-
fi
142-
143-
echo ""
144-
echo "🎯 Testing quick build validation:"
145-
# Test one quick build to ensure the environment actually works
146-
echo "Testing quick build with Clang-20..."
147-
if conan create . -pr clang20 -c user.mp-units.build:all=False -s compiler.cppstd=23 -b missing; then
148-
echo "✅ Quick build test passed"
149-
else
150-
echo "❌ Quick build test failed"
151-
exit 1
152-
fi
153-
154-
echo ""
155-
echo "📖 Testing documentation tools:"
156-
if command -v mkdocs >/dev/null 2>&1; then
157-
echo "✅ MkDocs: $(mkdocs --version)"
158-
# Test mkdocs configuration
159-
if mkdocs build --strict --quiet; then
160-
echo "✅ Documentation builds successfully"
161-
else
162-
echo "❌ Documentation build failed"
163-
exit 1
164-
fi
165-
else
166-
echo "❌ MkDocs: NOT FOUND"
167-
exit 1
168-
fi
169-
170-
echo ""
171-
echo "🎯 Testing API reference setup:"
172-
if [ -f ".devcontainer/api_reference.sh" ]; then
173-
echo "✅ API reference script exists"
174-
# Test setup-only mode
175-
if .devcontainer/api_reference.sh -s; then
176-
echo "✅ API reference setup completed"
177-
else
178-
echo "❌ API reference setup failed"
179-
exit 1
180-
fi
181-
else
182-
echo "❌ API reference script missing"
183-
exit 1
184-
fi
185-
186-
echo ""
187-
echo "🧹 Testing code quality tools:"
188-
if pre-commit --version >/dev/null 2>&1; then
189-
echo "✅ pre-commit: $(pre-commit --version)"
190-
else
191-
echo "❌ pre-commit: NOT FOUND"
192-
exit 1
193-
fi
194-
195-
echo ""
196-
echo "🎉 All tests passed! Development environment is ready for mp-units development."
57+
echo "✅ Devcontainer build and setup completed successfully"
58+
echo "Validation was performed during postCreateCommand"

0 commit comments

Comments
 (0)