Skip to content

Commit 1687365

Browse files
committed
feat: add finch vm testing
Signed-off-by: Arjun Raja Yogidas <[email protected]>
1 parent 1aec7ce commit 1687365

File tree

2 files changed

+139
-0
lines changed

2 files changed

+139
-0
lines changed

.github/workflows/finch-vm-test.yaml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: finch vm Tests
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-vm-test:
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+
# Run e2e tests inside the Finch VM
97+
- name: Run e2e tests
98+
run: |
99+
echo "Running e2e tests as root-user..."
100+
su ec2-user -c 'cd ${{ github.workspace }} && STATIC=1 GOPROXY=direct GOOS=linux GOARCH=$(GOARCH) make'
101+
# su ec2-user -c 'finch vm stop'
102+
su ec2-user -c 'finch vm remove -f'
103+
104+
cp -f ${{ github.workspace }}/bin/finch-daemon /Applications/Finch/finch-daemon/finch-daemon
105+
su ec2-user -c 'finch vm init'
106+
su ec2-user -c 'make test-e2e-inside-vm'
107+
shell: bash
108+
109+
# Cleanup
110+
- name: Stop Finch VM
111+
run: |
112+
echo "Stopping Finch VM as ec2-user..."
113+
114+
# Stop VM using ec2-user with custom environment
115+
su ec2-user -c "source /Users/ec2-user/.brewrc && HOME=/Users/ec2-user finch vm stop"
116+
shell: bash
117+
if: always()

Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,25 @@ coverage: linux
163163
release: linux
164164
@echo "$@"
165165
@$(FINCH_DAEMON_PROJECT_ROOT)/scripts/create-releases.sh $(RELEASE_TAG)
166+
167+
.PHONY: macos
168+
macos:
169+
ifeq ($(shell uname), Darwin)
170+
@echo "Running on macOS"
171+
else
172+
$(error This target can only be run on macOS!)
173+
endif
174+
175+
176+
DAEMON_DOCKER_HOST := "unix:///Applications/Finch/lima/data/finch/sock/finch.sock"
177+
# DAEMON_ROOT
178+
179+
.PHONY: test-e2e-inside-vm
180+
test-e2e-inside-vm: macos
181+
DOCKER_HOST=$(DAEMON_DOCKER_HOST) \
182+
DOCKER_API_VERSION="v1.41" \
183+
TEST_E2E=1 \
184+
go test ./e2e -test.v -ginkgo.v -ginkgo.randomize-all \
185+
--subject="finch" \
186+
--daemon-context-subject-prefix="/Applications/Finch/lima/bin/limactl shell finch sudo" \
187+
--daemon-context-subject-env="LIMA_HOME=/Applications/Finch/lima/data"

0 commit comments

Comments
 (0)