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