Refactor GitHub Actions workflow for bottle management #26
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-bot: | |
| strategy: | |
| matrix: | |
| os: [macos-14] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Set up Homebrew | |
| uses: Homebrew/actions/setup-homebrew@v4 | |
| with: | |
| core: true | |
| stable: true | |
| - name: Checkout tap | |
| uses: actions/checkout@v4 | |
| - name: Set variables | |
| id: set_vars | |
| run: | | |
| echo "root_url=https://github.com/${{ github.repository }}/releases/download/bottles" >> $GITHUB_OUTPUT | |
| - name: Build, bottle, and publish (push to main) | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| env: | |
| HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| brew test-bot --only-formulae --root-url="${{ steps.set_vars.outputs.root_url }}" mfc | |
| - name: Build and test only (PR or workflow_dispatch) | |
| if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' | |
| run: | | |
| brew install --build-from-source ./Formula/mfc.rb | |
| brew test mfc | |
| - name: Upload bottles as artifact | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bottles-${{ matrix.os }} | |
| path: '*.bottle.*' | |
| if-no-files-found: ignore | |
| - name: Cleanup | |
| if: always() | |
| continue-on-error: true | |
| run: | | |
| brew uninstall --force mfc || true | |
| if brew tap | grep -q mflowcode/test; then | |
| brew untap mflowcode/test || true | |
| fi | |
| if [ -d "/opt/homebrew/Library/Taps/mflowcode/homebrew-mfc" ]; then | |
| rm -rf /opt/homebrew/Library/Taps/mflowcode/homebrew-mfc || true | |
| fi | |
| test-run-case: | |
| needs: test-bot | |
| runs-on: macos-14 | |
| steps: | |
| - name: Set up Homebrew | |
| uses: Homebrew/actions/setup-homebrew@v4 | |
| with: | |
| core: true | |
| stable: true | |
| - name: Checkout tap | |
| uses: actions/checkout@v4 | |
| - name: Install MFC | |
| run: | | |
| brew install --build-from-source ./Formula/mfc.rb | |
| - name: Run Sod shock tube test case | |
| run: | | |
| mkdir -p ~/test_mfc_case | |
| cd ~/test_mfc_case | |
| cp $(brew --prefix mfc)/examples/1D_sodshocktube/case.py . | |
| mfc run case.py -j 1 | |
| - name: Verify output | |
| run: | | |
| test -d ~/test_mfc_case/silo_hdf5 | |
| echo "✅ Test case ran successfully and produced output" | |
| - name: Cleanup | |
| if: always() | |
| run: | | |
| brew uninstall --force mfc || true | |
| rm -rf ~/test_mfc_case | |
| verify-install: | |
| needs: test-run-case | |
| runs-on: macos-14 | |
| steps: | |
| - name: Set up Homebrew | |
| uses: Homebrew/actions/setup-homebrew@v4 | |
| with: | |
| core: true | |
| stable: true | |
| - name: Checkout tap | |
| uses: actions/checkout@v4 | |
| - name: Install MFC | |
| run: | | |
| brew install --build-from-source ./Formula/mfc.rb | |
| - name: Verify installation | |
| run: | | |
| 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" | |
| - name: Cleanup | |
| if: always() | |
| run: | | |
| brew uninstall --force mfc || true |