Browse Source

fix(ci): Remove automation to initialize Docker on Mac (#28352)

Docker has been doing all that is possible to prevent installing Docker Desktop
without user interaction, thus, we can't run `sentry devservices up`.
See https://github.com/docker/for-mac/issues/2359#issuecomment-910532550 for details.

This PR removes all code that at times had managed to automate the process on Github runners.

As a side feature, we add caching for Brew.
Armen Zambrano G 3 years ago
parent
commit
0628cec44c

+ 18 - 31
.github/workflows/development-environment.yml

@@ -3,6 +3,7 @@ on:
   pull_request:
     paths:
       - 'Makefile'
+      - '.github/actions/*'
       - '.github/workflows/development-environment.yml'
       - '.envrc'
       - 'Brewfile'
@@ -17,7 +18,6 @@ jobs:
     timeout-minutes: 40
     strategy:
       matrix:
-        # macosx-11.0 is Big Sur, however, it takes long for jobs to get started
         # Using Ubuntu 18 until I figure out this error:
         # -> ImportError: libffi.so.6: cannot open shared object file: No such file or directory
         os: [macos-11.0, ubuntu-18.04]
@@ -31,30 +31,28 @@ jobs:
       - name: Checkout sentry
         uses: actions/checkout@v2
 
+      - name: Set variables for caches
+        id: info
+        run: |
+          echo "::set-output name=brew-cache-dir::$(brew --cache)"
+          echo "::set-output name=yarn-cache-dir::$(yarn cache dir)"
+
+      - name: Cache (brew)
+        uses: actions/cache@v2
+        with:
+          path: ${{ steps.info.outputs.brew-cache-dir }}
+          key: devenv-${{ runner.os }}-brew-${{ hashFiles('Brewfile') }}
+          restore-keys: devenv-${{ runner.os }}-brew
+
       - name: Install prerequisites
+        # brew can be finicky but it does not always means that the rest of the job will fail
         # Xcode CLI & brew are already installed, thus, no need to call xcode-select install
         # Sometimes, brew needs to be updated before brew bundle would work
-        # After installing Docker (via homebrew) we need to make sure that it is properly initialized on Mac
         run: |
-          brew update && brew bundle -q
-          # This code is mentioned in our dev docs. Only remove if you adjust the docs as well
-          SENTRY_NO_VENV_CHECK=1 ./scripts/do.sh init-docker
+          brew update -q && brew bundle -q || exit 0
 
-      # The next few steps are to set up the cache quickly
-      - name: Set environment variables & others
-        id: info
-        run: |
-          echo "::set-output name=python-version::$(SENTRY_NO_VENV_CHECK=1 ./scripts/do.sh get-pyenv-version)"
-          echo "::set-output name=pip-cache-dir::$(pip3 cache dir)"
-          echo "::set-output name=pip-version::$(pip -V | awk -F ' ' '{print $2}')"
-          echo "::set-output name=yarn-cache-dir::$(yarn cache dir)"
-
-      # In a sense, we set up Python two times (once here and once via pyenv). Setting
-      # it up here is instant and it helps us to get the cache primed sooner
       - name: Setup Python
-        uses: actions/setup-python@v2
-        with:
-          python-version: ${{ steps.info.outputs.python-version }}
+        uses: ./.github/actions/setup-python
 
       - name: Cache (pyenv)
         uses: actions/cache@v2
@@ -62,12 +60,6 @@ jobs:
           path: ~/.pyenv
           key: devenv-${{ matrix.os }}-pyenv-${{ hashFiles('.python-version') }}
 
-      - name: Cache (pip)
-        uses: actions/cache@v2
-        with:
-          path: ${{ steps.info.outputs.pip-cache-dir }}
-          key: devenv-${{ matrix.os }}-py${{ steps.info.outputs.python-version }}-pip${{ steps.info.outputs.pip-version }}-${{ hashFiles('**/requirements.txt') }}
-
       - name: Cache (yarn)
         uses: actions/cache@v1 # We are explicitly using v1 due to perf reasons
         with:
@@ -83,9 +75,4 @@ jobs:
           eval "$(pyenv init --path)"
           python -m venv .venv
           source .venv/bin/activate
-          make bootstrap
-
-      - name: Test direnv
-        run: |
-          brew install direnv
-          direnv allow
+          make develop init-config

+ 0 - 28
.github/workflows/files/com.docker.vmnetd.plist

@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>Label</key>
-	<string>com.docker.vmnetd</string>
-	<key>Program</key>
-	<string>/Library/PrivilegedHelperTools/com.docker.vmnetd</string>
-	<key>ProgramArguments</key>
-	<array>
-		<string>/Library/PrivilegedHelperTools/com.docker.vmnetd</string>
-	</array>
-	<key>RunAtLoad</key>
-	<true/>
-	<key>Sockets</key>
-	<dict>
-		<key>Listener</key>
-		<dict>
-			<key>SockPathMode</key>
-			<integer>438</integer>
-			<key>SockPathName</key>
-			<string>/var/run/com.docker.vmnetd.sock</string>
-		</dict>
-	</dict>
-	<key>Version</key>
-	<string>59</string>
-</dict>
-</plist>

+ 2 - 10
.github/workflows/python-deps.yml

@@ -2,6 +2,7 @@ name: python deps
 on:
   pull_request:
     paths:
+      - '.github/actions/*'
       - '.github/workflows/python-deps.yml'
       - 'requirements*'
 
@@ -26,17 +27,8 @@ jobs:
     steps:
       - uses: actions/checkout@v2
 
-      - name: Install prerequisites
-        # Sometimes, brew needs to be updated before brew bundle would work
-        run: |
-          brew update && brew bundle -q
-
-      - name: Setup python
-        id: setup-python
+      - name: Setup Python
         uses: ./.github/actions/setup-python
-        with:
-          # XXX: We need to pass this python-deps-${{ matrix.os }}-py${{ matrix.python-version }}-${{ hashFiles('requirements-*.txt') }}
-          cache-files-hash: ${{ hashFiles('requirements-*.txt') }}
 
       - name: Install dependencies
         run: |

+ 0 - 47
scripts/lib.sh

@@ -79,53 +79,6 @@ sudo-askpass() {
     fi
 }
 
-# After using homebrew to install docker, we need to do some magic to remove the need to interact with the GUI
-# See: https://github.com/docker/for-mac/issues/2359#issuecomment-607154849 for why we need to do things below
-init-docker() {
-    # Need to start docker if it was freshly installed or updated
-    # You will know that Docker is ready for devservices when the icon on the menu bar stops flashing
-    if query-mac && ! require docker && [ -d "/Applications/Docker.app" ]; then
-        echo "Making some changes to complete Docker initialization"
-        # allow the app to run without confirmation
-        xattr -d -r com.apple.quarantine /Applications/Docker.app
-
-        # preemptively do docker.app's setup to avoid any gui prompts
-        # This path is not available for brand new MacBooks
-        sudo-askpass /bin/mkdir -p /Library/PrivilegedHelperTools
-        sudo-askpass /bin/chmod 754 /Library/PrivilegedHelperTools
-        sudo-askpass /bin/cp /Applications/Docker.app/Contents/Library/LaunchServices/com.docker.vmnetd /Library/PrivilegedHelperTools/
-        sudo-askpass /bin/chmod 544 /Library/PrivilegedHelperTools/com.docker.vmnetd
-
-        # This file used to be generated as part of brew's installation
-        if [ -f /Applications/Docker.app/Contents/Resources/com.docker.vmnetd.plist ]; then
-            sudo-askpass /bin/cp /Applications/Docker.app/Contents/Resources/com.docker.vmnetd.plist /Library/LaunchDaemons/
-        else
-            sudo-askpass /bin/cp .github/workflows/files/com.docker.vmnetd.plist /Library/LaunchDaemons/
-        fi
-        sudo-askpass /bin/chmod 644 /Library/LaunchDaemons/com.docker.vmnetd.plist
-        sudo-askpass /bin/launchctl load /Library/LaunchDaemons/com.docker.vmnetd.plist
-    fi
-    start-docker
-}
-
-# This is mainly to be used by CI
-# We need this for Mac since the executable docker won't work properly
-# until the app is opened once
-start-docker() {
-    if query-mac && ! docker system info &>/dev/null; then
-        echo "About to open Docker.app"
-        # At a later stage in the script, we're going to execute
-        # ensure_docker_server which waits for it to be ready
-        if ! open -g -a Docker.app; then
-            # If the step above fails, at least we can get some debugging information to determine why
-            sudo-askpass ls -l /Library/PrivilegedHelperTools/com.docker.vmnetd
-            ls -l /Library/LaunchDaemons/
-            cat /Library/LaunchDaemons/com.docker.vmnetd.plist
-            ls -l /Applications/Docker.app
-        fi
-    fi
-}
-
 upgrade-pip() {
     pip install --upgrade "pip==21.1.2" "wheel==0.36.2"
 }