Browse Source

ci(feature): Cache Brew files and use Catalina instead of Big Sur (#23688)

Caching brew for CI speeds up the installation of dependencies for Sentry.

We also change the OS we test on in order to speed up the execution of this workflow (The Big Sur capacity seems small).
Armen Zambrano G 4 years ago
parent
commit
a149842271
2 changed files with 21 additions and 8 deletions
  1. 19 8
      .github/workflows/development-environment.yml
  2. 2 0
      Brewfile

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

@@ -16,11 +16,29 @@ jobs:
     timeout-minutes: 20
     strategy:
       matrix:
-        os: [ macos-11.0 ]
+        os: [ macos-latest ]
 
     steps:
       - uses: actions/checkout@v2
 
+      - name: Set environment variables & others
+        if: ${{ runner.os == 'macOS' }}
+        shell: bash
+        run: |
+          echo "HOMEBREW_CACHE=`brew --cache`" >> $GITHUB_ENV
+          echo "PYENV_ROOT=$HOME/.pyenv" >> $GITHUB_ENV
+          echo "VOLTA_HOME=$HOME/.volta" >> $GITHUB_ENV
+          echo "PATH=$HOME/.pyenv/shims:$HOME/.volta/bin:$PATH" >> $GITHUB_ENV
+
+      - name: Cache (brew)
+        uses: actions/cache@v2
+        if: ${{ runner.os == 'macOS' }}
+        with:
+          path: $HOMEBREW_CACHE
+          key: ${{ runner.os }}-brew-${{ hashFiles('Brewfile') }}
+          restore-keys: |
+            ${{ runner.os }}-brew
+
       - name: Install prerequisites
         if: ${{ runner.os == 'macOS' }}
         # Depending on the host watchman will not install (read: intermittent issue),
@@ -31,13 +49,6 @@ jobs:
         run: |
           brew bundle
 
-      - name: Set environment variables
-        shell: bash
-        run: |
-          echo "PYENV_ROOT=$HOME/.pyenv" >> $GITHUB_ENV
-          echo "VOLTA_HOME=$HOME/.volta" >> $GITHUB_ENV
-          echo "PATH=$HOME/.pyenv/shims:$HOME/.volta/bin:$PATH" >> $GITHUB_ENV
-
       - name: Install Python (via Pyenv)
         id: python-version
         shell: bash

+ 2 - 0
Brewfile

@@ -1,3 +1,5 @@
+# 2021-02-08 - The CI checks the hash of this file to determine if to create a new
+# cache or not. If you want to force a new cache simply change the date on the line above
 brew 'pyenv'
 
 # required for pyenv's python-build