|  | 
|  | 1 | +name: Finch VM | 
|  | 2 | +on: | 
|  | 3 | +  push: | 
|  | 4 | +    branches: | 
|  | 5 | +      - main | 
|  | 6 | +    paths-ignore: | 
|  | 7 | +      - '**.md' | 
|  | 8 | +  pull_request: | 
|  | 9 | +    branches: | 
|  | 10 | +      - main | 
|  | 11 | +    paths-ignore: | 
|  | 12 | +      - '**.md' | 
|  | 13 | +  workflow_dispatch: | 
|  | 14 | +env: | 
|  | 15 | +  GO_VERSION: '1.23.8' | 
|  | 16 | +jobs: | 
|  | 17 | +  mac-test-e2e: | 
|  | 18 | +    runs-on: codebuild-finch-daemon-arm64-2-instance-${{ github.run_id }}-${{ github.run_attempt }} | 
|  | 19 | +    timeout-minutes: 30 | 
|  | 20 | +    steps: | 
|  | 21 | +      - name: Clean macOS runner workspace | 
|  | 22 | +        run: | | 
|  | 23 | +          rm -rf ${{ github.workspace }}/* | 
|  | 24 | +      - name: Configure Git for ec2-user | 
|  | 25 | +        run: | | 
|  | 26 | +          # sudo chown -R ec2-user: /private | 
|  | 27 | +          git config --global --add safe.directory "*" | 
|  | 28 | +        shell: bash | 
|  | 29 | +      - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 | 
|  | 30 | +        with: | 
|  | 31 | +          go-version: ${{ env.GO_VERSION }} | 
|  | 32 | +          cache: false | 
|  | 33 | + | 
|  | 34 | +      - name: Configure Go for ec2-user | 
|  | 35 | +        run: | | 
|  | 36 | +          # Ensure Go is properly configured for ec2-user | 
|  | 37 | +          chown -R ec2-user:staff $GOPATH || true | 
|  | 38 | +          chown -R ec2-user:staff $RUNNER_TOOL_CACHE/go || true | 
|  | 39 | +      - name: Install Rosetta 2 | 
|  | 40 | +        run: su ec2-user -c 'echo "A" | /usr/sbin/softwareupdate --install-rosetta --agree-to-license || true' | 
|  | 41 | + | 
|  | 42 | +      - name: Configure Homebrew for ec2-user | 
|  | 43 | +        run: | | 
|  | 44 | +          echo "Creating .brewrc file for ec2-user..." | 
|  | 45 | +          cat > /Users/ec2-user/.brewrc << 'EOF' | 
|  | 46 | +          # Homebrew environment setup | 
|  | 47 | +          export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH" | 
|  | 48 | +          export HOMEBREW_PREFIX="/opt/homebrew" | 
|  | 49 | +          export HOMEBREW_CELLAR="/opt/homebrew/Cellar" | 
|  | 50 | +          export HOMEBREW_REPOSITORY="/opt/homebrew" | 
|  | 51 | +          export HOMEBREW_NO_AUTO_UPDATE=1 | 
|  | 52 | +          EOF | 
|  | 53 | +          chown ec2-user:staff /Users/ec2-user/.brewrc | 
|  | 54 | +
 | 
|  | 55 | +          # Fix Homebrew permissions | 
|  | 56 | +          echo "Setting permissions for Homebrew directories..." | 
|  | 57 | +          mkdir -p /opt/homebrew/Cellar | 
|  | 58 | +          chown -R ec2-user:staff /opt/homebrew | 
|  | 59 | +        shell: bash | 
|  | 60 | + | 
|  | 61 | +      # Install dependencies using ec2-user with custom environment | 
|  | 62 | +      - name: Install dependencies | 
|  | 63 | +        run: | | 
|  | 64 | +          echo "Installing dependencies as ec2-user..." | 
|  | 65 | +          # Run brew with custom environment | 
|  | 66 | +          su ec2-user -c 'source /Users/ec2-user/.brewrc && brew install lz4 automake autoconf libtool yq' | 
|  | 67 | +        shell: bash | 
|  | 68 | + | 
|  | 69 | +      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | 
|  | 70 | +        with: | 
|  | 71 | +          # We need to get all the git tags to make version injection work. See VERSION in Makefile for more detail. | 
|  | 72 | +          fetch-depth: 0 | 
|  | 73 | +          persist-credentials: false | 
|  | 74 | +          submodules: recursive | 
|  | 75 | + | 
|  | 76 | +      - name: Configure workspace for ec2-user | 
|  | 77 | +        run: | | 
|  | 78 | +          # Ensure workspace is properly owned by ec2-user | 
|  | 79 | +          chown -R ec2-user:staff ${{ github.workspace }} | 
|  | 80 | +
 | 
|  | 81 | +      # Install Finch | 
|  | 82 | +      - name: Install Finch | 
|  | 83 | +        run: | | 
|  | 84 | +          echo "Installing Finch as ec2-user..." | 
|  | 85 | +
 | 
|  | 86 | +          # Run brew with custom environment | 
|  | 87 | +          su ec2-user -c 'source /Users/ec2-user/.brewrc && brew install finch --cask' | 
|  | 88 | +
 | 
|  | 89 | +          # Verify installation | 
|  | 90 | +          su ec2-user -c 'source /Users/ec2-user/.brewrc && brew list | grep finch || echo "finch not installed"' | 
|  | 91 | +          mkdir -p /private/var/run/finch-lima | 
|  | 92 | +          cat /etc/passwd | 
|  | 93 | +          chown ec2-user:daemon /private/var/run/finch-lima | 
|  | 94 | +        shell: bash | 
|  | 95 | + | 
|  | 96 | +      # Build binaries | 
|  | 97 | +      - name: Build binaries | 
|  | 98 | +        run: | | 
|  | 99 | +          echo "Building cross architecture binaries..." | 
|  | 100 | +          su ec2-user -c 'cd ${{ github.workspace }} && STATIC=1 GOPROXY=direct GOOS=linux GOARCH=$(GOARCH) make' | 
|  | 101 | +          su ec2-user -c 'finch vm remove -f' | 
|  | 102 | +          cp -f ${{ github.workspace }}/bin/finch-daemon /Applications/Finch/finch-daemon/finch-daemon | 
|  | 103 | +        shell: bash | 
|  | 104 | + | 
|  | 105 | +      # Initialize VM and check version | 
|  | 106 | +      - name: Check Finch version | 
|  | 107 | +        run: | | 
|  | 108 | +          echo "Initializing VM and checking version..." | 
|  | 109 | +          su ec2-user -c 'finch vm init' | 
|  | 110 | +          sleep 5  # Wait for services to be ready | 
|  | 111 | +          echo "Checking Finch version..." | 
|  | 112 | +          su ec2-user -c 'LIMA_HOME=/Applications/Finch/lima/data /Applications/Finch/lima/bin/limactl shell finch curl --unix-socket /var/run/finch.sock -X GET http:/v1.43/version' | 
|  | 113 | +        shell: bash | 
|  | 114 | + | 
|  | 115 | +      # Run e2e tests | 
|  | 116 | +      - name: Run e2e tests | 
|  | 117 | +        run: | | 
|  | 118 | +          echo "Running e2e tests..." | 
|  | 119 | +          su ec2-user -c 'make test-e2e-inside-vm' | 
|  | 120 | +        shell: bash | 
|  | 121 | + | 
|  | 122 | +      # Cleanup | 
|  | 123 | +      - name: Stop Finch VM | 
|  | 124 | +        run: | | 
|  | 125 | +          echo "Stopping Finch VM as ec2-user..." | 
|  | 126 | +
 | 
|  | 127 | +          # Stop VM using ec2-user with custom environment | 
|  | 128 | +          su ec2-user -c "source /Users/ec2-user/.brewrc && HOME=/Users/ec2-user finch vm stop" | 
|  | 129 | +        shell: bash | 
|  | 130 | +        if: always() | 
0 commit comments