-
Notifications
You must be signed in to change notification settings - Fork 150
265 lines (217 loc) · 10.1 KB
/
Copy pathhomebrew.yml
File metadata and controls
265 lines (217 loc) · 10.1 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
255
256
257
258
259
260
261
262
263
264
265
name: Homebrew Formula Test
on:
push:
paths:
- 'packaging/homebrew/**'
- '.github/workflows/homebrew.yml'
pull_request:
paths:
- 'packaging/homebrew/**'
- '.github/workflows/homebrew.yml'
workflow_dispatch:
jobs:
# Fast smoke tests that run before expensive operations
smoke-test:
name: Quick Formula Validation
runs-on: ubuntu-latest # Use Linux for speed (Homebrew works on Linux too)
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Validate formula syntax with brew style
run: |
echo "Checking formula syntax..."
brew style packaging/homebrew/mfc.rb
- name: Run brew audit (without installation)
run: |
echo "Configuring git for brew tap-new..."
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
echo "Creating temporary local tap..."
brew tap-new mflowcode/test
cp packaging/homebrew/mfc.rb $(brew --repository)/Library/Taps/mflowcode/homebrew-test/Formula/mfc.rb
echo "Running brew audit (online checks)..."
brew audit --online --skip-style mflowcode/test/mfc || true
echo "Cleaning up tap..."
brew untap mflowcode/test
- name: Validate Ruby syntax
run: |
echo "Checking Ruby syntax..."
ruby -c packaging/homebrew/mfc.rb
- name: Check for common formula issues
run: |
echo "Checking for common issues..."
# Check that required fields are present
grep -q 'desc "' packaging/homebrew/mfc.rb || (echo "❌ Missing desc"; exit 1)
grep -q 'homepage "' packaging/homebrew/mfc.rb || (echo "❌ Missing homepage"; exit 1)
grep -q 'url "' packaging/homebrew/mfc.rb || (echo "❌ Missing url"; exit 1)
grep -q 'sha256 "' packaging/homebrew/mfc.rb || (echo "❌ Missing sha256"; exit 1)
grep -q 'license "' packaging/homebrew/mfc.rb || (echo "❌ Missing license"; exit 1)
# Check that install method exists
grep -q 'def install' packaging/homebrew/mfc.rb || (echo "❌ Missing install method"; exit 1)
# Check that test block exists
grep -q 'test do' packaging/homebrew/mfc.rb || (echo "❌ Missing test block"; exit 1)
echo "✅ All required formula components present"
- name: Verify URL is reachable
run: |
echo "Checking that source URL is reachable..."
URL=$(grep -E 'url "https://[^"]+' packaging/homebrew/mfc.rb | head -1 | sed 's/.*url "\([^"]*\)".*/\1/')
if [ -z "$URL" ]; then
echo "❌ Could not extract URL from formula"
exit 1
fi
echo "URL: $URL"
HTTP_CODE=$(curl -sI -w "%{http_code}" -o /dev/null "$URL")
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "302" ]; then
echo "✅ URL is reachable (HTTP $HTTP_CODE)"
else
echo "⚠️ URL returned HTTP $HTTP_CODE (may indicate an issue)"
# Don't fail here - could be a temporary issue
fi
- name: Verify SHA256 checksum
run: |
echo "Verifying SHA256 checksum matches URL..."
URL=$(grep -E 'url "https://[^"]+' packaging/homebrew/mfc.rb | head -1 | sed 's/.*url "\([^"]*\)".*/\1/')
EXPECTED_SHA=$(grep 'sha256 "' packaging/homebrew/mfc.rb | head -1 | sed 's/.*sha256 "\([^"]*\)".*/\1/')
if [ -z "$URL" ] || [ -z "$EXPECTED_SHA" ]; then
echo "❌ Could not extract URL or SHA256 from formula"
exit 1
fi
echo "Downloading tarball to compute checksum..."
ACTUAL_SHA=$(curl -sL "$URL" | shasum -a 256 | awk '{print $1}')
echo "Expected SHA256: $EXPECTED_SHA"
echo "Actual SHA256: $ACTUAL_SHA"
if [ "$EXPECTED_SHA" = "$ACTUAL_SHA" ]; then
echo "✅ SHA256 checksum matches!"
else
echo "❌ SHA256 mismatch!"
exit 1
fi
# Full installation test (only runs if smoke tests pass)
test-formula:
name: Full Installation Test
needs: smoke-test # Only run after smoke tests pass
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Homebrew
run: |
echo "Homebrew version:"
brew --version
echo "Updating Homebrew..."
brew update
- name: Install formula dependencies
run: |
echo "Installing MFC dependencies..."
brew install cmake gcc python@3.12 boost fftw hdf5 open-mpi openblas
- name: Install MFC from formula
run: |
echo "Creating temporary local tap..."
brew tap-new mflowcode/test
echo "Copying formula to tap..."
cp packaging/homebrew/mfc.rb $(brew --repository)/Library/Taps/mflowcode/homebrew-test/Formula/mfc.rb
echo "Installing MFC from local tap..."
# Note: brew may exit with code 1 due to dylib fixup warnings on some Python packages (non-fatal)
# We verify installation using brew commands rather than parsing log output
set +e # Don't fail immediately on error
brew install --build-from-source --verbose mflowcode/test/mfc 2>&1 | tee /tmp/brew-install.log
brew_exit_code=$?
set -e
# Verify installation using brew list (more robust than log parsing)
if brew list mflowcode/test/mfc &>/dev/null; then
echo "✅ MFC installed successfully (ignoring dylib relocation warnings)"
# Optionally verify with brew info
brew info mflowcode/test/mfc
exit 0
else
echo "❌ MFC installation failed"
exit $brew_exit_code
fi
- name: Display error logs on failure
if: failure()
run: |
echo "=== Displaying last 200 lines of brew install log ==="
if [ -f /tmp/brew-install.log ]; then
tail -200 /tmp/brew-install.log
fi
echo -e "\n=== Displaying Homebrew log files ==="
if [ -d ~/Library/Logs/Homebrew/mfc/ ]; then
for logfile in ~/Library/Logs/Homebrew/mfc/*; do
if [ -f "$logfile" ]; then
echo -e "\n\n====== $logfile ======"
cat "$logfile"
fi
done
fi
echo -e "\n=== Searching for Cantera config.log ==="
cantera_config_log=$(find /private/tmp -name "config.log" -path "*/mfc--cantera*" 2>/dev/null | head -1)
if [ -n "$cantera_config_log" ] && [ -f "$cantera_config_log" ]; then
echo -e "\n\n====== Cantera config.log ======"
echo "Found at: $cantera_config_log"
cat "$cantera_config_log"
# Copy to a known location for artifact upload
mkdir -p /tmp/cantera-logs
cp "$cantera_config_log" /tmp/cantera-logs/config.log
else
echo "Cantera config.log not found"
echo "Searching in all /private/tmp directories:"
find /private/tmp -name "config.log" 2>/dev/null || echo "No config.log files found"
fi
- name: Upload Homebrew logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: homebrew-logs
path: |
/tmp/brew-install.log
/tmp/cantera-logs/
~/Library/Logs/Homebrew/mfc/
if-no-files-found: ignore
- name: Test MFC installation
run: |
echo "=== Testing MFC Installation ==="
# Use the full tap-qualified name since we installed from mflowcode/test
MFC_PREFIX="$(brew --prefix mflowcode/test/mfc)"
echo "MFC prefix: $MFC_PREFIX"
echo "1. Checking binaries exist and are executable..."
test -f $(brew --prefix)/bin/mfc && test -x $(brew --prefix)/bin/mfc
test -f $(brew --prefix)/bin/pre_process && test -x $(brew --prefix)/bin/pre_process
test -f $(brew --prefix)/bin/simulation && test -x $(brew --prefix)/bin/simulation
test -f $(brew --prefix)/bin/post_process && test -x $(brew --prefix)/bin/post_process
echo " ✓ All binaries exist and are executable"
echo "2. Verifying installation structure..."
test -f "$MFC_PREFIX/libexec/mfc.sh"
test -d "$MFC_PREFIX/toolchain"
echo " ✓ Installation structure verified"
echo "3. Checking Python venv..."
test -d "$MFC_PREFIX/libexec/venv"
test -f "$MFC_PREFIX/libexec/venv/bin/python"
test -f "$MFC_PREFIX/libexec/venv/bin/pip"
echo " ✓ Python venv exists"
echo "4. Checking examples..."
test -d "$MFC_PREFIX/examples"
test -f "$MFC_PREFIX/examples/1D_sodshocktube/case.py"
echo " ✓ Examples installed"
echo "5. Testing mfc wrapper..."
mfc --help
echo " ✓ mfc --help succeeded"
echo "=== All tests passed! ==="
- name: Run MFC test case
run: |
echo "Running a simple test case (1D Sod shock tube)..."
MFC_PREFIX="$(brew --prefix mflowcode/test/mfc)"
TESTDIR=$(mktemp -d)
cp "$MFC_PREFIX/examples/1D_sodshocktube/case.py" "$TESTDIR/"
echo "Running with $(sysctl -n hw.ncpu) processors..."
# Use absolute path and shorthand syntax (mfc auto-detects and prepends 'run')
mfc "$TESTDIR/case.py" -j $(sysctl -n hw.ncpu)
echo "Test case completed successfully!"
- name: Uninstall and cleanup
if: always()
run: |
echo "Cleaning up..."
brew uninstall mflowcode/test/mfc || true
brew untap mflowcode/test || true
brew cleanup