chore: run e2e in finch vm #2
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: macOS Tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - '**.md' | |
| pull_request: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - '**.md' | |
| workflow_dispatch: | |
| env: | |
| GO_VERSION: '1.23.8' | |
| jobs: | |
| mac-test: | |
| runs-on: codebuild-Test-fd-codebuild-mac-${{ github.run_id }}-${{ github.run_attempt }} | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Clean macOS runner workspace | |
| run: | | |
| rm -rf ${{ github.workspace }}/* | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| # We need to get all the git tags to make version injection work. See VERSION in Makefile for more detail. | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| submodules: recursive | |
| - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: false | |
| - name: Clean up previous files | |
| run: | | |
| sudo rm -rf /opt/finch | |
| sudo rm -rf ~/.finch | |
| sudo rm -rf ./_output | |
| if pgrep '^qemu-system'; then | |
| sudo pkill '^qemu-system' | |
| fi | |
| if pgrep '^socket_vmnet'; then | |
| sudo pkill '^socket_vmnet' | |
| fi | |
| - name: Install Rosetta 2 | |
| run: echo "A" | softwareupdate --install-rosetta || true | |
| - name: Install dependencies | |
| run: | | |
| # Ensure brew is not run as root | |
| if [ "$(id -u)" -eq 0 ]; then | |
| echo "Running as root, switching to regular user for brew commands" | |
| # Get the regular user | |
| REGULAR_USER=$(stat -f "%Su" /dev/console) | |
| su - $REGULAR_USER -c "brew install lz4 automake autoconf libtool yq" | |
| else | |
| brew install lz4 automake autoconf libtool yq | |
| fi | |
| shell: zsh {0} | |
| # Install Finch | |
| - name: Install Finch | |
| run: | | |
| # Ensure brew is not run as root | |
| if [ "$(id -u)" -eq 0 ]; then | |
| echo "Running as root, switching to regular user for brew commands" | |
| # Get the regular user | |
| REGULAR_USER=$(stat -f "%Su" /dev/console) | |
| su - $REGULAR_USER -c "brew install finch" | |
| else | |
| brew install finch | |
| fi | |
| shell: zsh {0} | |
| # Initialize and start Finch VM | |
| - name: Initialize Finch VM | |
| run: | | |
| # Ensure finch commands run as the same user who installed it | |
| if [ "$(id -u)" -eq 0 ]; then | |
| echo "Running as root, switching to regular user for finch commands" | |
| # Get the regular user | |
| REGULAR_USER=$(stat -f "%Su" /dev/console) | |
| su - $REGULAR_USER -c "finch vm init" | |
| else | |
| finch vm init | |
| fi | |
| - name: Start Finch VM | |
| run: | | |
| # Ensure finch commands run as the same user who installed it | |
| if [ "$(id -u)" -eq 0 ]; then | |
| echo "Running as root, switching to regular user for finch commands" | |
| # Get the regular user | |
| REGULAR_USER=$(stat -f "%Su" /dev/console) | |
| su - $REGULAR_USER -c "finch vm start" | |
| else | |
| finch vm start | |
| fi | |
| # Run e2e tests inside the Finch VM | |
| - name: Run e2e tests | |
| run: | | |
| # Set the DOCKER_HOST environment variable | |
| export DOCKER_HOST=unix:///Applications/Finch/lima/data/finch/sock/finch.sock | |
| make test-e2e | |
| # Run e2e tests with OPA authorization | |
| - name: Run opa e2e tests | |
| run: | | |
| # Set the DOCKER_HOST environment variable | |
| export DOCKER_HOST=unix:///Applications/Finch/lima/data/finch/sock/finch.sock | |
| make test-e2e-opa | |
| # Cleanup | |
| - name: Stop Finch VM | |
| run: | | |
| # Ensure finch commands run as the same user who installed it | |
| if [ "$(id -u)" -eq 0 ]; then | |
| echo "Running as root, switching to regular user for finch commands" | |
| # Get the regular user | |
| REGULAR_USER=$(stat -f "%Su" /dev/console) | |
| su - $REGULAR_USER -c "finch vm stop" | |
| else | |
| finch vm stop | |
| fi | |
| if: always() |