From 378bd0b6f87997683b1b9d16698751b33c1945c6 Mon Sep 17 00:00:00 2001 From: Daz DeBoer Date: Mon, 6 Sep 2021 13:23:36 -0600 Subject: [PATCH] Save and restore caches in parallel --- src/caches.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/caches.ts b/src/caches.ts index 714ef2c..562bc55 100644 --- a/src/caches.ts +++ b/src/caches.ts @@ -11,11 +11,13 @@ export async function restore(buildRootDirectory: string): Promise { return } - core.startGroup('Restore Gradle state from cache') - core.saveState(BUILD_ROOT_DIR, buildRootDirectory) - new GradleUserHomeCache().restore() - new ProjectDotGradleCache(buildRootDirectory).restore() - core.endGroup() + await core.group('Restore Gradle state from cache', async () => { + core.saveState(BUILD_ROOT_DIR, buildRootDirectory) + return Promise.all([ + new GradleUserHomeCache().restore(), + new ProjectDotGradleCache(buildRootDirectory).restore() + ]) + }) } export async function save(): Promise { @@ -24,9 +26,11 @@ export async function save(): Promise { return } - core.startGroup('Caching Gradle state') - const buildRootDirectory = core.getState(BUILD_ROOT_DIR) - new GradleUserHomeCache().save() - new ProjectDotGradleCache(buildRootDirectory).save() - core.endGroup() + await core.group('Caching Gradle state', async () => { + const buildRootDirectory = core.getState(BUILD_ROOT_DIR) + return Promise.all([ + new GradleUserHomeCache().save(), + new ProjectDotGradleCache(buildRootDirectory).save() + ]) + }) }