Skip to content

Commit 3642944

Browse files
authored
Merge branch 'master' into cfldtBugFix
2 parents 56396aa + cb856f7 commit 3642944

File tree

108 files changed

+13672
-10698
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+13672
-10698
lines changed

.github/workflows/bench.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ jobs:
6262
device: gpu
6363
interface: acc
6464
build_script: "bash .github/workflows/frontier/build.sh gpu acc bench"
65+
- cluster: frontier
66+
name: Oak Ridge | Frontier (CCE)
67+
group: phoenix
68+
labels: frontier
69+
flag: f
70+
device: gpu
71+
interface: omp
72+
build_script: "bash .github/workflows/frontier/build.sh gpu omp bench"
6573
runs-on:
6674
group: ${{ matrix.group }}
6775
labels: ${{ matrix.labels }}

.github/workflows/deploy-tap.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Deploy Homebrew Tap
2+
3+
on:
4+
# Test formula on PRs (audit only, don't deploy)
5+
pull_request:
6+
branches: [ master ]
7+
paths:
8+
- 'packaging/homebrew/mfc.rb'
9+
- 'packaging/homebrew/README.md'
10+
# Deploy to tap on push to master
11+
push:
12+
branches: [ master, homebrew-new ]
13+
paths:
14+
- 'packaging/homebrew/mfc.rb'
15+
- 'packaging/homebrew/README.md'
16+
tags:
17+
- 'v*.*.*'
18+
# Allow manual trigger for testing
19+
workflow_dispatch:
20+
21+
permissions:
22+
contents: read
23+
24+
jobs:
25+
deploy-tap:
26+
name: Audit and deploy formula
27+
runs-on: macos-14
28+
permissions:
29+
contents: write
30+
pull-requests: write
31+
steps:
32+
- name: Checkout MFC repository
33+
uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
36+
37+
- name: Determine event metadata
38+
id: meta
39+
run: |
40+
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
41+
VERSION="${GITHUB_REF_NAME#v}"
42+
URL="https://github.com/${{ github.repository }}/archive/refs/tags/v${VERSION}.tar.gz"
43+
else
44+
# Extract URL from current formula to re-audit and sync
45+
URL="$(grep -Eo 'https://github.com/.*/archive/refs/tags/v[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz' packaging/homebrew/mfc.rb | head -n1)"
46+
VERSION="$(echo "${URL}" | sed -E 's/.*v([0-9]+\.[0-9]+\.[0-9]+)\.tar\.gz/\1/')"
47+
fi
48+
SHASUM="$(curl -sL "${URL}" | shasum -a 256 | awk '{print $1}')"
49+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
50+
echo "url=${URL}" >> $GITHUB_OUTPUT
51+
echo "sha256=${SHASUM}" >> $GITHUB_OUTPUT
52+
echo "Event: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
53+
echo "Version: ${VERSION}" >> $GITHUB_STEP_SUMMARY
54+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
55+
echo "Mode: Audit only (PR)" >> $GITHUB_STEP_SUMMARY
56+
else
57+
echo "Mode: Audit and deploy" >> $GITHUB_STEP_SUMMARY
58+
fi
59+
60+
- name: Update formula (for tag events)
61+
if: github.ref_type == 'tag'
62+
run: |
63+
/usr/bin/sed -i '' "s@^ url \".*\"@ url \"${{ steps.meta.outputs.url }}\"@" packaging/homebrew/mfc.rb
64+
/usr/bin/sed -i '' "s@^ sha256 \".*\"@ sha256 \"${{ steps.meta.outputs.sha256 }}\"@" packaging/homebrew/mfc.rb
65+
66+
- name: Setup Homebrew
67+
uses: Homebrew/actions/setup-homebrew@master
68+
69+
- name: Audit/style formula before pushing
70+
run: |
71+
brew style packaging/homebrew/mfc.rb
72+
# Create temporary tap to audit the formula
73+
brew tap-new mfc/local
74+
cp packaging/homebrew/mfc.rb "$(brew --repository)/Library/Taps/mfc/homebrew-local/Formula/mfc.rb"
75+
brew audit --online --strict --new --except=homepage mfc/local/mfc || brew audit --online mfc/local/mfc
76+
brew untap mfc/local
77+
78+
- name: Clone or bootstrap tap repository
79+
if: github.event_name != 'pull_request'
80+
env:
81+
TAP_TOKEN: ${{ secrets.TAP_REPO_TOKEN }}
82+
run: |
83+
set -euo pipefail
84+
REPO="https://x-access-token:${TAP_TOKEN}@github.com/MFlowCode/homebrew-mfc.git"
85+
if git ls-remote "${REPO}" HEAD >/dev/null 2>&1; then
86+
git clone "${REPO}" tap-repo
87+
else
88+
# Repo exists but might be empty; fall back to bootstrap
89+
mkdir -p tap-repo
90+
cd tap-repo
91+
git init -b main
92+
git remote add origin "${REPO}"
93+
touch .keep
94+
git add .keep
95+
git -c user.name="github-actions[bot]" -c user.email="github-actions[bot]@users.noreply.github.com" commit -m "Initialize tap"
96+
git push -u origin main
97+
fi
98+
99+
- name: Copy formula and README into tap
100+
if: github.event_name != 'pull_request'
101+
run: |
102+
mkdir -p tap-repo/Formula
103+
cp packaging/homebrew/mfc.rb tap-repo/Formula/mfc.rb
104+
cp packaging/homebrew/README.md tap-repo/README.md
105+
106+
- name: Commit & push if changed
107+
if: github.event_name != 'pull_request'
108+
env:
109+
TAP_TOKEN: ${{ secrets.TAP_REPO_TOKEN }}
110+
run: |
111+
cd tap-repo
112+
git add Formula/mfc.rb README.md
113+
if git diff --cached --quiet; then
114+
echo "No changes in Formula/mfc.rb or README.md; skipping push."
115+
exit 0
116+
fi
117+
git -c user.name="github-actions[bot]" -c user.email="github-actions[bot]@users.noreply.github.com" \
118+
commit -m "mfc: v${{ steps.meta.outputs.version }}"
119+
git push origin HEAD:main
120+

.github/workflows/homebrew.yml

Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
name: Homebrew Formula Test
2+
3+
on:
4+
push:
5+
paths:
6+
- 'packaging/homebrew/**'
7+
- '.github/workflows/homebrew.yml'
8+
pull_request:
9+
paths:
10+
- 'packaging/homebrew/**'
11+
- '.github/workflows/homebrew.yml'
12+
workflow_dispatch:
13+
14+
jobs:
15+
# Fast smoke tests that run before expensive operations
16+
smoke-test:
17+
name: Quick Formula Validation
18+
runs-on: ubuntu-latest # Use Linux for speed (Homebrew works on Linux too)
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Homebrew
25+
uses: Homebrew/actions/setup-homebrew@master
26+
27+
- name: Validate formula syntax with brew style
28+
run: |
29+
echo "Checking formula syntax..."
30+
brew style packaging/homebrew/mfc.rb
31+
32+
- name: Run brew audit (without installation)
33+
run: |
34+
echo "Configuring git for brew tap-new..."
35+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
36+
git config --global user.name "github-actions[bot]"
37+
38+
echo "Creating temporary local tap..."
39+
brew tap-new mflowcode/test
40+
cp packaging/homebrew/mfc.rb $(brew --repository)/Library/Taps/mflowcode/homebrew-test/Formula/mfc.rb
41+
42+
echo "Running brew audit (online checks)..."
43+
brew audit --online --skip-style mflowcode/test/mfc || true
44+
45+
echo "Cleaning up tap..."
46+
brew untap mflowcode/test
47+
48+
- name: Validate Ruby syntax
49+
run: |
50+
echo "Checking Ruby syntax..."
51+
ruby -c packaging/homebrew/mfc.rb
52+
53+
- name: Check for common formula issues
54+
run: |
55+
echo "Checking for common issues..."
56+
57+
# Check that required fields are present
58+
grep -q 'desc "' packaging/homebrew/mfc.rb || (echo "❌ Missing desc"; exit 1)
59+
grep -q 'homepage "' packaging/homebrew/mfc.rb || (echo "❌ Missing homepage"; exit 1)
60+
grep -q 'url "' packaging/homebrew/mfc.rb || (echo "❌ Missing url"; exit 1)
61+
grep -q 'sha256 "' packaging/homebrew/mfc.rb || (echo "❌ Missing sha256"; exit 1)
62+
grep -q 'license "' packaging/homebrew/mfc.rb || (echo "❌ Missing license"; exit 1)
63+
64+
# Check that install method exists
65+
grep -q 'def install' packaging/homebrew/mfc.rb || (echo "❌ Missing install method"; exit 1)
66+
67+
# Check that test block exists
68+
grep -q 'test do' packaging/homebrew/mfc.rb || (echo "❌ Missing test block"; exit 1)
69+
70+
echo "✅ All required formula components present"
71+
72+
- name: Verify URL is reachable
73+
run: |
74+
echo "Checking that source URL is reachable..."
75+
URL=$(grep -E 'url "https://[^"]+' packaging/homebrew/mfc.rb | head -1 | sed 's/.*url "\([^"]*\)".*/\1/')
76+
77+
if [ -z "$URL" ]; then
78+
echo "❌ Could not extract URL from formula"
79+
exit 1
80+
fi
81+
82+
echo "URL: $URL"
83+
HTTP_CODE=$(curl -sI -w "%{http_code}" -o /dev/null "$URL")
84+
85+
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "302" ]; then
86+
echo "✅ URL is reachable (HTTP $HTTP_CODE)"
87+
else
88+
echo "⚠️ URL returned HTTP $HTTP_CODE (may indicate an issue)"
89+
# Don't fail here - could be a temporary issue
90+
fi
91+
92+
- name: Verify SHA256 checksum
93+
run: |
94+
echo "Verifying SHA256 checksum matches URL..."
95+
URL=$(grep -E 'url "https://[^"]+' packaging/homebrew/mfc.rb | head -1 | sed 's/.*url "\([^"]*\)".*/\1/')
96+
EXPECTED_SHA=$(grep 'sha256 "' packaging/homebrew/mfc.rb | head -1 | sed 's/.*sha256 "\([^"]*\)".*/\1/')
97+
98+
if [ -z "$URL" ] || [ -z "$EXPECTED_SHA" ]; then
99+
echo "❌ Could not extract URL or SHA256 from formula"
100+
exit 1
101+
fi
102+
103+
echo "Downloading tarball to compute checksum..."
104+
ACTUAL_SHA=$(curl -sL "$URL" | shasum -a 256 | awk '{print $1}')
105+
106+
echo "Expected SHA256: $EXPECTED_SHA"
107+
echo "Actual SHA256: $ACTUAL_SHA"
108+
109+
if [ "$EXPECTED_SHA" = "$ACTUAL_SHA" ]; then
110+
echo "✅ SHA256 checksum matches!"
111+
else
112+
echo "❌ SHA256 mismatch!"
113+
exit 1
114+
fi
115+
116+
# Full installation test (only runs if smoke tests pass)
117+
test-formula:
118+
name: Full Installation Test
119+
needs: smoke-test # Only run after smoke tests pass
120+
runs-on: macos-latest
121+
122+
steps:
123+
- name: Checkout repository
124+
uses: actions/checkout@v4
125+
126+
- name: Set up Homebrew
127+
run: |
128+
echo "Homebrew version:"
129+
brew --version
130+
echo "Updating Homebrew..."
131+
brew update
132+
133+
- name: Install formula dependencies
134+
run: |
135+
echo "Installing MFC dependencies..."
136+
brew install cmake gcc [email protected] boost fftw hdf5 open-mpi openblas
137+
138+
- name: Install MFC from formula
139+
run: |
140+
echo "Creating temporary local tap..."
141+
brew tap-new mflowcode/test
142+
143+
echo "Copying formula to tap..."
144+
cp packaging/homebrew/mfc.rb $(brew --repository)/Library/Taps/mflowcode/homebrew-test/Formula/mfc.rb
145+
146+
echo "Installing MFC from local tap..."
147+
# Note: brew may exit with code 1 due to dylib fixup warnings on some Python packages (non-fatal)
148+
# We verify installation using brew commands rather than parsing log output
149+
set +e # Don't fail immediately on error
150+
brew install --build-from-source --verbose mflowcode/test/mfc 2>&1 | tee /tmp/brew-install.log
151+
brew_exit_code=$?
152+
set -e
153+
154+
# Verify installation using brew list (more robust than log parsing)
155+
if brew list mflowcode/test/mfc &>/dev/null; then
156+
echo "✅ MFC installed successfully (ignoring dylib relocation warnings)"
157+
# Optionally verify with brew info
158+
brew info mflowcode/test/mfc
159+
exit 0
160+
else
161+
echo "❌ MFC installation failed"
162+
exit $brew_exit_code
163+
fi
164+
165+
- name: Display error logs on failure
166+
if: failure()
167+
run: |
168+
echo "=== Displaying last 200 lines of brew install log ==="
169+
if [ -f /tmp/brew-install.log ]; then
170+
tail -200 /tmp/brew-install.log
171+
fi
172+
173+
echo -e "\n=== Displaying Homebrew log files ==="
174+
if [ -d ~/Library/Logs/Homebrew/mfc/ ]; then
175+
for logfile in ~/Library/Logs/Homebrew/mfc/*; do
176+
if [ -f "$logfile" ]; then
177+
echo -e "\n\n====== $logfile ======"
178+
cat "$logfile"
179+
fi
180+
done
181+
fi
182+
183+
echo -e "\n=== Searching for Cantera config.log ==="
184+
cantera_config_log=$(find /private/tmp -name "config.log" -path "*/mfc--cantera*" 2>/dev/null | head -1)
185+
if [ -n "$cantera_config_log" ] && [ -f "$cantera_config_log" ]; then
186+
echo -e "\n\n====== Cantera config.log ======"
187+
echo "Found at: $cantera_config_log"
188+
cat "$cantera_config_log"
189+
# Copy to a known location for artifact upload
190+
mkdir -p /tmp/cantera-logs
191+
cp "$cantera_config_log" /tmp/cantera-logs/config.log
192+
else
193+
echo "Cantera config.log not found"
194+
echo "Searching in all /private/tmp directories:"
195+
find /private/tmp -name "config.log" 2>/dev/null || echo "No config.log files found"
196+
fi
197+
198+
- name: Upload Homebrew logs on failure
199+
if: failure()
200+
uses: actions/upload-artifact@v4
201+
with:
202+
name: homebrew-logs
203+
path: |
204+
/tmp/brew-install.log
205+
/tmp/cantera-logs/
206+
~/Library/Logs/Homebrew/mfc/
207+
if-no-files-found: ignore
208+
209+
- name: Test MFC installation
210+
run: |
211+
echo "=== Testing MFC Installation ==="
212+
213+
echo "1. Checking binaries exist and are executable..."
214+
test -f $(brew --prefix)/bin/mfc && test -x $(brew --prefix)/bin/mfc
215+
test -f $(brew --prefix)/bin/pre_process && test -x $(brew --prefix)/bin/pre_process
216+
test -f $(brew --prefix)/bin/simulation && test -x $(brew --prefix)/bin/simulation
217+
test -f $(brew --prefix)/bin/post_process && test -x $(brew --prefix)/bin/post_process
218+
echo " ✓ All binaries exist and are executable"
219+
220+
echo "2. Verifying installation structure..."
221+
test -f $(brew --prefix mfc)/libexec/mfc.sh
222+
test -d $(brew --prefix mfc)/toolchain
223+
echo " ✓ Installation structure verified"
224+
225+
echo "3. Checking Python venv..."
226+
test -d $(brew --prefix mfc)/libexec/venv
227+
test -f $(brew --prefix mfc)/libexec/venv/bin/python
228+
test -f $(brew --prefix mfc)/libexec/venv/bin/pip
229+
echo " ✓ Python venv exists"
230+
231+
echo "4. Checking examples..."
232+
test -d $(brew --prefix mfc)/examples
233+
test -f $(brew --prefix mfc)/examples/1D_sodshocktube/case.py
234+
echo " ✓ Examples installed"
235+
236+
echo "5. Testing mfc wrapper..."
237+
mfc --help
238+
echo " ✓ mfc --help succeeded"
239+
240+
echo "=== All tests passed! ==="
241+
242+
- name: Run MFC test case
243+
run: |
244+
echo "Running a simple test case (1D Sod shock tube)..."
245+
TESTDIR=$(mktemp -d)
246+
cp $(brew --prefix mfc)/examples/1D_sodshocktube/case.py "$TESTDIR/"
247+
248+
echo "Running with $(sysctl -n hw.ncpu) processors..."
249+
# Use absolute path and shorthand syntax (mfc auto-detects and prepends 'run')
250+
mfc "$TESTDIR/case.py" -j $(sysctl -n hw.ncpu)
251+
252+
echo "Test case completed successfully!"
253+
254+
- name: Uninstall and cleanup
255+
if: always()
256+
run: |
257+
echo "Cleaning up..."
258+
brew uninstall mfc || true
259+
brew cleanup

0 commit comments

Comments
 (0)