chore: run e2e in finch vm #57
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-newFD-CI-test-${{ github.run_id }}-${{ github.run_attempt }} | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Clean macOS runner workspace | |
| run: | | |
| rm -rf ${{ github.workspace }}/* | |
| - name: Configure Git for ec2-user | |
| run: | | |
| # sudo chown -R ec2-user: /private | |
| git config --global --add safe.directory "*" | |
| shell: bash | |
| - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: false | |
| - name: Configure Go for ec2-user | |
| run: | | |
| # Ensure Go is properly configured for ec2-user | |
| chown -R ec2-user:staff $GOPATH || true | |
| chown -R ec2-user:staff $RUNNER_TOOL_CACHE/go || true | |
| # - name: List available users and system info | |
| # run: | | |
| # su ec2-user -c 'echo "Current user: $(whoami)" | |
| # echo "Current user ID: $(id -u)" | |
| # echo "Current user home: $HOME" | |
| # echo "Console user: $(stat -f "%Su" /dev/console)" | |
| # echo "All users:" | |
| # dscl . -list /Users | grep -v "^_" | |
| # echo "Users with home directories:" | |
| # ls -la /Users/ | |
| # echo "Environment variables:" | |
| # env | sort | |
| # echo "Brew info:" | |
| # which brew || echo "brew not found in PATH" | |
| # echo "PATH: $PATH"' | |
| - name: Install Rosetta 2 | |
| run: su ec2-user -c 'echo "A" | /usr/sbin/softwareupdate --install-rosetta --agree-to-license || true' | |
| - name: Configure Homebrew for ec2-user | |
| run: | | |
| echo "Creating .brewrc file for ec2-user..." | |
| cat > /Users/ec2-user/.brewrc << 'EOF' | |
| # Homebrew environment setup | |
| export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH" | |
| export HOMEBREW_PREFIX="/opt/homebrew" | |
| export HOMEBREW_CELLAR="/opt/homebrew/Cellar" | |
| export HOMEBREW_REPOSITORY="/opt/homebrew" | |
| export HOMEBREW_NO_AUTO_UPDATE=1 | |
| EOF | |
| chown ec2-user:staff /Users/ec2-user/.brewrc | |
| # Fix Homebrew permissions | |
| echo "Setting permissions for Homebrew directories..." | |
| mkdir -p /opt/homebrew/Cellar | |
| chown -R ec2-user:staff /opt/homebrew | |
| shell: bash | |
| # Install dependencies using ec2-user with custom environment | |
| - name: Install dependencies | |
| run: | | |
| echo "Installing dependencies as ec2-user..." | |
| # Run brew with custom environment | |
| su ec2-user -c 'source /Users/ec2-user/.brewrc && brew install lz4 automake autoconf libtool yq' | |
| shell: bash | |
| - 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 | |
| - name: Configure workspace for ec2-user | |
| run: | | |
| # Ensure workspace is properly owned by ec2-user | |
| chown -R ec2-user:staff ${{ github.workspace }} | |
| # Install Finch | |
| - name: Install Finch | |
| run: | | |
| echo "Installing Finch as ec2-user..." | |
| # Run brew with custom environment | |
| su ec2-user -c 'source /Users/ec2-user/.brewrc && brew install finch --cask' | |
| # Verify installation | |
| su ec2-user -c 'source /Users/ec2-user/.brewrc && brew list | grep finch || echo "finch not installed"' | |
| # Create .finch directory and config for ec2-user | |
| echo "Creating .finch directory and config for ec2-user..." | |
| su ec2-user -c 'mkdir -p /Users/ec2-user/.finch' | |
| su ec2-user -c 'echo "cpus: 4" > /Users/ec2-user/.finch/finch.yaml' | |
| su ec2-user -c 'echo "memory: 8GiB" >> /Users/ec2-user/.finch/finch.yaml' | |
| # Fix ownership of var/run directories | |
| echo "Fixing ownership of /private/var/run directories..." | |
| chown -R root:wheel /private/var/run | |
| mkdir -p /private/var/run/finch-lima | |
| chown -R root:wheel /private/var/run/finch-lima | |
| # Check finch version with HOME set to ec2-user's home | |
| echo "Checking finch version..." | |
| if ! su ec2-user -c 'HOME=/Users/ec2-user finch version'; then | |
| echo "finch version command failed, starting VM..." | |
| su ec2-user -c 'HOME=/Users/ec2-user finch vm init' | |
| fi | |
| shell: bash | |
| # Check for Finch socket | |
| # - name: Check for Finch socket | |
| # run: | | |
| # su ec2-user -c 'echo "Checking for Finch socket at /Applications/Finch/lima/data/finch/sock/finch.sock..." | |
| # # Check if the socket file exists | |
| # if test -S /Applications/Finch/lima/data/finch/sock/finch.sock; then | |
| # echo "Socket file exists" | |
| # else | |
| # echo "ERROR: Socket file not found at expected location /Applications/Finch/lima/data/finch/sock/finch.sock" | |
| # exit 1 | |
| # fi' | |
| # # Store the socket path for later steps (this needs to run as root to modify GITHUB_ENV) | |
| # echo "SOCKET_PATH=/Applications/Finch/lima/data/finch/sock/finch.sock" >> $GITHUB_ENV | |
| # shell: bash | |
| # Run e2e tests inside the Finch VM | |
| - name: Run e2e tests | |
| run: | | |
| echo "Running e2e tests as ec2-user..." | |
| su ec2-user -c "cd ${{ github.workspace }} && STATIC=1 GOPROXY=direct GOOS=linux GOARCH=$(GOARCH) make" | |
| su ec2-user -c 'HOME=/Users/ec2-user finch vm stop' | |
| su ec2-user -c 'HOME=/Users/ec2-user finch vm remove' | |
| su ec2-user -c "cp ${{ github.workspace }}/bin/finch-daemon -f /Applications/Finch/finch-daemon/finch-daemon" | |
| su ec2-user -c 'HOME=/Users/ec2-user finch vm init' | |
| su ec2-user -c make test-e2e-inside-vm | |
| shell: bash | |
| # Cleanup | |
| - name: Stop Finch VM | |
| run: | | |
| echo "Stopping Finch VM as ec2-user..." | |
| # Stop VM using ec2-user with custom environment | |
| su ec2-user -c "source /Users/ec2-user/.brewrc && HOME=/Users/ec2-user finch vm stop" | |
| shell: bash | |
| if: always() |