mfc: v5.1.4 #69
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Bottle | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'Formula/**' | |
| - '.github/workflows/bottle.yml' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| test-and-bottle: | |
| name: Test and build bottles per macOS | |
| strategy: | |
| matrix: | |
| os: [macos-14, macos-15, macos-26] # Sonoma, Sequoia, Tahoe (public preview) | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout tap | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Homebrew | |
| uses: Homebrew/actions/setup-homebrew@master | |
| - name: Determine version and root URL | |
| id: meta | |
| run: | | |
| set -euo pipefail | |
| # Extract URL from the formula (e.g. .../v5.1.0.tar.gz) | |
| URL=$(grep -E 'url "https://github.com/.*/archive/refs/tags/v[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz"' Formula/mfc.rb \ | |
| | sed -E 's/.*url "([^"]+)".*/\1/') | |
| if [[ -z "${URL}" ]]; then | |
| echo "Could not extract URL from Formula/mfc.rb" >&2 | |
| exit 1 | |
| fi | |
| # Parse version from the URL (…/vX.Y.Z.tar.gz) | |
| VERSION=$(echo "${URL}" | sed -E 's/.*v([0-9]+\.[0-9]+\.[0-9]+)\.tar\.gz/\1/') | |
| if [[ -z "${VERSION}" ]]; then | |
| echo "Could not parse version from URL: ${URL}" >&2 | |
| exit 1 | |
| fi | |
| TAG="mfc-${VERSION}" | |
| ROOT_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}" | |
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "tag=${TAG}" >> "$GITHUB_OUTPUT" | |
| echo "root_url=${ROOT_URL}" >> "$GITHUB_OUTPUT" | |
| - name: Install formula with --build-bottle | |
| run: | | |
| set -euo pipefail | |
| echo "Installing mfc with --build-bottle (allowing non-fatal dylib fixup failures)..." | |
| # Homebrew may exit non-zero due to dylib ID fixup issues in Python wheels, | |
| # even though the formula actually installed correctly. Treat that as | |
| # non-fatal as long as the formula is present. | |
| set +e | |
| brew install --build-bottle mflowcode/mfc/mfc 2>&1 | tee /tmp/brew-install.log | |
| brew_exit_code=$? | |
| set -e | |
| if brew list mflowcode/mfc/mfc &>/dev/null; then | |
| echo "✅ mfc installed successfully (ignoring dylib fixup warnings)" | |
| else | |
| echo "❌ mfc installation failed; propagating brew exit code" | |
| exit $brew_exit_code | |
| fi | |
| - name: Run Sod shock tube test case | |
| run: | | |
| set -euo pipefail | |
| echo "Running a simple test case (1D Sod shock tube) on ${{ matrix.os }}..." | |
| TESTDIR=$(mktemp -d) | |
| cp "$(brew --prefix mfc)/examples/1D_sodshocktube/case.py" "$TESTDIR/" | |
| cd "$TESTDIR" | |
| mfc case.py -j 1 | |
| test -d "$TESTDIR/silo_hdf5" | |
| echo "✅ Test case ran successfully and produced output" | |
| - name: Basic installation verification | |
| run: | | |
| set -euo pipefail | |
| echo "1. Checking binaries..." | |
| test -x "$(brew --prefix mfc)/bin/pre_process" | |
| test -x "$(brew --prefix mfc)/bin/simulation" | |
| test -x "$(brew --prefix mfc)/bin/post_process" | |
| test -x "$(brew --prefix mfc)/bin/mfc" | |
| echo "2. Checking toolchain..." | |
| test -d "$(brew --prefix mfc)/toolchain" | |
| echo "3. Checking Python venv..." | |
| test -d "$(brew --prefix mfc)/libexec/venv" | |
| test -x "$(brew --prefix mfc)/libexec/venv/bin/python" | |
| echo "4. Checking examples..." | |
| test -d "$(brew --prefix mfc)/examples" | |
| echo "5. Testing mfc command..." | |
| mfc --help | |
| echo "✅ All verification checks passed on ${{ matrix.os }}" | |
| - name: Build bottle | |
| run: | | |
| set -euo pipefail | |
| # Build bottle and emit JSON metadata for merge step | |
| brew bottle --root-url="${{ steps.meta.outputs.root_url }}" --json mfc | |
| ls -1 *.bottle.* | |
| - name: Upload bottle artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bottles-${{ matrix.os }} | |
| path: | | |
| *.bottle.* | |
| merge-bottles: | |
| name: Merge bottles and update formula | |
| needs: test-and-bottle | |
| runs-on: macos-14 | |
| steps: | |
| - name: Checkout tap | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Homebrew | |
| uses: Homebrew/actions/setup-homebrew@master | |
| - name: Determine version and root URL | |
| id: meta | |
| run: | | |
| set -euo pipefail | |
| URL=$(grep -E 'url "https://github.com/.*/archive/refs/tags/v[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz"' Formula/mfc.rb \ | |
| | sed -E 's/.*url "([^"]+)".*/\1/') | |
| if [[ -z "${URL}" ]]; then | |
| echo "Could not extract URL from Formula/mfc.rb" >&2 | |
| exit 1 | |
| fi | |
| VERSION=$(echo "${URL}" | sed -E 's/.*v([0-9]+\.[0-9]+\.[0-9]+)\.tar\.gz/\1/') | |
| if [[ -z "${VERSION}" ]]; then | |
| echo "Could not parse version from URL: ${URL}" >&2 | |
| exit 1 | |
| fi | |
| TAG="mfc-${VERSION}" | |
| ROOT_URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/${TAG}" | |
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "tag=${TAG}" >> "$GITHUB_OUTPUT" | |
| echo "root_url=${ROOT_URL}" >> "$GITHUB_OUTPUT" | |
| - name: Download all bottle artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: bottles | |
| - name: Flatten bottle directory | |
| run: | | |
| set -euo pipefail | |
| echo "Before flattening:" | |
| find bottles -name '*.bottle.*' -type f | |
| # Move all bottle files from subdirectories to bottles/ root | |
| find bottles -mindepth 2 -name '*.bottle.*' -type f -exec mv {} bottles/ \; | |
| echo "" | |
| echo "After flattening:" | |
| ls -1 bottles/*.bottle.* | |
| - name: Rename bottles for GitHub release | |
| run: | | |
| set -euo pipefail | |
| echo "Renaming bottles (mfc-- → mfc-)..." | |
| # Rename mfc--VERSION to mfc-VERSION for all bottle files | |
| for file in bottles/mfc--*.bottle.*; do | |
| if [[ -f "$file" ]]; then | |
| newname=$(echo "$file" | sed 's/mfc--/mfc-/') | |
| mv "$file" "$newname" | |
| echo " $file → $newname" | |
| fi | |
| done | |
| echo "" | |
| echo "Bottles ready for upload:" | |
| ls -1 bottles/*.bottle.* | |
| - name: Merge bottle metadata into formula | |
| run: | | |
| set -euo pipefail | |
| # Collect all JSON metadata files (now in bottles/ root) | |
| JSON_BOTTLES=(bottles/*.bottle*.json) | |
| if [[ ! -e "${JSON_BOTTLES[0]}" ]]; then | |
| echo "No bottle metadata (*.bottle*.json) found in bottles/" | |
| ls -la bottles/ | |
| exit 1 | |
| fi | |
| echo "Merging bottle metadata from:" | |
| printf '%s\n' "${JSON_BOTTLES[@]}" | |
| # Use --write which auto-commits, but capture the current HEAD first | |
| BEFORE_SHA=$(git rev-parse HEAD) | |
| echo "HEAD before merge: ${BEFORE_SHA}" | |
| brew bottle --merge --write "${JSON_BOTTLES[@]}" | |
| AFTER_SHA=$(git rev-parse HEAD) | |
| echo "HEAD after merge: ${AFTER_SHA}" | |
| if [[ "${BEFORE_SHA}" != "${AFTER_SHA}" ]]; then | |
| echo "✅ New bottle commit created by brew bottle --write" | |
| echo "bottle_updated=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "ℹ️ No new commit (bottles unchanged or already present)" | |
| echo "bottle_updated=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| id: merge | |
| - name: Push bottle updates if changed | |
| if: steps.merge.outputs.bottle_updated == 'true' | |
| run: | | |
| set -euo pipefail | |
| echo "Pushing bottle update commit..." | |
| git log -1 --stat | |
| # Configure git to use the GitHub token for authentication | |
| git config --local --unset-all http.https://github.com/.extraheader || true | |
| git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git | |
| git push origin HEAD:main | |
| - name: Create or update GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ steps.meta.outputs.tag }} | |
| name: MFC bottles ${{ steps.meta.outputs.version }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload bottles to Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ steps.meta.outputs.tag }} | |
| files: bottles/*.bottle.* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |