ci: Speed up MacOS builds
authorJuan Ramos <juan@lunarg.com>
Sat, 3 Dec 2022 00:53:51 +0000 (17:53 -0700)
committerJuan Ramos <114601453+juan-lunarg@users.noreply.github.com>
Mon, 5 Dec 2022 16:04:49 +0000 (09:04 -0700)
Caches update_deps.py dependencies.
In particular MoltenVK since it's a huge dependency.

.github/workflows/build.yml
scripts/update_deps.py

index af8e636..879df77 100644 (file)
@@ -105,19 +105,32 @@ jobs:
             - uses: actions/setup-python@v2
               with:
                 python-version: '3.7'
+            - name: Install Ninja
+              run: brew install ninja
+            - name: Cache dependencies
+              id: cache-deps
+              uses: actions/cache@v3
+              env:
+                cache-name: cache-macos-latest
+              with:
+                path: |
+                  external/Vulkan-Headers/build/install
+                  external/MoltenVK
+                  external/Vulkan-Loader/build/install
+                key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.config }}-${{ hashfiles('scripts/known_good.json') }}
 
-            - name: Fetch and install headers
-              run: python scripts/update_deps.py --dir external
+            - name: Fetch/Update dependencies
+              run: python scripts/update_deps.py --dir external --skip-existing-install
 
             - name: Generate build files
-              run: cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=${{matrix.config}} -Cexternal/helper.cmake
+              run: cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=${{matrix.config}} -Cexternal/helper.cmake -G "Ninja"
               env:
                 # Specify the minimum version of macOS on which the target binaries are to be deployed.
                 # https://cmake.org/cmake/help/latest/envvar/MACOSX_DEPLOYMENT_TARGET.html
                 MACOSX_DEPLOYMENT_TARGET: 10.12
 
             - name: Build the tools
-              run: make -C build
+              run: cmake --build build
 
             - name: Verify generated source files
               run: python scripts/generate_source.py --verify external/Vulkan-Headers/registry
index 105ef22..f892be0 100755 (executable)
@@ -652,6 +652,12 @@ def main():
         help="Delete install directory before building",
         default=False)
     parser.add_argument(
+        '--skip-existing-install',
+        dest='skip_existing_install',
+        action='store_true',
+        help="Skip build if install directory exists",
+        default=False)
+    parser.add_argument(
         '--arch',
         dest='arch',
         choices=['32', '64', 'x86', 'x64', 'win32', 'win64'],
@@ -694,6 +700,14 @@ def main():
         if not repo.on_build_platform:
             continue
 
+        # Skip building the repo if its install directory already exists
+        # and requested via an option.  This is useful for cases where the
+        # install directory is restored from a cache that is known to be up
+        # to date.
+        if args.skip_existing_install and os.path.isdir(repo.install_dir):
+            print('Skipping build for repo {n} due to existing install directory'.format(n=repo.name))
+            continue
+
         # Skip test-only repos if the --tests option was not passed in
         if repo.IsOptional(args.optional):
             continue