Browse Source

fix(ci): Fix dev env workflow Docker initialization code (#26296)

The dev env workflow has recently been failing to initialize Docker properly. I don't know if the host runners changed or if the newer version of Docker does things differently. Either way, the file `com.docker.vmnetd.plist` is sometimes not on disk when we try to copy it, thus, we commit in the repo a copy of it in case it's missing.

We also reverted the condition to it's [original code](https://github.com/getsentry/bootstrap-sentry/blob/259a2710b41aeae06e9065a853176e20a7e0fc30/bootstrap.sh#L364) since there's a bug that would always resolve to true.
Armen Zambrano G 3 years ago
parent
commit
701be72529

+ 8 - 8
.github/workflows/development-environment.yml

@@ -43,17 +43,17 @@ jobs:
         # After installing Docker (via homebrew) we need to make sure that it is properly initialized on Mac
         run: |
           HOMEBREW_NO_AUTO_UPDATE=1 brew bundle -q --no-upgrade || brew update && brew bundle
+          # 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
 
-      - name: Install Python (via Pyenv)
+      # XXX: This is a temporary change. There's another PR that will bring this workflow up-to-date
+      # 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
         id: python-version
-        # XXX: Can we cache the installed Python environments?
-        # We echo to $GITHUB_ENV to make the PATH changes by pyenv init permanent for the rest of the execution
-        run: |
-          make setup-pyenv
-          eval "$(pyenv init -)"
-          echo "PATH=$PATH" >> $GITHUB_ENV
-          echo "::set-output name=python-version::$(python -V  | sed s/Python\ //g)"
+        with:
+          python-version: 3.6.13
 
       - name: Setup pip
         uses: ./.github/actions/setup-pip

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

@@ -0,0 +1,28 @@
+<?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>

+ 8 - 4
scripts/lib.sh

@@ -40,17 +40,21 @@ sudo-askpass() {
 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 && [ ! -f /Library/PrivilegedHelperTools/com.docker.vmnetd ]; then
+    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
-        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/cp /Applications/Docker.app/Contents/Resources/com.docker.vmnetd.plist /Library/LaunchDaemons/
         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