From 90a8b7b5767d17c71fe2553e57e207e2ecc7bfc6 Mon Sep 17 00:00:00 2001 From: Simeon Widdis Date: Tue, 1 Oct 2024 13:40:01 -0700 Subject: [PATCH] Fix caches Signed-off-by: Simeon Widdis --- .../ftr-e2e-dashboards-observability-test.yml | 22 +++------- .../workflows/integration-tests-workflow.yml | 40 +++++++------------ 2 files changed, 21 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ftr-e2e-dashboards-observability-test.yml b/.github/workflows/ftr-e2e-dashboards-observability-test.yml index 7934654ad2..e2b7441471 100644 --- a/.github/workflows/ftr-e2e-dashboards-observability-test.yml +++ b/.github/workflows/ftr-e2e-dashboards-observability-test.yml @@ -109,30 +109,20 @@ jobs: registry-url: "https://registry.npmjs.org" - name: Install correct yarn version for OpenSearch Dashboards + id: setup-yarn run: | npm uninstall -g yarn echo "Installing yarn ${{ steps.versions_step.outputs.yarn_version }}" npm i -g yarn@${{ steps.versions_step.outputs.yarn_version }} + echo "yarn-cache-dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - - name: Cache node modules + - name: Yarn Cache uses: actions/cache@v4 with: - path: OpenSearch-Dashboards/**/node_modules - key: ${{ runner.OS }}-node-${{ hashFiles('OpenSearch-Dashboards/**/package-lock.json') }} + path: ${{ steps.setup-yarn.outputs.yarn-cache-dir }} + key: ${{ runner.OS }}-yarn-${{ hashFiles('OpenSearch-Dashboards/**/yarn.lock') }} restore-keys: | - ${{ runner.OS }}-node- - - - name: Restore target caches - id: cache-target-folders-restore - shell: bash - run: | - echo "Restoring target folder caches..." - target_folders=("./OpenSearch-Dashboards/packages/*/target" "./OpenSearch-Dashboards/src/plugins/*/target" "./OpenSearch-Dashboards/src/core/target" "./plugins/dashboards-observability/target") - for target_folder in "${target_folders[@]}"; do - target_name = $(echo "$target_folder" | sed 's/\/target//g') - cache_key="${{ runner.OS }}-$target_name-${{ hashFiles("$target_folder/**/*", "!$target_folder/target/**") }} - restored_cache=$(actions/cache/restore@v4 -p "$target_folder/target" -k "$cache_key" -r "${{ runner.OS }}-$target_name-") - done + ${{ runner.OS }}-yarn- - name: Bootstrap OpenSearch Dashboards run: | diff --git a/.github/workflows/integration-tests-workflow.yml b/.github/workflows/integration-tests-workflow.yml index 1736a02423..515e78d4dd 100644 --- a/.github/workflows/integration-tests-workflow.yml +++ b/.github/workflows/integration-tests-workflow.yml @@ -131,30 +131,32 @@ jobs: working-directory: OpenSearch-Dashboards - name: Install correct yarn version for OpenSearch Dashboards + id: setup-yarn run: | npm uninstall -g yarn echo "Installing yarn ${{ steps.versions_step.outputs.yarn_version }}" npm i -g yarn@${{ steps.versions_step.outputs.yarn_version }} + echo "yarn-cache-dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - - name: Cache node modules + - name: Yarn Cache uses: actions/cache@v4 with: - path: OpenSearch-Dashboards/**/node_modules + path: ${{ steps.setup-yarn.outputs.yarn-cache-dir }} key: ${{ runner.OS }}-node-${{ hashFiles('OpenSearch-Dashboards/**/yarn.lock') }} restore-keys: | ${{ runner.OS }}-node- - - name: Restore core-targets caches - id: cache-target-folders - shell: bash - run: | - echo "Restoring target folder caches..." - target_folders=("./OpenSearch-Dashboards/packages/*/target" "./OpenSearch-Dashboards/src/plugins/*/target" "./OpenSearch-Dashboards/src/core/target" "./plugins/dashboards-observability/target") - for target_folder in "${target_folders[@]}"; do - target_name = $(echo "$target_folder" | sed 's/\/target//g') - cache_key="${{ runner.OS }}-$target_name-${{ hashFiles("$target_folder/**/*", "!$target_folder/target/**") }} - restored_cache=$(actions/cache/restore@v4 -p "$target_folder/target" -k "$cache_key" -r "${{ runner.OS }}-$target_name-") - done + - name: Cache build targets + uses: actions/cache@v4 + with: + path: | + OpenSearch-Dashboards/packages/*/target + OpenSearch-Dashboards/src/plugins/*/target + OpenSearch-Dashboards/src/core/target + OpenSearch-Dashboards/plugins/dashboards-observability/target + key: ${{ runner.OS }}-targets-${{ hashFiles('OpenSearch-Dashboards/yarn.lock' 'OpenSearch-Dashboards/plugins/dashboards-observability/yarn.lock') }} + restore-keys: | + ${{ runner.OS }}-targets- - name: Bootstrap OpenSearch Dashboards run: | @@ -166,18 +168,6 @@ jobs: cd OpenSearch-Dashboards node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers=10 --verbose - - name: Stash core-targets caches - id: cache-target-folders - shell: bash - run: | - echo "Saving target folder caches..." - target_folders=("./OpenSearch-Dashboards/packages/*/target" "./OpenSearch-Dashboards/src/plugins/*/target" "./OpenSearch-Dashboards/src/core/target" "./plugins/dashboards-observability/target") - for target_folder in "${target_folders[@]}"; do - target_name = $(echo "$target_folder" | sed 's/\/target//g') - cache_key="${{ runner.OS }}-$target_name-${{ hashFiles("$target_folder/**/*", "!$target_folder/target/**") }} - actions/cache/save@v4 -p "$target_folder/target" -k "$cache_key" -r "${{ runner.OS }}-$target_name-" - done - - name: Run OpenSearch Dashboards server run: | cd OpenSearch-Dashboards