Skip to content

Commit 87dbd98

Browse files
committed
chore: run e2e in finch vm
Signed-off-by: Arjun Raja Yogidas <[email protected]>
1 parent 7ec7d02 commit 87dbd98

File tree

1 file changed

+159
-0
lines changed

1 file changed

+159
-0
lines changed

.github/workflows/mac-test.yaml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
name: macOS 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-test:
18+
runs-on: codebuild-Test-fd-codebuild-mac-${{ 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+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25+
with:
26+
# We need to get all the git tags to make version injection work. See VERSION in Makefile for more detail.
27+
fetch-depth: 0
28+
persist-credentials: false
29+
submodules: recursive
30+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
31+
with:
32+
go-version: ${{ env.GO_VERSION }}
33+
cache: false
34+
- name: Clean up previous files
35+
run: |
36+
sudo rm -rf /opt/finch
37+
sudo rm -rf ~/.finch
38+
sudo rm -rf ./_output
39+
if pgrep '^qemu-system'; then
40+
sudo pkill '^qemu-system'
41+
fi
42+
if pgrep '^socket_vmnet'; then
43+
sudo pkill '^socket_vmnet'
44+
fi
45+
46+
# Debug step to see available users
47+
- name: List available users and system info
48+
run: |
49+
echo "Current user: $(whoami)"
50+
echo "Current user ID: $(id -u)"
51+
echo "Current user home: $HOME"
52+
echo "Console user: $(stat -f "%Su" /dev/console)"
53+
echo "All users:"
54+
dscl . -list /Users | grep -v '^_'
55+
echo "Users with home directories:"
56+
ls -la /Users/
57+
echo "Environment variables:"
58+
env | sort
59+
echo "Brew info:"
60+
which brew || echo "brew not found in PATH"
61+
echo "PATH: $PATH"
62+
63+
- name: Install Rosetta 2
64+
run: echo "A" | softwareupdate --install-rosetta || true
65+
66+
# Fix Homebrew permissions and setup environment
67+
- name: Fix Homebrew permissions and setup environment
68+
run: |
69+
echo "Fixing Homebrew permissions for ec2-user..."
70+
sudo chown -R ec2-user:staff /opt/homebrew
71+
72+
# Create a cache directory that ec2-user can access
73+
sudo mkdir -p /tmp/homebrew-cache
74+
sudo chown -R ec2-user:staff /tmp/homebrew-cache
75+
76+
# Create a .brewrc file for ec2-user with environment settings
77+
sudo -u ec2-user bash -c 'cat > /Users/ec2-user/.brewrc << EOF
78+
export HOMEBREW_NO_AUTO_UPDATE=1
79+
export HOMEBREW_NO_INSTALL_CLEANUP=1
80+
export HOMEBREW_CACHE=/tmp/homebrew-cache
81+
export HOMEBREW_NO_ENV_HINTS=1
82+
EOF'
83+
84+
# Make sure ec2-user sources the .brewrc file
85+
sudo -u ec2-user bash -c 'echo "source ~/.brewrc" >> ~/.zshrc'
86+
sudo -u ec2-user bash -c 'echo "source ~/.brewrc" >> ~/.bashrc'
87+
88+
# Install dependencies using ec2-user with custom environment
89+
- name: Install dependencies
90+
run: |
91+
echo "Installing dependencies as ec2-user..."
92+
93+
# Run brew with custom environment
94+
sudo -u ec2-user bash -c 'source /Users/ec2-user/.brewrc && brew install lz4 automake autoconf libtool yq'
95+
96+
# Verify installation
97+
sudo -u ec2-user bash -c 'brew list | grep lz4 || echo "lz4 not installed"'
98+
shell: bash
99+
100+
# Install Finch
101+
- name: Install Finch
102+
run: |
103+
echo "Installing Finch as ec2-user..."
104+
105+
# Run brew with custom environment
106+
sudo -u ec2-user bash -c 'source /Users/ec2-user/.brewrc && brew install finch'
107+
108+
# Verify installation
109+
sudo -u ec2-user bash -c 'brew list | grep finch || echo "finch not installed"'
110+
sudo -u ec2-user bash -c 'which finch || echo "finch not in PATH"'
111+
shell: bash
112+
113+
# Initialize and start Finch VM
114+
- name: Initialize Finch VM
115+
run: |
116+
echo "Initializing Finch VM as ec2-user..."
117+
118+
# Initialize VM using ec2-user with custom environment
119+
sudo -u ec2-user bash -c 'source /Users/ec2-user/.brewrc && finch vm init'
120+
shell: bash
121+
122+
- name: Start Finch VM
123+
run: |
124+
echo "Starting Finch VM as ec2-user..."
125+
126+
# Start VM using ec2-user with custom environment
127+
sudo -u ec2-user bash -c 'source /Users/ec2-user/.brewrc && finch vm start'
128+
129+
# Verify VM is running
130+
sudo -u ec2-user bash -c 'source /Users/ec2-user/.brewrc && finch vm ls || echo "Cannot verify if VM is running"'
131+
shell: bash
132+
133+
# Run e2e tests inside the Finch VM
134+
- name: Run e2e tests
135+
run: |
136+
echo "Running e2e tests as ec2-user..."
137+
138+
# Run tests using ec2-user with custom environment
139+
sudo -u ec2-user bash -c "source /Users/ec2-user/.brewrc && cd ${{ github.workspace }} && DOCKER_HOST=unix:///Applications/Finch/lima/data/finch/sock/finch.sock make test-e2e"
140+
shell: bash
141+
142+
# Run e2e tests with OPA authorization
143+
- name: Run opa e2e tests
144+
run: |
145+
echo "Running e2e tests with OPA authorization as ec2-user..."
146+
147+
# Run tests using ec2-user with custom environment
148+
sudo -u ec2-user bash -c "source /Users/ec2-user/.brewrc && cd ${{ github.workspace }} && DOCKER_HOST=unix:///Applications/Finch/lima/data/finch/sock/finch.sock make test-e2e-opa"
149+
shell: bash
150+
151+
# Cleanup
152+
- name: Stop Finch VM
153+
run: |
154+
echo "Stopping Finch VM as ec2-user..."
155+
156+
# Stop VM using ec2-user with custom environment
157+
sudo -u ec2-user bash -c 'source /Users/ec2-user/.brewrc && finch vm stop'
158+
shell: bash
159+
if: always()

0 commit comments

Comments
 (0)