|
| 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 | + # Try a simpler approach for brew commands |
| 66 | + - name: Install dependencies |
| 67 | + run: | |
| 68 | + # Try different approaches to run brew |
| 69 | + echo "Attempting to install dependencies..." |
| 70 | + |
| 71 | + # Approach 1: Direct brew command |
| 72 | + brew install lz4 automake autoconf libtool yq || true |
| 73 | + |
| 74 | + # Approach 2: Use specific brew path |
| 75 | + /opt/homebrew/bin/brew install lz4 automake autoconf libtool yq || true |
| 76 | + |
| 77 | + # Approach 3: Use sudo with specific user if available |
| 78 | + if id runner &>/dev/null; then |
| 79 | + echo "Using 'runner' user" |
| 80 | + sudo -u runner /opt/homebrew/bin/brew install lz4 automake autoconf libtool yq || true |
| 81 | + fi |
| 82 | + |
| 83 | + # Approach 4: Use current non-root user from environment |
| 84 | + if [ -n "$SUDO_USER" ]; then |
| 85 | + echo "Using SUDO_USER: $SUDO_USER" |
| 86 | + sudo -u $SUDO_USER /opt/homebrew/bin/brew install lz4 automake autoconf libtool yq || true |
| 87 | + fi |
| 88 | + |
| 89 | + # Verify installation |
| 90 | + brew list | grep lz4 || echo "lz4 not installed" |
| 91 | + shell: zsh {0} |
| 92 | + |
| 93 | + # Install Finch |
| 94 | + - name: Install Finch |
| 95 | + run: | |
| 96 | + # Try different approaches to install Finch |
| 97 | + echo "Attempting to install Finch..." |
| 98 | + |
| 99 | + # Approach 1: Direct brew command |
| 100 | + brew install finch || true |
| 101 | + |
| 102 | + # Approach 2: Use specific brew path |
| 103 | + /opt/homebrew/bin/brew install finch || true |
| 104 | + |
| 105 | + # Approach 3: Use sudo with specific user if available |
| 106 | + if id runner &>/dev/null; then |
| 107 | + echo "Using 'runner' user" |
| 108 | + sudo -u runner /opt/homebrew/bin/brew install finch || true |
| 109 | + fi |
| 110 | + |
| 111 | + # Approach 4: Use current non-root user from environment |
| 112 | + if [ -n "$SUDO_USER" ]; then |
| 113 | + echo "Using SUDO_USER: $SUDO_USER" |
| 114 | + sudo -u $SUDO_USER /opt/homebrew/bin/brew install finch || true |
| 115 | + fi |
| 116 | + |
| 117 | + # Verify installation |
| 118 | + brew list | grep finch || echo "finch not installed" |
| 119 | + which finch || echo "finch not in PATH" |
| 120 | + shell: zsh {0} |
| 121 | + |
| 122 | + # Initialize and start Finch VM |
| 123 | + - name: Initialize Finch VM |
| 124 | + run: | |
| 125 | + echo "Attempting to initialize Finch VM..." |
| 126 | + |
| 127 | + # Approach 1: Direct finch command |
| 128 | + finch vm init || true |
| 129 | + |
| 130 | + # Approach 2: Use specific finch path |
| 131 | + /opt/homebrew/bin/finch vm init || true |
| 132 | + |
| 133 | + # Approach 3: Use sudo with specific user if available |
| 134 | + if id runner &>/dev/null; then |
| 135 | + echo "Using 'runner' user" |
| 136 | + sudo -u runner /opt/homebrew/bin/finch vm init || true |
| 137 | + fi |
| 138 | + |
| 139 | + # Approach 4: Use current non-root user from environment |
| 140 | + if [ -n "$SUDO_USER" ]; then |
| 141 | + echo "Using SUDO_USER: $SUDO_USER" |
| 142 | + sudo -u $SUDO_USER /opt/homebrew/bin/finch vm init || true |
| 143 | + fi |
| 144 | + |
| 145 | + - name: Start Finch VM |
| 146 | + run: | |
| 147 | + echo "Attempting to start Finch VM..." |
| 148 | + |
| 149 | + # Approach 1: Direct finch command |
| 150 | + finch vm start || true |
| 151 | + |
| 152 | + # Approach 2: Use specific finch path |
| 153 | + /opt/homebrew/bin/finch vm start || true |
| 154 | + |
| 155 | + # Approach 3: Use sudo with specific user if available |
| 156 | + if id runner &>/dev/null; then |
| 157 | + echo "Using 'runner' user" |
| 158 | + sudo -u runner /opt/homebrew/bin/finch vm start || true |
| 159 | + fi |
| 160 | + |
| 161 | + # Approach 4: Use current non-root user from environment |
| 162 | + if [ -n "$SUDO_USER" ]; then |
| 163 | + echo "Using SUDO_USER: $SUDO_USER" |
| 164 | + sudo -u $SUDO_USER /opt/homebrew/bin/finch vm start || true |
| 165 | + fi |
| 166 | + |
| 167 | + # Verify VM is running |
| 168 | + finch vm ls || /opt/homebrew/bin/finch vm ls || echo "Cannot verify if VM is running" |
| 169 | + |
| 170 | + # Run e2e tests inside the Finch VM |
| 171 | + - name: Run e2e tests |
| 172 | + run: | |
| 173 | + echo "Attempting to run e2e tests..." |
| 174 | + |
| 175 | + # Approach 1: Direct command |
| 176 | + export DOCKER_HOST=unix:///Applications/Finch/lima/data/finch/sock/finch.sock |
| 177 | + make test-e2e || true |
| 178 | + |
| 179 | + # Approach 2: Use sudo with specific user if available |
| 180 | + if id runner &>/dev/null; then |
| 181 | + echo "Using 'runner' user" |
| 182 | + sudo -u runner bash -c "cd ${{ github.workspace }} && DOCKER_HOST=unix:///Applications/Finch/lima/data/finch/sock/finch.sock make test-e2e" || true |
| 183 | + fi |
| 184 | + |
| 185 | + # Approach 3: Use current non-root user from environment |
| 186 | + if [ -n "$SUDO_USER" ]; then |
| 187 | + echo "Using SUDO_USER: $SUDO_USER" |
| 188 | + sudo -u $SUDO_USER bash -c "cd ${{ github.workspace }} && DOCKER_HOST=unix:///Applications/Finch/lima/data/finch/sock/finch.sock make test-e2e" || true |
| 189 | + fi |
| 190 | + |
| 191 | + # Run e2e tests with OPA authorization |
| 192 | + - name: Run opa e2e tests |
| 193 | + run: | |
| 194 | + echo "Attempting to run e2e tests with OPA authorization..." |
| 195 | + |
| 196 | + # Approach 1: Direct command |
| 197 | + export DOCKER_HOST=unix:///Applications/Finch/lima/data/finch/sock/finch.sock |
| 198 | + make test-e2e-opa || true |
| 199 | + |
| 200 | + # Approach 2: Use sudo with specific user if available |
| 201 | + if id runner &>/dev/null; then |
| 202 | + echo "Using 'runner' user" |
| 203 | + sudo -u runner bash -c "cd ${{ github.workspace }} && DOCKER_HOST=unix:///Applications/Finch/lima/data/finch/sock/finch.sock make test-e2e-opa" || true |
| 204 | + fi |
| 205 | + |
| 206 | + # Approach 3: Use current non-root user from environment |
| 207 | + if [ -n "$SUDO_USER" ]; then |
| 208 | + echo "Using SUDO_USER: $SUDO_USER" |
| 209 | + sudo -u $SUDO_USER bash -c "cd ${{ github.workspace }} && DOCKER_HOST=unix:///Applications/Finch/lima/data/finch/sock/finch.sock make test-e2e-opa" || true |
| 210 | + fi |
| 211 | + |
| 212 | + # Cleanup |
| 213 | + - name: Stop Finch VM |
| 214 | + run: | |
| 215 | + echo "Attempting to stop Finch VM..." |
| 216 | + |
| 217 | + # Approach 1: Direct finch command |
| 218 | + finch vm stop || true |
| 219 | + |
| 220 | + # Approach 2: Use specific finch path |
| 221 | + /opt/homebrew/bin/finch vm stop || true |
| 222 | + |
| 223 | + # Approach 3: Use sudo with specific user if available |
| 224 | + if id runner &>/dev/null; then |
| 225 | + echo "Using 'runner' user" |
| 226 | + sudo -u runner /opt/homebrew/bin/finch vm stop || true |
| 227 | + fi |
| 228 | + |
| 229 | + # Approach 4: Use current non-root user from environment |
| 230 | + if [ -n "$SUDO_USER" ]; then |
| 231 | + echo "Using SUDO_USER: $SUDO_USER" |
| 232 | + sudo -u $SUDO_USER /opt/homebrew/bin/finch vm stop || true |
| 233 | + fi |
| 234 | + if: always() |
0 commit comments