|
| 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 | + - name: Install Rosetta 2 |
| 46 | + run: echo "A" | softwareupdate --install-rosetta || true |
| 47 | + - name: Install dependencies |
| 48 | + run: | |
| 49 | + # Ensure brew is not run as root |
| 50 | + if [ "$(id -u)" -eq 0 ]; then |
| 51 | + echo "Running as root, switching to regular user for brew commands" |
| 52 | + # Get the regular user |
| 53 | + REGULAR_USER=$(stat -f "%Su" /dev/console) |
| 54 | + su - $REGULAR_USER -c "brew install lz4 automake autoconf libtool yq" |
| 55 | + else |
| 56 | + brew install lz4 automake autoconf libtool yq |
| 57 | + fi |
| 58 | + shell: zsh {0} |
| 59 | + |
| 60 | + # Install Finch |
| 61 | + - name: Install Finch |
| 62 | + run: | |
| 63 | + # Ensure brew is not run as root |
| 64 | + if [ "$(id -u)" -eq 0 ]; then |
| 65 | + echo "Running as root, switching to regular user for brew commands" |
| 66 | + # Get the regular user |
| 67 | + REGULAR_USER=$(stat -f "%Su" /dev/console) |
| 68 | + su - $REGULAR_USER -c "brew install finch" |
| 69 | + else |
| 70 | + brew install finch |
| 71 | + fi |
| 72 | + shell: zsh {0} |
| 73 | + |
| 74 | + # Initialize and start Finch VM |
| 75 | + - name: Initialize Finch VM |
| 76 | + run: | |
| 77 | + # Ensure finch commands run as the same user who installed it |
| 78 | + if [ "$(id -u)" -eq 0 ]; then |
| 79 | + echo "Running as root, switching to regular user for finch commands" |
| 80 | + # Get the regular user |
| 81 | + REGULAR_USER=$(stat -f "%Su" /dev/console) |
| 82 | + su - $REGULAR_USER -c "finch vm init" |
| 83 | + else |
| 84 | + finch vm init |
| 85 | + fi |
| 86 | + |
| 87 | + - name: Start Finch VM |
| 88 | + run: | |
| 89 | + # Ensure finch commands run as the same user who installed it |
| 90 | + if [ "$(id -u)" -eq 0 ]; then |
| 91 | + echo "Running as root, switching to regular user for finch commands" |
| 92 | + # Get the regular user |
| 93 | + REGULAR_USER=$(stat -f "%Su" /dev/console) |
| 94 | + su - $REGULAR_USER -c "finch vm start" |
| 95 | + else |
| 96 | + finch vm start |
| 97 | + fi |
| 98 | + |
| 99 | + # Run e2e tests inside the Finch VM |
| 100 | + - name: Run e2e tests |
| 101 | + run: | |
| 102 | + # Set the DOCKER_HOST environment variable |
| 103 | + export DOCKER_HOST=unix:///Applications/Finch/lima/data/finch/sock/finch.sock |
| 104 | + make test-e2e |
| 105 | + |
| 106 | + # Run e2e tests with OPA authorization |
| 107 | + - name: Run opa e2e tests |
| 108 | + run: | |
| 109 | + # Set the DOCKER_HOST environment variable |
| 110 | + export DOCKER_HOST=unix:///Applications/Finch/lima/data/finch/sock/finch.sock |
| 111 | + make test-e2e-opa |
| 112 | + |
| 113 | + # Cleanup |
| 114 | + - name: Stop Finch VM |
| 115 | + run: | |
| 116 | + # Ensure finch commands run as the same user who installed it |
| 117 | + if [ "$(id -u)" -eq 0 ]; then |
| 118 | + echo "Running as root, switching to regular user for finch commands" |
| 119 | + # Get the regular user |
| 120 | + REGULAR_USER=$(stat -f "%Su" /dev/console) |
| 121 | + su - $REGULAR_USER -c "finch vm stop" |
| 122 | + else |
| 123 | + finch vm stop |
| 124 | + fi |
| 125 | + if: always() |
0 commit comments